コード例 #1
0
            public void can_get_componenets()
            {
                var v = new VectorF(new[] { 3.0f, 4.0f, 5.0f });

                Assert.Equal(3.0, v.Get(0));
                Assert.Equal(4.0, v.Get(1));
                Assert.Equal(5.0, v.Get(2));
            }
コード例 #2
0
            public void get_large_dimension_throws()
            {
                var v = new VectorF(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));
            }
コード例 #3
0
            public void get_negative_dimension_throws()
            {
                var v = new VectorF(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));
            }
コード例 #4
0
            public void can_set_componenets()
            {
                var v = new VectorF(new[] { 2.0f, 6.0f, 7.0f });

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

                Assert.Equal(3.0, v.Get(0));
                Assert.Equal(4.0, v.Get(1));
                Assert.Equal(5.0, v.Get(2));
            }
コード例 #5
0
            public void get_all_element_for_dim_5()
            {
                var v = new VectorF(5);

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

                Assert.Equal(-1.0f, v.Get(0));
                Assert.Equal(5.7f, v.Get(1));
                Assert.Equal(-0.4f, v.Get(2));
                Assert.Equal(9.0f, v.Get(3));
                Assert.Equal(-101.1f, v.Get(4));
            }
コード例 #6
0
            public void size_constructor_sets_components_to_zero()
            {
                var v = new VectorF(15);

                Assert.Equal(15, v.Dimensions);

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