Examples of QRDecomposition


Examples of org.jquantlib.math.matrixutilities.QRDecomposition

        final Matrix testMatrices[] = { M1, M2, I, M3, M3.transpose(), M4, M4.transpose(), M5 };

        for (final Matrix A : testMatrices) {

            QRDecomposition qr;
            Matrix Q;
            Matrix R;
            final Matrix P;
            final Matrix mT;
            Matrix mul1;
            final Matrix mul2;
            double norm;

            // System.out.println("///////////////////////////////////////////////");

            // System.out.println("Matrix A = "+A.toString());

            // System.out.println("// QR decomposition with column pivoting");
            qr = new Matrix(A).qr(true);
            R = qr.R();
            Q = qr.Q();
            P = qr.P();

            // norm(Q*R - A*P)
            mul1 = Q.mul(R);
            mul2 = A.mul(P);
            norm = norm( mul1.sub(mul2) );
            if (norm > tolerance) {
                fail("Q*R (pivot=true) does not match matrix A*P :: norm = "+String.valueOf(norm));
            }



            // System.out.println("// QR decomposition without column pivoting");
            qr = new Matrix(A).qr();
            // norm(Q*R - A)
            R = qr.R();
            Q = qr.Q();

            mul1 = Q.mul(R);
            norm = norm(mul1.sub(A));
            if (norm > tolerance) {
                fail("Q*R (pivot=false) does not match matrix A :: norm = "+String.valueOf(norm));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.