public void solve(DMatrixRBlock B, DMatrixRBlock X) { if (B.numRows != QR.numRows) { throw new ArgumentException("Row of B and A do not match"); } X.reshape(QR.numCols, B.numCols); // The system being solved for can be described as: // Q*R*X = B // First apply householder reflectors to B // Y = Q^T*B //decomposer.applyQTran(B); // Second solve for Y using the upper triangle matrix R and the just computed Y // X = R^-1 * Y MatrixOps_DDRB.extractAligned(B, X); // extract a block aligned matrix int M = Math.Min(QR.numRows, QR.numCols); TriangularSolver_DDRB.solve(QR.blockLength, true, new DSubmatrixD1(QR, 0, M, 0, M), new DSubmatrixD1(X), false); }
virtual public void solve(DMatrixRBlock B, DMatrixRBlock X) { if (B.blockLength != blockLength) { throw new ArgumentException("Unexpected blocklength in B."); } DSubmatrixD1 L = new DSubmatrixD1(decomposer.getT(null)); if (X == null) { //X = B.create<DMatrixRBlock>(L.col1, B.numCols); X = new DMatrixRBlock(L.col1, B.numCols); } else { X.reshape(L.col1, B.numCols, blockLength, false); } // L * L^T*X = B // Solve for Y: L*Y = B TriangularSolver_DDRB.solve(blockLength, false, L, new DSubmatrixD1(B), false); // L^T * X = Y TriangularSolver_DDRB.solve(blockLength, false, L, new DSubmatrixD1(B), true); if (X != null) { // copy the solution from B into X MatrixOps_DDRB.extractAligned(B, X); } }