Beispiel #1
0
            public void can_get_componenets()
            {
                var v = new VectorD(new[] { 3.0, 4.0, 5.0 });

                Assert.Equal(3.0, v.Get(0));
                Assert.Equal(4.0, v.Get(1));
                Assert.Equal(5.0, v.Get(2));
            }
Beispiel #2
0
            public void get_large_dimension_throws()
            {
                var v = new VectorD(5);

                Assert.Throws <ArgumentOutOfRangeException>(() => v.Get(5));
                Assert.Throws <ArgumentOutOfRangeException>(() => v.Get(6));
                Assert.Throws <ArgumentOutOfRangeException>(() => v.Get(101));
                Assert.Throws <ArgumentOutOfRangeException>(() => v.Get(int.MaxValue));
            }
Beispiel #3
0
            public void get_negative_dimension_throws()
            {
                var v = new VectorD(5);

                Assert.Throws <ArgumentOutOfRangeException>(() => v.Get(-1));
                Assert.Throws <ArgumentOutOfRangeException>(() => v.Get(-4));
                Assert.Throws <ArgumentOutOfRangeException>(() => v.Get(-5));
                Assert.Throws <ArgumentOutOfRangeException>(() => v.Get(int.MinValue));
            }
Beispiel #4
0
            public void can_set_componenets()
            {
                var v = new VectorD(new[] { 2.0, 6.0, 7.0 });

                v.Set(0, 3.0);
                v.Set(1, 4.0);
                v.Set(2, 5.0);

                Assert.Equal(3.0, v.Get(0));
                Assert.Equal(4.0, v.Get(1));
                Assert.Equal(5.0, v.Get(2));
            }
Beispiel #5
0
            public void get_all_element_for_dim_5()
            {
                var v = new VectorD(5);

                v.Set(0, -1.0);
                v.Set(1, 5.7);
                v.Set(2, -0.4);
                v.Set(3, 9.0);
                v.Set(4, -101.1);

                Assert.Equal(-1.0, v.Get(0));
                Assert.Equal(5.7, v.Get(1));
                Assert.Equal(-0.4, v.Get(2));
                Assert.Equal(9.0, v.Get(3));
                Assert.Equal(-101.1, v.Get(4));
            }
Beispiel #6
0
            public void size_constructor_sets_components_to_zero()
            {
                var v = new VectorD(15);

                Assert.Equal(15, v.Dimensions);

                for (var d = 0; d < v.Dimensions; d++)
                {
                    Assert.Equal(0.0, v.Get(d));
                }
            }