Search in sources :

Example 1 with GradientFunction

use of uk.ac.sussex.gdsc.smlm.function.GradientFunction in project GDSC-SMLM by aherbert.

the class SteppingFunctionSolver method computeValue.

@Override
protected boolean computeValue(double[] y, double[] fx, double[] a) {
    // If the fx array is not null then wrap the gradient function.
    // Compute the value and the wrapper will store the values appropriately.
    // Then reset the gradient function.
    // Note: If a sub class wraps the function with weights
    // then the weights will not be stored in the function value.
    // Only the value produced by the original function is stored:
    // Wrapped (+weights) < FunctionStore < Function
    // However if the base function is already wrapped then this will occur:
    // Wrapped (+weights) < FunctionStore < Wrapped (+precomputed) < Function
    gradientIndices = function.gradientIndices();
    if (fx != null && fx.length == ((Gradient1Function) function).size()) {
        final GradientFunction tmp = function;
        function = new Gradient1FunctionStore((Gradient1Function) function, fx, null);
        lastY = prepareFunctionValue(y, a);
        value = computeFunctionValue(a);
        function = tmp;
    } else {
        lastY = prepareFunctionValue(y, a);
        value = computeFunctionValue(a);
    }
    return true;
}
Also used : Gradient1FunctionStore(uk.ac.sussex.gdsc.smlm.function.Gradient1FunctionStore) Gradient1Function(uk.ac.sussex.gdsc.smlm.function.Gradient1Function) GradientFunction(uk.ac.sussex.gdsc.smlm.function.GradientFunction)

Aggregations

Gradient1Function (uk.ac.sussex.gdsc.smlm.function.Gradient1Function)1 Gradient1FunctionStore (uk.ac.sussex.gdsc.smlm.function.Gradient1FunctionStore)1 GradientFunction (uk.ac.sussex.gdsc.smlm.function.GradientFunction)1