MCPcopy Create free account
hub / github.com/WinVector/Logistic / eval

Method eval

src/com/winvector/opt/impl/NormPenalty.java:62–80  ·  view source on GitHub ↗
(final double[] x, final boolean wantGrad, final boolean wantHessian)

Source from the content-addressed store, hash-verified

60 }
61
62 @Override
63 public VEval eval(final double[] x, final boolean wantGrad, final boolean wantHessian) {
64 final VEval r = new VEval(x,wantGrad,wantHessian);
65 if(regularizeTerm>0.0) {
66 for(int i=0;i<dim;++i) {
67 if((skip==null)||(!skip.get(i))) {
68 final double xi = x[i];
69 r.fx += -regularizeTerm*xi*xi;
70 if(wantGrad) {
71 r.gx[i] = -2.0*regularizeTerm*xi;
72 }
73 if(wantHessian) {
74 r.hx[i][i] = -2.0*regularizeTerm;
75 }
76 }
77 }
78 }
79 return r;
80 }
81
82 /**
83 *

Callers 2

testNormVMethod · 0.95
testNormV2Method · 0.95

Calls 1

getMethod · 0.45

Tested by 2

testNormVMethod · 0.76
testNormV2Method · 0.76