/** * Computes the reciprocal condition number * * @param A * The matrix this is a decomposition of * @return The reciprocal condition number. Values close to unity indicate a * well-conditioned system, while numbers close to zero do not. */ public double rcond(Matrix A) { if (n != A.numRows()) throw new IllegalArgumentException("n != A.numRows()"); if (!A.isSquare()) throw new IllegalArgumentException("!A.isSquare()"); double anorm = A.norm(Norm.One); double[] work = new double[3 * n]; int[] iwork = new int[n]; intW info = new intW(0); doubleW rcond = new doubleW(0); if (upper) LAPACK.getInstance().dpocon(UpLo.Upper.netlib(), n, Cu.getData(), Matrices.ld(n), anorm, rcond, work, iwork, info); else LAPACK.getInstance().dpocon(UpLo.Lower.netlib(), n, Cl.getData(), Matrices.ld(n), anorm, rcond, work, iwork, info); if (info.val < 0) throw new IllegalArgumentException(); return rcond.val; }
/** * Computes the reciprocal condition number * * @param A * The matrix this is a decomposition of * @return The reciprocal condition number. Values close to unity indicate a * well-conditioned system, while numbers close to zero do not. */ public double rcond(Matrix A) { if (n != A.numRows()) throw new IllegalArgumentException("n != A.numRows()"); if (!A.isSquare()) throw new IllegalArgumentException("!A.isSquare()"); double anorm = A.norm(Norm.One); double[] work = new double[3 * n]; int[] iwork = new int[n]; intW info = new intW(0); doubleW rcond = new doubleW(0); if (upper) LAPACK.getInstance().dpocon(UpLo.Upper.netlib(), n, Cu.getData(), Matrices.ld(n), anorm, rcond, work, iwork, info); else LAPACK.getInstance().dpocon(UpLo.Lower.netlib(), n, Cl.getData(), Matrices.ld(n), anorm, rcond, work, iwork, info); if (info.val < 0) throw new IllegalArgumentException(); return rcond.val; }
/** * Solves for <code>B</code>, overwriting it on return */ public DenseMatrix solve(DenseMatrix B) throws MatrixNotSPDException { if (notspd) throw new MatrixNotSPDException(); if (n != B.numRows()) throw new IllegalArgumentException("n != B.numRows()"); intW info = new intW(0); if (upper) LAPACK.getInstance().dpotrs(UpLo.Upper.netlib(), Cu.numRows(), B.numColumns(), Cu.getData(), Matrices.ld(Cu.numRows()), B.getData(), Matrices.ld(Cu.numRows()), info); else LAPACK.getInstance().dpotrs(UpLo.Lower.netlib(), Cl.numRows(), B.numColumns(), Cl.getData(), Matrices.ld(Cl.numRows()), B.getData(), Matrices.ld(Cl.numRows()), info); if (info.val < 0) throw new IllegalArgumentException(); return B; }
/** * Solves for <code>B</code>, overwriting it on return */ public DenseMatrix solve(DenseMatrix B) throws MatrixNotSPDException { if (notspd) throw new MatrixNotSPDException(); if (n != B.numRows()) throw new IllegalArgumentException("n != B.numRows()"); intW info = new intW(0); if (upper) LAPACK.getInstance().dpotrs(UpLo.Upper.netlib(), Cu.numRows(), B.numColumns(), Cu.getData(), Matrices.ld(Cu.numRows()), B.getData(), Matrices.ld(Cu.numRows()), info); else LAPACK.getInstance().dpotrs(UpLo.Lower.netlib(), Cl.numRows(), B.numColumns(), Cl.getData(), Matrices.ld(Cl.numRows()), B.getData(), Matrices.ld(Cl.numRows()), info); if (info.val < 0) throw new IllegalArgumentException(); return B; }