/** * An orthogonal matrix that has the following property: H = Q<sup>T</sup>AQ * * @param Q If not null then the results will be stored here. Otherwise a new matrix will be created. * @return The extracted Q matrix. */ public DMatrixRMaj getQ(DMatrixRMaj Q) { Q = UtilDecompositons_DDRM.checkIdentity(Q, N, N); for (int j = N - 2; j >= 0; j--) { u[j + 1] = 1; for (int i = j + 2; i < N; i++) { u[i] = QH.get(i, j); } QrHelperFunctions_DDRM.rank1UpdateMultR(Q, u, gammas[j], j + 1, j + 1, N, b); } return(Q); }
/** * An orthogonal matrix that has the following property: T = Q<sup>T</sup>AQ * * @param Q If not null then the results will be stored here. Otherwise a new matrix will be created. * @return The extracted Q matrix. */ public DMatrixRMaj getQ(DMatrixRMaj Q) { Q = UtilDecompositons_DDRM.checkIdentity(Q, N, N); for (int i = 0; i < N; i++) { w[i] = 0; } for (int j = N - 2; j >= 0; j--) { w[j + 1] = 1; for (int i = j + 2; i < N; i++) { w[i] = QT.get(j, i); } QrHelperFunctions_DDRM.rank1UpdateMultR(Q, w, gammas[j + 1], j + 1, j + 1, N, b); // Q.print(); } return(Q); }
/** * Computes the Q matrix from the imformation stored in the QR matrix. This * operation requires about 4(m<sup>2</sup>n-mn<sup>2</sup>+n<sup>3</sup>/3) flops. * * @param Q The orthogonal Q matrix. */ public virtual DMatrixRMaj getQ(DMatrixRMaj Q, bool compact) { if (compact) { Q = UtilDecompositons_DDRM.checkIdentity(Q, numRows, minLength); } else { Q = UtilDecompositons_DDRM.checkIdentity(Q, numRows, numRows); } for (int j = minLength - 1; j >= 0; j--) { double[] u = dataQR[j]; double vv = u[j]; u[j] = 1; QrHelperFunctions_DDRM.rank1UpdateMultR(Q, u, gammas[j], j, j, numRows, v); u[j] = vv; } return(Q); }
/** * An orthogonal matrix that has the following property: T = Q<sup>T</sup>AQ * * @param Q If not null then the results will be stored here. Otherwise a new matrix will be created. * @return The extracted Q matrix. */ //@Override public DMatrixRMaj getQ(DMatrixRMaj Q, bool transposed) { Q = UtilDecompositons_DDRM.checkIdentity(Q, N, N); for (int i = 0; i < N; i++) { w[i] = 0; } if (transposed) { for (int j = N - 2; j >= 0; j--) { w[j + 1] = 1; for (int i = j + 2; i < N; i++) { w[i] = QT.data[j * N + i]; } QrHelperFunctions_DDRM.rank1UpdateMultL(Q, w, gammas[j + 1], j + 1, j + 1, N); } } else { for (int j = N - 2; j >= 0; j--) { w[j + 1] = 1; for (int i = j + 2; i < N; i++) { w[i] = QT.get(j, i); } QrHelperFunctions_DDRM.rank1UpdateMultR(Q, w, gammas[j + 1], j + 1, j + 1, N, b); } } return(Q); }