/** * Constructs and returns the LU-decomposition of the given matrix. */ public DenseDoubleLUDecomposition lu(DoubleMatrix2D matrix) { return new DenseDoubleLUDecomposition(matrix); }
/** * Returns the determinant of matrix <tt>A</tt>. * * @return the determinant. */ public double det(DoubleMatrix2D A) { return lu(A).det(); }
public Matrix[] lu() { if (getRowCount() >= getColumnCount()) { DenseDoubleLUDecomposition lu = new DenseDoubleLUDecomposition(matrix); Matrix l = new ParallelColtDenseDoubleMatrix2D(lu.getL()); Matrix u = new ParallelColtDenseDoubleMatrix2D(lu.getU().viewPart(0, 0, (int) getColumnCount(), (int) getColumnCount())); int m = (int) getRowCount(); int[] piv = lu.getPivot(); Matrix p = new ParallelColtDenseDoubleMatrix2D(m, m); for (int i = 0; i < m; i++) { p.setAsDouble(1, i, piv[i]); } return new Matrix[] { l, u, p }; } else { throw new RuntimeException("only supported for matrices m>=n"); } }
lu = new DenseDoubleLUDecomposition(matrix); } catch (IllegalArgumentException exc) { buf.append("\n\n" + constructionException + " LUDecomposition: " + exc.getMessage()); buf.append("\n\n" + lu.toString());
/** * Solves A*x = b. * * @return x; a new independent matrix; solution if A is square, least * squares solution otherwise. */ public DoubleMatrix1D solve(DoubleMatrix2D A, DoubleMatrix1D b) { if (A.rows() == A.columns()) { return lu(A).solve(b); } else { DoubleMatrix1D x = b.copy(); qr(A).solve(x); return x.viewPart(0, A.columns()).copy(); } }
public Matrix[] lu() { if (getRowCount() >= getColumnCount()) { DenseDoubleLUDecomposition lu = new DenseDoubleLUDecomposition(matrix); Matrix l = new ParallelColtDenseDoubleMatrix2D(lu.getL()); Matrix u = new ParallelColtDenseDoubleMatrix2D(lu.getU().viewPart(0, 0, (int) getColumnCount(), (int) getColumnCount())); int m = (int) getRowCount(); int[] piv = lu.getPivot(); Matrix p = new ParallelColtDenseDoubleMatrix2D(m, m); for (int i = 0; i < m; i++) { p.setAsDouble(1, i, piv[i]); } return new Matrix[] { l, u, p }; } else { throw new RuntimeException("only supported for matrices m>=n"); } }
lu = new DenseDoubleLUDecomposition(matrix); } catch (IllegalArgumentException exc) { buf.append("\n\n" + constructionException + " LUDecomposition: " + exc.getMessage()); buf.append("\n\n" + lu.toString());
/** * Solves A*x = b. * * @return x; a new independent matrix; solution if A is square, least * squares solution otherwise. */ public DoubleMatrix1D solve(DoubleMatrix2D A, DoubleMatrix1D b) { if (A.rows() == A.columns()) { return lu(A).solve(b); } else { DoubleMatrix1D x = b.copy(); qr(A).solve(x); return x.viewPart(0, A.columns()).copy(); } }
/** * Constructs and returns the LU-decomposition of the given matrix. */ public DenseDoubleLUDecomposition lu(DoubleMatrix2D matrix) { return new DenseDoubleLUDecomposition(matrix); }
/** * Solves A*X = B. * * @return X; a new independent matrix; solution if A is square, least * squares solution otherwise. */ public DoubleMatrix2D solve(DoubleMatrix2D A, DoubleMatrix2D B) { if (A.rows() == A.columns()) { return lu(A).solve(B); } else { DoubleMatrix2D X = B.copy(); qr(A).solve(X); return X.viewPart(0, 0, A.columns(), B.columns()).copy(); } }
/** * Returns the determinant of matrix <tt>A</tt>. * * @return the determinant. */ public double det(DoubleMatrix2D A) { return lu(A).det(); }
/** * Solves A*X = B. * * @return X; a new independent matrix; solution if A is square, least * squares solution otherwise. */ public DoubleMatrix2D solve(DoubleMatrix2D A, DoubleMatrix2D B) { if (A.rows() == A.columns()) { return lu(A).solve(B); } else { DoubleMatrix2D X = B.copy(); qr(A).solve(X); return X.viewPart(0, 0, A.columns(), B.columns()).copy(); } }