/** * Constructs and returns a new LU Decomposition object; The decomposed * matrices can be retrieved via instance methods of the returned * decomposition object. * * @param A * Rectangular matrix */ public DenseDoubleLUDecomposition(DoubleMatrix2D A) { quick = new DenseDoubleLUDecompositionQuick(0); // zero tolerance for // compatibility with Jama quick.decompose(A.copy()); }
/** * Constructs and returns a new LU Decomposition object; The decomposed * matrices can be retrieved via instance methods of the returned * decomposition object. * * @param A * Rectangular matrix */ public DenseDoubleLUDecomposition(DoubleMatrix2D A) { quick = new DenseDoubleLUDecompositionQuick(0); // zero tolerance for // compatibility with Jama quick.decompose(A.copy()); }
@Override public long process(BenchmarkMatrix[] inputs, BenchmarkMatrix[] outputs, long numTrials) { DoubleMatrix2D matA = inputs[0].getOriginal(); // the recommended way I think would be using Algebra, but this might allow // reuse of data DenseDoubleLUDecompositionQuick decomp = new DenseDoubleLUDecompositionQuick(); DoubleMatrix2D tmp = createMatrix(matA.rows(),matA.columns()); DoubleMatrix2D L = null; DoubleMatrix2D U = null; int[] pivot = null; long prev = System.nanoTime(); for( long i = 0; i < numTrials; i++ ) { // input matrix is overwritten tmp.assign(matA); decomp.decompose(tmp); if( !decomp.isNonsingular() ) throw new DetectedException("LU decomposition failed"); L = decomp.getL(); U = decomp.getU(); pivot = decomp.getPivot(); } long elapsedTime = System.nanoTime()-prev; if( outputs != null ) { outputs[0] = new PColtBenchmarkMatrix(L); outputs[1] = new PColtBenchmarkMatrix(U); outputs[2] = new RowMajorBenchmarkMatrix(RowMajorOps.pivotMatrix(null, pivot, pivot.length, false)); } return elapsedTime; } }
decompose(A); return;