QRDecomposition { public RealMatrix getR() { if (cachedR == null) { final int n = qrt.length; final int m = qrt[0].length; double[][] ra = new double[m][n]; for (int row = FastMath.min(m, n) - 1; row >= 0; row--) { ra[row][row] = rDiag[row]; for (int col = row + 1; col < n; col++) { ra[row][col] = qrt[col][row]; } } cachedR = MatrixUtils.createRealMatrix(ra); } return cachedR; } QRDecomposition(RealMatrix matrix);  QRDecomposition(RealMatrix matrix,
                           double threshold); RealMatrix getR(); RealMatrix getQ(); RealMatrix getQT(); RealMatrix getH(); DecompositionSolver getSolver();  }
@Test public void testRUpperTriangular() { RealMatrix matrix = MatrixUtils.createRealMatrix(testData3x3NonSingular); checkUpperTriangular(new QRDecomposition(matrix).getR()); matrix = MatrixUtils.createRealMatrix(testData3x3Singular); checkUpperTriangular(new QRDecomposition(matrix).getR()); matrix = MatrixUtils.createRealMatrix(testData3x4); checkUpperTriangular(new QRDecomposition(matrix).getR()); matrix = MatrixUtils.createRealMatrix(testData4x3); checkUpperTriangular(new QRDecomposition(matrix).getR()); Random r = new Random(643895747384642l); int p = (5 * BlockRealMatrix.BLOCK_SIZE) / 4; int q = (7 * BlockRealMatrix.BLOCK_SIZE) / 4; matrix = createTestMatrix(r, p, q); checkUpperTriangular(new QRDecomposition(matrix).getR()); matrix = createTestMatrix(r, p, q); checkUpperTriangular(new QRDecomposition(matrix).getR()); }