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"); } }
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"); } }