JacobianFunction implements MultivariateMatrixFunction { public double[][] value(double[] point) { final DerivativeStructure[] dsX = new DerivativeStructure[point.length]; for (int i = 0; i < point.length; ++i) { dsX[i] = new DerivativeStructure(point.length, 1, i, point[i]); } final DerivativeStructure[] dsY = f.value(dsX); final double[][] y = new double[dsY.length][point.length]; final int[] orders = new int[point.length]; for (int i = 0; i < dsY.length; ++i) { for (int j = 0; j < point.length; ++j) { orders[j] = 1; y[i][j] = dsY[i].getPartialDerivative(orders); orders[j] = 0; } } return y; } JacobianFunction(final MultivariateDifferentiableVectorFunction f); double[][] value(double[] point);  }
@Test public void testSphere() { SphereMapping f = new SphereMapping(10.0); JacobianFunction j = new JacobianFunction(f); for (double latitude = -1.5; latitude < 1.5; latitude += 0.1) { for (double longitude = -3.1; longitude < 3.1; longitude += 0.1) { double[] point = new double[] { latitude, longitude }; double[][] referenceJacobian = f.jacobian(point); double[][] testJacobian = j.value(point); Assert.assertEquals(referenceJacobian.length, testJacobian.length); for (int i = 0; i < 3; ++i) { TestUtils.assertEquals(referenceJacobian[i], testJacobian[i], 2.0e-15); } } } }