Beispiel #1
0
        public void LinearAlgebraSVD()
        {
            //using DotNumerics.LinearAlgebra;
            //using DotNumerics;

            Matrix A = new Matrix(3, 2);

            A[0, 0] = 2; A[0, 1] = 5;
            A[1, 0] = 1; A[1, 1] = 5;
            A[2, 0] = 8; A[2, 1] = 2;


            SingularValueDecomposition svd = new SingularValueDecomposition();
            Matrix S;
            Matrix U;
            Matrix VT;

            svd.ComputeSVD(A, out S, out U, out VT);

            Matrix AmUSVT = A - U * S * VT;

            ObjectDumper.Write("A=");
            ObjectDumper.Write(A.MatrixToString("0.000"));

            ObjectDumper.Write("S =");
            ObjectDumper.Write(S.MatrixToString("0.000"));

            ObjectDumper.Write("U = ");
            ObjectDumper.Write(U.MatrixToString("0.000"));

            ObjectDumper.Write("VT = ");
            ObjectDumper.Write(VT.MatrixToString("0.000"));

            ObjectDumper.Write("A - U * S * VT - VT = ");
            ObjectDumper.Write(AmUSVT.MatrixToString("0.000"));
        }