|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnr.ScalarFunction
public abstract class ScalarFunction
A functionoid designed to implement a scalar function of a vector
Constructor Summary | |
---|---|
ScalarFunction()
|
Method Summary | |
---|---|
abstract double |
eval(Vec x)
a scalar function of a vector. |
Vec |
grad(Vec x)
Calculates the gradient for this function. |
Vec |
grad(Vec x,
Vec g)
Calculates the gradient for this function. |
double |
gradCost()
The computational cost of evaluating the gradient. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ScalarFunction()
Method Detail |
---|
public abstract double eval(Vec x)
x
- the independent variable
public double gradCost()
grad(nr.Vec, nr.Vec)
to eval(nr.Vec)
. For the most
part this can be ignored.
This will usually depend on the size of the input vector, so is
unknowable to a generic implementation, so the default implementation
throws an Error. If it is needed, it must be implemented (how to get the
necessary information is up to you).
For the default gradient, gradCost = 2*x.size() (grad calls eval twice for every element of the input vector)
public Vec grad(Vec x, Vec g)
x
- the independent variableg
- the the gradient of eval. If grad == null, a new Vec
will be created
public Vec grad(Vec x)
(Vec, Vec)
with
g == null. The default implementation does just that.
x
- the independent variable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |