LUDecomposition implements AutoCloseable { public double determinant() { if (singular) return 0; final int m = pivot.size(); double determinant = even ? 1 : -1; for (int i = 0; i < m; i++) determinant *= lu.getX(i, i); return determinant; } LUDecomposition(Matrix matrix);  LUDecomposition(Matrix matrix, double singularityThreshold); @Override void close(); Matrix getL(); Matrix getU(); Matrix getP(); Vector getPivot(); double determinant(); Vector solve(Vector b); Matrix solve(Matrix b);  }
@Test public void singularDeterminant() throws Exception { assertEquals("Unexpected determinant for singular matrix decomposition.", 0d, new LUDecomposition(new DenseMatrix(2, 2)).determinant(), 0d); }