public virtual FMatrixRMaj getT(FMatrixRMaj T) { // write the values to T if (lower) { T = UtilDecompositons_FDRM.checkZerosUT(T, n, n); for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { T.unsafe_set(i, j, this.T.unsafe_get(i, j)); } } } else { T = UtilDecompositons_FDRM.checkZerosLT(T, n, n); for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { T.unsafe_set(i, j, this.T.unsafe_get(i, j)); } } } return(T); }
/** * Writes the upper triangular matrix into the specified matrix. * * @param upper Where the upper triangular matrix is writen to. */ public virtual FMatrixRMaj getUpper(FMatrixRMaj upper) { int numRows = LU.numRows < LU.numCols ? LU.numRows : LU.numCols; int numCols = LU.numCols; upper = UtilDecompositons_FDRM.checkZerosLT(upper, numRows, numCols); for (int i = 0; i < numRows; i++) { for (int j = i; j < numCols; j++) { upper.unsafe_set(i, j, LU.unsafe_get(i, j)); } } return(upper); }
/** * Returns an upper triangular matrix which is the R in the QR decomposition. If compact then the input * expected to be size = [min(rows,cols) , numCols] otherwise size = [numRows,numCols]. * * @param R Storage for upper triangular matrix. * @param compact If true then a compact matrix is expected. */ public virtual FMatrixRMaj getR(FMatrixRMaj R, bool compact) { if (compact) { R = UtilDecompositons_FDRM.checkZerosLT(R, minLength, numCols); } else { R = UtilDecompositons_FDRM.checkZerosLT(R, numRows, numCols); } for (int j = 0; j < numCols; j++) { float[] colR = dataQR[j]; int l = Math.Min(j, numRows - 1); for (int i = 0; i <= l; i++) { float val = colR[i]; R.set(i, j, val); } } return(R); }