InverseJacobianEstimateInitializationFunction implements NewtonRootFinderMatrixInitializationFunction { @Override public DoubleMatrix2D getInitializedMatrix(final Function1D<DoubleMatrix1D, DoubleMatrix2D> jacobianFunction, final DoubleMatrix1D x) { Validate.notNull(jacobianFunction); Validate.notNull(x); final DoubleMatrix2D estimate = jacobianFunction.evaluate(x); final DecompositionResult decompositionResult = _decomposition.evaluate(estimate); return decompositionResult.solve(DoubleMatrixUtils.getIdentityMatrix2D(x.getNumberOfElements())); } InverseJacobianEstimateInitializationFunction(final Decomposition<?> decomposition); @Override DoubleMatrix2D getInitializedMatrix(final Function1D<DoubleMatrix1D, DoubleMatrix2D> jacobianFunction, final DoubleMatrix1D x);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullFunction() { ESTIMATE.getInitializedMatrix(null, X); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullVector() { ESTIMATE.getInitializedMatrix(J, null); }
@Test public void test() { DoubleMatrix2D m1 = ESTIMATE.getInitializedMatrix(J, X); DoubleMatrix2D m2 = J.evaluate(X); DoubleMatrix2D m3 = (DoubleMatrix2D) (ALGEBRA.multiply(m1, m2)); DoubleMatrix2D identity = DoubleMatrixUtils.getIdentityMatrix2D(2); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { assertEquals(m3.getEntry(i, j), identity.getEntry(i, j), 1e-6); } } }