/** * Constructs and returns the QR-decomposition of the given matrix. * * @param matrix * sparse matrix * @param order * ordering option (0 to 3); 0: natural ordering, 1: amd(A+A'), * 2: amd(S'*S), 3: amd(A'*A) * @return the QR-decomposition of the given matrix */ public SparseDoubleQRDecomposition qr(DoubleMatrix2D matrix, int order) { return new SparseDoubleQRDecomposition(matrix, order); }
/** * Solves A*x = b. * * @param A * sparse matrix * @param b * right hand side * @return x; a new independent matrix; solution if A is square, least * squares solution if A.rows() > A.columns(), underdetermined * system solution if A.rows() < A.columns(). */ public DoubleMatrix1D solve(DoubleMatrix2D A, DoubleMatrix1D b) { DoubleMatrix1D x = new DenseDoubleMatrix1D(Math.max(A.rows(), A.columns())); x.viewPart(0, (int) b.size()).assign(b); if (A.rows() == A.columns()) { lu(A, 0).solve(x); return x; } else { qr(A, 0).solve(x); return x.viewPart(0, A.columns()).copy(); } } }
throw new IllegalArgumentException("The size b must be equal to max(A.rows(), A.columns())."); if (!this.hasFullRank()) { throw new IllegalArgumentException("Matrix is rank deficient.");
/** * Solves A*x = b. * * @param A * sparse matrix * @param b * right hand side * @return x; a new independent matrix; solution if A is square, least * squares solution if A.rows() > A.columns(), underdetermined * system solution if A.rows() < A.columns(). */ public DoubleMatrix1D solve(DoubleMatrix2D A, DoubleMatrix1D b) { DoubleMatrix1D x = new DenseDoubleMatrix1D(Math.max(A.rows(), A.columns())); x.viewPart(0, (int) b.size()).assign(b); if (A.rows() == A.columns()) { lu(A, 0).solve(x); return x; } else { qr(A, 0).solve(x); return x.viewPart(0, A.columns()).copy(); } } }
throw new IllegalArgumentException("The size b must be equal to max(A.rows(), A.columns())."); if (!this.hasFullRank()) { throw new IllegalArgumentException("Matrix is rank deficient.");
/** * Constructs and returns the QR-decomposition of the given matrix. * * @param matrix * sparse matrix * @param order * ordering option (0 to 3); 0: natural ordering, 1: amd(A+A'), * 2: amd(S'*S), 3: amd(A'*A) * @return the QR-decomposition of the given matrix */ public SparseDoubleQRDecomposition qr(DoubleMatrix2D matrix, int order) { return new SparseDoubleQRDecomposition(matrix, order); }