Exemple #1
0
        public void Replace_ShouldSucceed()
        {
            var A = new VectorXD(new double[] { 1, 3, -1, 0, double.PositiveInfinity, -1 }).ToSparse();

            A.Replace(x => x == -1 ? 0.0 : x);
            Assert.Equal(0, A.Get(2));
            Assert.Equal(0, A.Get(5));
            A.Replace(x => double.IsInfinity(x) ? 0.0 : x);
            Assert.Equal(0, A.Get(4));
        }
Exemple #2
0
        public void Replace_ShouldSucceed()
        {
            var A = new VectorXD(new double[] { 1, 3, double.NaN, 0, double.PositiveInfinity, double.NaN });

            A.Replace(x => double.IsNaN(x) ? 0.0 : x);
            Assert.Equal(0, A.Get(2));
            Assert.Equal(0, A.Get(5));
            A.Replace(x => double.IsInfinity(x) ? 0.0 : x);
            Assert.Equal(0, A.Get(4));
        }
Exemple #3
0
        public void Identity_ShouldSucceed()
        {
            VectorXD v = VectorXD.Identity(3, 1);

            Assert.True(v.Max() <= 1.0);
            Assert.True(v.Min() >= 0.0);
            Assert.Equal(3, v.Length);
            Assert.Equal(1, v.Get(1));
            Assert.Equal(0, v.Get(0));
            Assert.Equal(0, v.Get(2));
        }
Exemple #4
0
        public void ConstructorString_ShouldSucceed()
        {
            double[] values = new double[] { 1.0, 2.0, 5.0, 6.0 };

            int      length = 4;
            VectorXD v      = new VectorXD("1 2 5 6");

            Assert.Equal(length, v.Length);

            for (int i = 0; i < length; i++)
            {
                Assert.Equal(values[i], v.Get(i));
            }
        }