@CodeReview(reviewer="Kevin R. Dixon", date="2009-07-06", changesNeeded=false, comments={"Fixed bug introduced into the numerical differentiation procedure.","Made clone() call super.clone().","Fixed the brittleness in the copy constructor."}) public class DirectionalVectorToScalarFunction extends AbstractDifferentiableUnivariateScalarFunction
Modifier and Type | Field and Description |
---|---|
static double |
FORWARD_DIFFERENCE
Value used in the forward-difference derivative approximation
|
Constructor and Description |
---|
DirectionalVectorToScalarFunction(DirectionalVectorToScalarFunction other)
Copy constructor
|
DirectionalVectorToScalarFunction(Evaluator<? super Vector,? extends java.lang.Double> vectorScalarFunction,
Vector vectorOffset,
Vector direction)
Creates a new function that restricts the vectorFunction to a
particular vector direction
|
Modifier and Type | Method and Description |
---|---|
DirectionalVectorToScalarFunction |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
Vector |
computeVector(double scaleFactor)
Transforms the scaleFactor into a multidimensional Vector using the
direction
|
double |
differentiate(double input)
Differentiates the output of the function about the given input
|
double |
evaluate(double input)
Evaluates the vector function along the direction using the scale
factor "input" and vectorOffset
|
Vector |
getDirection()
Getter for direction
|
Vector |
getVectorOffset()
Getter for vectorOffset
|
Evaluator<? super Vector,? extends java.lang.Double> |
getVectorScalarFunction()
Getter for vectorScalarFunction
|
void |
setDirection(Vector direction)
Setter for direction
|
void |
setVectorOffset(Vector vectorOffset)
Point to use as input to vectorFunction
|
void |
setVectorScalarFunction(Evaluator<? super Vector,? extends java.lang.Double> vectorScalarFunction)
Setter for vectorScalarFunction
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
differentiate
evaluate, evaluateAsDouble
public static final double FORWARD_DIFFERENCE
public DirectionalVectorToScalarFunction(Evaluator<? super Vector,? extends java.lang.Double> vectorScalarFunction, Vector vectorOffset, Vector direction)
vectorScalarFunction
- Function that maps a Vector onto a DoublevectorOffset
- offset vector from which to scale along
direction to evaluate vectorFunctiondirection
- Direction to optimize alongpublic DirectionalVectorToScalarFunction(DirectionalVectorToScalarFunction other)
other
- DirectionalVectorToScalarFunction to copypublic DirectionalVectorToScalarFunction clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class AbstractCloneableSerializable
public Vector getDirection()
public void setDirection(Vector direction)
direction
- Direction to optimize alongpublic Vector getVectorOffset()
public void setVectorOffset(Vector vectorOffset)
vectorOffset
- Point to use as input to vectorFunctionpublic Vector computeVector(double scaleFactor)
scaleFactor
- scale factor to move along the direction from
vectorOffsetpublic Evaluator<? super Vector,? extends java.lang.Double> getVectorScalarFunction()
public void setVectorScalarFunction(Evaluator<? super Vector,? extends java.lang.Double> vectorScalarFunction)
vectorScalarFunction
- Function that maps a Vector onto a Doublepublic double evaluate(double input)
input
- scale factor to move along direction from
vectorOffsetpublic double differentiate(double input)
DifferentiableUnivariateScalarFunction
input
- Input about which to compute the derivative of the function output