MCPcopy Index your code
hub / github.com/WinVector/Logistic / testGradAndHessian

Method testGradAndHessian

test/com/winvector/logistic/TestOpt.java:48–64  ·  view source on GitHub ↗
(final VectorFn f, final double[] x, final double epsilon, final double tol)

Source from the content-addressed store, hash-verified

46 }
47
48 public static void testGradAndHessian(final VectorFn f, final double[] x, final double epsilon, final double tol) {
49 final VEval fx = f.eval(x,true,true);
50 //System.out.println("fx: " + fx);
51 final VEval fn = numericlyBuildGradientAndHessian(f,x,epsilon);
52 //System.out.println("fn: " + fn);
53 final int dim = f.dim();
54 for(int i=0;i<dim;++i) {
55 if(Math.abs(fx.gx[i]-fn.gx[i])>=tol) { //extra if lets us set a breakpoint
56 assertTrue(Math.abs(fx.gx[i]-fn.gx[i])<tol);
57 }
58 for(int j=0;j<dim;++j) {
59 if(Math.abs(fx.hx[i][j]-fn.hx[i][j])>=tol) { //extra if lets us set a breakpoint
60 assertTrue(Math.abs(fx.hx[i][j]-fn.hx[i][j])<tol);
61 }
62 }
63 }
64 }
65
66
67 public void testNormV() {

Callers 7

testMHMethod · 0.95
testMHRMethod · 0.95
testNormGHMethod · 0.95
testGHMethod · 0.95
testGHRMethod · 0.95
testGH2Method · 0.95
testGHR2Method · 0.95

Calls 3

evalMethod · 0.65
dimMethod · 0.65

Tested by

no test coverage detected