QLNet.SVD.singularValues C# (CSharp) Метод

singularValues() публичный Метод

public singularValues ( ) : Vector
Результат Vector
        public Vector singularValues()
        {
            return s_;
        }

Usage Example

Пример #1
0
        public void testSVD()
        {
            //BOOST_MESSAGE("Testing singular value decomposition...");

            setup();

            double tol = 1.0e-12;
            Matrix[] testMatrices = { M1, M2, M3, M4 };

            for (int j = 0; j < testMatrices.Length; j++) {
                // m >= n required (rows >= columns)
                Matrix A = testMatrices[j];
                SVD svd = new SVD(A);
                // U is m x n
                Matrix U = svd.U();
                // s is n long
                Vector s = svd.singularValues();
                // S is n x n
                Matrix S = svd.S();
                // V is n x n
                Matrix V = svd.V();

                for (int i=0; i < S.rows(); i++) {
                    if (S[i,i] != s[i])
                        Assert.Fail("S not consistent with s");
                }

                // tests
                Matrix U_Utranspose = Matrix.transpose(U)*U;
                if (norm(U_Utranspose-I) > tol)
                    Assert.Fail("U not orthogonal (norm of U^T*U-I = " + norm(U_Utranspose-I) + ")");

                Matrix V_Vtranspose = Matrix.transpose(V) * V;
                if (norm(V_Vtranspose-I) > tol)
                    Assert.Fail("V not orthogonal (norm of V^T*V-I = " + norm(V_Vtranspose-I) + ")");

                Matrix A_reconstructed = U * S * Matrix.transpose(V);
                if (norm(A_reconstructed-A) > tol)
                    Assert.Fail("Product does not recover A: (norm of U*S*V^T-A = " + norm(A_reconstructed-A) + ")");
            }
        }
All Usage Examples Of QLNet.SVD::singularValues