edu.stanford.nlp.optimization
Class AbstractCachingDiffFunction

java.lang.Object
  extended by edu.stanford.nlp.optimization.AbstractCachingDiffFunction
All Implemented Interfaces:
DiffFunction, Function, HasInitial
Direct Known Subclasses:
AbstractStochasticCachingDiffFunction

public abstract class AbstractCachingDiffFunction
extends Object
implements DiffFunction, HasInitial

Author:
Dan Klein

Field Summary
protected  double[] derivative
           
protected  double value
           
 
Constructor Summary
AbstractCachingDiffFunction()
           
 
Method Summary
protected abstract  void calculate(double[] x)
          Calculate the value at x and the derivative and save them in the respective fields
protected  void clearCache()
          Clears the cache in a way that doesn't require reallocation :-)
protected  void copy(double[] y, double[] x)
           
 double[] derivativeAt(double[] x)
          Returns the first-derivative vector at the input location.
abstract  int domainDimension()
          Returns the number of dimensions in the function's domain
 double[] initial()
          Returns the intitial point in the domain (but not necessarily a feasible one).
 double lastValue()
           
 void setValue(double v)
           
 double valueAt(double[] x)
          Returns the value of the function at a single point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

derivative

protected double[] derivative

value

protected double value
Constructor Detail

AbstractCachingDiffFunction

public AbstractCachingDiffFunction()
Method Detail

domainDimension

public abstract int domainDimension()
Description copied from interface: Function
Returns the number of dimensions in the function's domain

Specified by:
domainDimension in interface Function
Returns:
the number of domain dimensions

calculate

protected abstract void calculate(double[] x)
Calculate the value at x and the derivative and save them in the respective fields

Parameters:
x -

clearCache

protected void clearCache()
Clears the cache in a way that doesn't require reallocation :-)


initial

public double[] initial()
Description copied from interface: HasInitial
Returns the intitial point in the domain (but not necessarily a feasible one).

Specified by:
initial in interface HasInitial
Returns:
a domain point

copy

protected void copy(double[] y,
                    double[] x)

valueAt

public double valueAt(double[] x)
Description copied from interface: Function
Returns the value of the function at a single point.

Specified by:
valueAt in interface Function
Parameters:
x - a double[] input
Returns:
the function value at the input

derivativeAt

public double[] derivativeAt(double[] x)
Description copied from interface: DiffFunction
Returns the first-derivative vector at the input location.

Specified by:
derivativeAt in interface DiffFunction
Parameters:
x - a double[] input vector
Returns:
the vector of first partial derivatives.

lastValue

public double lastValue()

setValue

public void setValue(double v)


Stanford NLP Group