public override /**/ double quality() { return(SpecializedOps_ZDRM.qualityTriangular(R)); } /** * Solves for X using the QR decomposition. * * @param B A matrix that is n by m. Not modified. * @param X An n by m matrix where the solution is written to. Modified. */ //@Override public override void solve(ZMatrixRMaj B, ZMatrixRMaj X) { if (X.numRows != numCols) { throw new ArgumentException("Unexpected dimensions for X"); } else if (B.numRows != numRows || B.numCols != X.numCols) { throw new ArgumentException("Unexpected dimensions for B"); } int BnumCols = B.numCols; Y.reshape(numRows, 1); Z.reshape(numRows, 1); // solve each column one by one for (int colB = 0; colB < BnumCols; colB++) { // make a copy of this column in the vector for (int i = 0; i < numRows; i++) { int indexB = B.getIndex(i, colB); Y.data[i * 2] = B.data[indexB]; Y.data[i * 2 + 1] = B.data[indexB + 1]; } // Solve Qa=b // a = Q'b CommonOps_ZDRM.mult(Qt, Y, Z); // solve for Rx = b using the standard upper triangular solver TriangularSolver_ZDRM.solveU(R.data, Z.data, numCols); // save the results for (int i = 0; i < numCols; i++) { X.set(i, colB, Z.data[i * 2], Z.data[i * 2 + 1]); } } }
//@Override public void mult(ZMatrixRMaj A, ZMatrixRMaj B, ZMatrixRMaj output) { CommonOps_ZDRM.mult(A, B, output); }