@Test
public void testInverseAndSolve() {
double[][] dataA = {{1,2,4},
{2,13,23},
{4,23,90}};
Matrix A = Matrix.create(dataA);
double[][] dataB = {{17},{97},{320}};
Matrix b = Matrix.create(dataB);
// Matrix x = Matrix.createRandom(3, 1);
Matrix x;
CholeskyLDUSolver solver = new CholeskyLDUSolver();
assertTrue(solver.setA(A));
Matrix A_inv_result = solver.invert().toMatrix();
x = solver.solve(b).toMatrix();
double[][] data_A_inv_expected = {{1.453515, -0.199546, -0.013605},
{-0.199546, 0.167800, -0.034014},
{-0.013605, -0.034014, 0.020408}};
Matrix A_inv_expected = Matrix.create(data_A_inv_expected);
double[][] data_x_expected = {{1},{2},{3}};
Matrix x_expected = Matrix.create(data_x_expected);
assertArrayEquals(A_inv_expected.getElements(),A_inv_result.getElements(),1e-5);
assertArrayEquals(x_expected.getElements(),x.getElements(),1e-5);
}