view src/samer/units/SumFnVec.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
children
line wrap: on
line source
package	samer.units;
import	samer.core.types.*;
import	samer.tools.*;
import	samer.maths.*;

public class SumFnVec extends FunctionOfVector implements SafeTask
{
	double []		x, fx;
	DoubleModel	out;
	Function		f;
	
	public SumFnVec(Function f, VVector x, DoubleModel out) {
		this.x=x.array();
		this.f=f;
		this.out=out;
		fx=new double[x.size()];
	}

	public void starting() {}
	public void stopping() {}
	public void run() {
		f.apply(x,fx);
		out.set(Mathx.sum(fx));
	}

	public double apply(double [] x) {
		f.apply(x,fx); return Mathx.sum(fx);
	}
}