/** * Returns the solution X of the linear system A*X = B. * The matrix A must be symmetric and positive-definite. * Also, the matrices A and B must have the same number of rows. * @param b the right-hand-side matrix B. * @return the solution matrix X. */ public DMatrix solve(DMatrix b) { Check.argument(_n==b.getM(),"A and B have same number of rows"); Check.state(_pd,"A is positive-definite"); int n = _n; int nrhs = b.getN(); double[] aa = _l; int lda = _n; double[] ba = b.getPackedColumns(); int ldb = _n; LapackInfo li = new LapackInfo(); _lapack.dpotrs("L",n,nrhs,aa,lda,ba,ldb,li); li.check("dpotrs"); return new DMatrix(_n,nrhs,ba); }