/** * Returns whether the matrix is nonsingular (has an inverse). * * @return true if <tt>U</tt>, and hence <tt>A</tt>, is nonsingular; false * otherwise. */ public boolean isNonsingular() { return quick.isNonsingular(); }
/** * Sets the combined lower and upper triangular factor, <tt>LU</tt>. The * parameter is not checked; make sure it is indeed a proper LU * decomposition. */ public void setLU(DoubleMatrix2D LU) { this.LU = LU; this.isNonSingular = isNonsingular(LU); }
/** * Sets the combined lower and upper triangular factor, <tt>LU</tt>. The * parameter is not checked; make sure it is indeed a proper LU * decomposition. */ public void setLU(DoubleMatrix2D LU) { this.LU = LU; this.isNonSingular = isNonsingular(LU); }
/** * Returns whether the matrix is nonsingular (has an inverse). * * @return true if <tt>U</tt>, and hence <tt>A</tt>, is nonsingular; false * otherwise. */ public boolean isNonsingular() { return quick.isNonsingular(); }
buf.append(String.valueOf(this.isNonsingular())); } catch (IllegalArgumentException exc) { buf.append(unknown + exc.getMessage());
buf.append(String.valueOf(this.isNonsingular())); } catch (IllegalArgumentException exc) { buf.append(unknown + exc.getMessage());
/** * Returns the determinant, <tt>det(A)</tt>. * * @exception IllegalArgumentException * if <tt>A.rows() != A.columns()</tt> (Matrix must be * square). */ public double det() { int m = m(); int n = n(); if (m != n) throw new IllegalArgumentException("Matrix must be square."); if (!isNonsingular()) return 0; // avoid rounding errors double det = pivsign; for (int j = 0; j < n; j++) { det *= LU.getQuick(j, j); } return det; }
/** * Returns the determinant, <tt>det(A)</tt>. * * @exception IllegalArgumentException * if <tt>A.rows() != A.columns()</tt> (Matrix must be * square). */ public double det() { int m = m(); int n = n(); if (m != n) throw new IllegalArgumentException("Matrix must be square."); if (!isNonsingular()) return 0; // avoid rounding errors double det = pivsign; for (int j = 0; j < n; j++) { det *= LU.getQuick(j, j); } return det; }
@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; } }
if (B.size() != m) throw new IllegalArgumentException("Matrix dimensions must agree."); if (!this.isNonsingular()) throw new IllegalArgumentException("Matrix is singular.");
if (B.size() != m) throw new IllegalArgumentException("Matrix dimensions must agree."); if (!this.isNonsingular()) throw new IllegalArgumentException("Matrix is singular.");
if (B.rows() != m) throw new IllegalArgumentException("Matrix row dimensions must agree."); if (!this.isNonsingular()) throw new IllegalArgumentException("Matrix is singular.");
if (B.rows() != m) throw new IllegalArgumentException("Matrix row dimensions must agree."); if (!this.isNonsingular()) throw new IllegalArgumentException("Matrix is singular.");
if (B.rows() != m) throw new IllegalArgumentException("Matrix row dimensions must agree."); if (!this.isNonsingular()) throw new IllegalArgumentException("Matrix is singular.");
if (B.rows() != m) throw new IllegalArgumentException("Matrix row dimensions must agree."); if (!this.isNonsingular()) throw new IllegalArgumentException("Matrix is singular.");