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

Class SumFn

src/com/winvector/opt/impl/SumFn.java:13–37  ·  view source on GitHub ↗

Class for slow loosely coupled summation of VectorFns. designed usage: summing two unrelated functions (like data score and regularization penalty) @author johnmount

Source from the content-addressed store, hash-verified

11 *
12 */
13public class SumFn implements VectorFn {
14 private final Iterable<VectorFn> underlying;
15 private final int dim;
16
17 public SumFn(final Iterable<VectorFn> underlying) {
18 this.underlying = underlying;
19 dim = underlying.iterator().next().dim();
20 }
21
22 @Override
23 public int dim() {
24 return dim;
25 }
26
27 @Override
28 public VEval eval(final double[] x, final boolean wantGrad, final boolean wantHessian) {
29 final VEval r = new VEval(x,wantGrad,wantHessian);
30 for(final VectorFn fi: underlying) {
31 final VEval vi = fi.eval(x,wantGrad,wantHessian);
32 r.add(vi);
33 }
34 return r;
35 }
36
37}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected