Accord.Tests.Math.JaggedSingularValueDecompositionTest.JaggedSingularValueDecompositionConstructorTest5 C# (CSharp) Method

JaggedSingularValueDecompositionConstructorTest5() private method

private JaggedSingularValueDecompositionConstructorTest5 ( ) : void
return void
        public void JaggedSingularValueDecompositionConstructorTest5()
        {
            // Test using SVD assumption auto-correction feature
            // without computing the left singular vectors.

            var value = new double[][]
            { 
                 new double[] { 1, 2 },
                 new double[] { 3, 4 },
                 new double[] { 5, 6 },
                 new double[] { 7, 8 }
            }.Transpose(); // value is 2x4, having less rows than columns.

            var target = new JaggedSingularValueDecomposition(value, false, true, true);


            // Checking values
            double[][] U =
            {
                new double[] { 0.0, 0.0 },
                new double[] { 0.0, 0.0 },
            };

            // U should not have been computed
            Assert.IsTrue(Matrix.IsEqual(target.LeftSingularVectors, U));


            double[][] V = // economy svd
            {
                new double[] {  0.152483233310201,  0.822647472225661,  },
                new double[] {  0.349918371807964,  0.421375287684580,  },
                new double[] {  0.547353510305727,  0.0201031031435023, },
                new double[] {  0.744788648803490, -0.381169081397574,  },
            };

            // V can be different, but for the economy SVD it is often equal
            Assert.IsTrue(Matrix.IsEqual(target.RightSingularVectors, V, 0.0001));



            double[][] S = 
            {
                new double[] { 14.2690954992615, 0.000000000000000 },
                new double[] {  0.0000000000000,	0.626828232417543 },
            };

            // The diagonal values should be equal
            Assert.IsTrue(Matrix.IsEqual(target.Diagonal, Matrix.Diagonal(S), 0.001));
        }