/** * Computes and applies the fill reduction permutation. Either A is returned (unmodified) or the permutated * version of A. * @param A Input matrix. unmodified. * @return A permuted matrix. Might be A or a different matrix. */ public DMatrixSparseCSC apply(DMatrixSparseCSC A) { if (fillReduce == null) { return(A); } fillReduce.process(A); IGrowArray gp = fillReduce.getRow(); if (pinv.Length < gp.Length) { pinv = new int[gp.Length]; } CommonOps_DSCC.permutationInverse(gp.data, pinv, gp.Length); if (symmetric) { CommonOps_DSCC.permuteSymmetric(A, pinv, Aperm, gw); } else { CommonOps_DSCC.permuteRowInv(pinv, A, Aperm); } return(Aperm); }
//@Override public DMatrixSparseCSC getQ(DMatrixSparseCSC Q, bool compact) { if (Q == null) { Q = new DMatrixSparseCSC(1, 1, 0); } if (compact) { Q.reshape(V.numRows, n, 0); } else { Q.reshape(V.numRows, m, 0); } DMatrixSparseCSC I = CommonOps_DSCC.identity(V.numRows, Q.numCols); for (int i = V.numCols - 1; i >= 0; i--) { QrHelperFunctions_DSCC.rank1UpdateMultR(V, i, beta[i], I, Q, gwork, gx); I.set(Q); } // Apply P transpose to Q CommonOps_DSCC.permutationInverse(structure.pinv, structureP, V.numRows); CommonOps_DSCC.permuteRowInv(structureP, Q, I); // Remove fictitious rows if (V.numRows > m) { CommonOps_DSCC.extractRows(I, 0, m, Q); } else { Q.set(I); } return(Q); }