Examples of QRDecomposition


Examples of Jama.QRDecomposition

     * inversion/qr decomposition until the preferable
     * Apache commons class catches up. Matrix is the Jama version
     * RealMatrixImpl is the commons version.
     */
    Matrix v = new Matrix(new VandermondeMatrix(x,order+1).getMatrix().getData());
    QRDecomposition qr = new QRDecomposition(v);
    rMatrix = new RealMatrixImpl(qr.getR().getArray());
    qMatrix = new RealMatrixImpl(qr.getQ().getArray());
    RealMatrix qMatrixTransposed = qMatrix.transpose();
    RealMatrix qByY = qMatrixTransposed.multiply(yMatrix);
    RealMatrix  rMatrixInverse = new RealMatrixImpl(new Matrix(rMatrix.getData()).inverse().getArray());
    RealMatrix resultMatrix = rMatrixInverse.multiply(qByY);
    coefficiants= resultMatrix.getColumn(0);
View Full Code Here

Examples of Jama.QRDecomposition

            errorCount = try_failure(errorCount, "times(double)...",
                    "incorrect Matrix-scalar product calculation");
        }

        A = new Matrix(columnwise, 4);
        QRDecomposition QR = A.qr();

        R = QR.getR();
        try {
            check(A, QR.getQ().times(R));
            try_success("QRDecomposition...", "");
        } catch (java.lang.RuntimeException e) {
            errorCount = try_failure(errorCount, "QRDecomposition...",
                    "incorrect QR decomposition calculation");
        }
View Full Code Here

Examples of Jama.QRDecomposition

            Matrix R = L.times(U).minus(M.getMatrix(p, 0, n - 1));
            double res = R.norm1() / (n * eps);

            print(fixedWidthDoubletoString(res, 12, 3));

            QRDecomposition QR = new QRDecomposition(M);
            Matrix Q = QR.getQ();

            R = QR.getR();
            R = Q.times(R).minus(M);
            res = R.norm1() / (n * eps);
            print(fixedWidthDoubletoString(res, 12, 3));

            print("\n");
View Full Code Here

Examples of org.apache.commons.math.linear.QRDecomposition

        }
    }

    /** test solve */
    public void testSolve() {
        QRDecomposition decomposition =
            new QRDecompositionImpl(MatrixUtils.createRealMatrix(testData3x3NonSingular));
        DecompositionSolver solver = decomposition.getSolver();
        RealMatrix b = MatrixUtils.createRealMatrix(new double[][] {
                { -102, 12250 }, { 544, 24500 }, { 167, -36750 }
        });
        RealMatrix xRef = MatrixUtils.createRealMatrix(new double[][] {
                { 1, 2515 }, { 2, 422 }, { -3, 898 }
View Full Code Here

Examples of org.apache.commons.math.linear.QRDecomposition

    }

    private void checkDimension(RealMatrix m) {
        int rows = m.getRowDimension();
        int columns = m.getColumnDimension();
        QRDecomposition qr = new QRDecompositionImpl(m);
        assertEquals(rows,    qr.getQ().getRowDimension());
        assertEquals(rows,    qr.getQ().getColumnDimension());
        assertEquals(rows,    qr.getR().getRowDimension());
        assertEquals(columns, qr.getR().getColumnDimension());       
    }
View Full Code Here

Examples of org.apache.commons.math.linear.QRDecomposition

        checkAEqualQR(createTestMatrix(r, q, p));

    }

    private void checkAEqualQR(RealMatrix m) {
        QRDecomposition qr = new QRDecompositionImpl(m);
        double norm = qr.getQ().multiply(qr.getR()).subtract(m).getNorm();
        assertEquals(0, norm, normTolerance);
    }
View Full Code Here

Examples of org.apache.commons.math.linear.QRDecomposition

        checkQOrthogonal(createTestMatrix(r, q, p));

    }

    private void checkQOrthogonal(RealMatrix m) {
        QRDecomposition qr = new QRDecompositionImpl(m);
        RealMatrix eye = MatrixUtils.createRealIdentityMatrix(m.getRowDimension());
        double norm = qr.getQT().multiply(qr.getQ()).subtract(eye).getNorm();
        assertEquals(0, norm, normTolerance);
    }
View Full Code Here

Examples of org.apache.commons.math.linear.QRDecomposition

            }
        });
    }
    /** test matrices values */
    public void testMatricesValues() {
        QRDecomposition qr =
            new QRDecompositionImpl(MatrixUtils.createRealMatrix(testData3x3NonSingular));
        RealMatrix qRef = MatrixUtils.createRealMatrix(new double[][] {
                { -12.0 / 14.0,   69.0 / 175.0,  -58.0 / 175.0 },
                -6.0 / 14.0, -158.0 / 175.0,    6.0 / 175.0 },
                {   4.0 / 14.0,  -30.0 / 175.0, -165.0 / 175.0 }
        });
        RealMatrix rRef = MatrixUtils.createRealMatrix(new double[][] {
                { -14.0,  -21.0, 14.0 },
                {   0.0, -175.0, 70.0 },
                {   0.0,    0.0, 35.0 }
        });
        RealMatrix hRef = MatrixUtils.createRealMatrix(new double[][] {
                { 26.0 / 14.0, 0.0, 0.0 },
                6.0 / 14.0, 648.0 / 325.0, 0.0 },
                { -4.0 / 14.036.0 / 325.0, 2.0 }
        });

        // check values against known references
        RealMatrix q = qr.getQ();
        assertEquals(0, q.subtract(qRef).getNorm(), 1.0e-13);
        RealMatrix qT = qr.getQT();
        assertEquals(0, qT.subtract(qRef.transpose()).getNorm(), 1.0e-13);
        RealMatrix r = qr.getR();
        assertEquals(0, r.subtract(rRef).getNorm(), 1.0e-13);
        RealMatrix h = qr.getH();
        assertEquals(0, h.subtract(hRef).getNorm(), 1.0e-13);

        // check the same cached instance is returned the second time
        assertTrue(q == qr.getQ());
        assertTrue(r == qr.getR());
        assertTrue(h == qr.getH());
       
    }
View Full Code Here

Examples of org.apache.commons.math3.linear.QRDecomposition

        // Compute transpose(J)J.
        final RealMatrix jTj = j.transpose().multiply(j);

        // Compute the covariances matrix.
        final DecompositionSolver solver
            = new QRDecomposition(jTj, threshold).getSolver();
        return solver.getInverse().getData();
    }
View Full Code Here

Examples of org.apache.commons.math3.linear.QRDecomposition

        SiteWithPolynomial nearSite = nearestSites.get(row);
        DefaultPolynomial.populateMatrix(matrix, row, nearSite.pos.x, nearSite.pos.z);
        vector.setEntry(row, nearSite.pos.y);
      }
     
      QRDecomposition qr = new QRDecomposition(matrix);
      RealVector solution = qr.getSolver().solve(vector);
       
      double[] coeffs = solution.toArray();
     
      for (double coeff : coeffs) {
        if (coeff > 10e3) {
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.