LUDecomposition implements AutoCloseable { public Matrix getU() { if ((cachedU == null) && !singular) { final int m = pivot.size(); cachedU = like(matrix); cachedU.assign(0.0); for (int i = 0; i < m; ++i) for (int j = i; j < m; ++j) cachedU.setX(i, j, lu.getX(i, j)); } return cachedU; } 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 getU() throws Exception { Matrix luDecompositionU = new LUDecomposition(testMatrix).getU(); assertEquals("Unexpected row size.", testU.rowSize(), luDecompositionU.rowSize()); assertEquals("Unexpected column size.", testU.columnSize(), luDecompositionU.columnSize()); for (int i = 0; i < testU.rowSize(); i++) for (int j = 0; j < testU.columnSize(); j++) assertEquals("Unexpected value at (" + i + "," + j + ").", testU.getX(i, j), luDecompositionU.getX(i, j), 0.0000001d); luDecompositionU.destroy(); }