IGLib  1.5
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
IG.Num.ScalarFunctionUntransformedBase Class Referenceabstract

Base class for defining scalar functions without possibility of affine transformation of parameters. More...

+ Inheritance diagram for IG.Num.ScalarFunctionUntransformedBase:
+ Collaboration diagram for IG.Num.ScalarFunctionUntransformedBase:

Public Member Functions

virtual void Evaluate (IScalarFunctionResults data)
 Evaluates whatever needs to be evaluated and stores the results on the specified storage object. More...
 
abstract double Value (IVector parameters)
 Returns the value of this function at the specified parameter. More...
 
abstract void GradientPlain (IVector parameters, IVector gradient)
 Calculates first order derivatives (gradient) of this function at the specified parameters. WARNING: Plain function, does not check consistency of arguments. More...
 
virtual void Gradient (IVector parameters, ref IVector gradient)
 Calculates first order derivatives (gradient) of this function at the specified parameters. More...
 
abstract void HessianPlain (IVector parameters, IMatrix hessian)
 Calculates the second derivative (Hessian matrix) of this function at the specified parameters. WARNING: Plain function, does not check consistency of arguments. More...
 
virtual void Hessian (IVector parameters, ref IMatrix hessian)
 Calculates the second derivative (Hessian matrix) of this function at the specified parameters. More...
 
virtual void NumericalGradientForwardPlain (IVector x, IVector stepSizes, IVector gradient)
 Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used. More...
 
void NumericalGradientForward (IVector x, IVector stepSizes, ref IVector gradient)
 Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used. More...
 
void NumericalGradientForward (IVector x, double stepSize, ref IVector gradient)
 Calculates numerical derivatives (gradient) of this function. Forward difference formula is used. More...
 
virtual void NumericalGradientCentralPlain (IVector x, IVector stepSizes, IVector gradient)
 Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used. More...
 
void NumericalGradientCentral (IVector x, IVector stepSizes, ref IVector gradient)
 Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used. More...
 
void NumericalGradientCentral (IVector x, double stepSize, ref IVector gradient)
 Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used. More...
 
virtual void NumericalHessianForwardPlain (IVector x, IVector stepSizes, IVector aux, IMatrix hessian)
 Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. WARNING: Dimensions of vector arguments must match. This function does not check for consistency of argument dimensions. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown). More...
 
virtual void NumericalHessianForward (IVector x, IVector stepSizes, ref IVector aux, ref IMatrix hessian)
 Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown). More...
 
virtual void NumericalHessianForward (IVector x, double stepSize, ref IVector aux, ref IMatrix hessian)
 Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown). More...
 
virtual void NumericalHessianCentralPlain (IVector x, IVector stepSizes, IVector aux1, IVector aux2, IMatrix hessian)
 Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. WARNING: Dimensions of vector arguments must match. This function does not check for consistency of argument dimensions. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown). More...
 
virtual void NumericalHessianCentral (IVector x, IVector stepSizes, ref IVector aux1, ref IVector aux2, ref IMatrix hessian)
 Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown). More...
 
virtual void NumericalHessianCentral (IVector x, double stepSize, ref IVector aux1, ref IVector aux2, ref IMatrix hessian)
 Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown). More...
 
virtual void NumericalHessianCentralPlain (IVector x, IVector stepSizes, IVector aux1, IVector aux2, IMatrix hessian, bool useAnalyticalGradient)
 Calculates numerical second derivatives (Hessian) of this function by the central difference formula. WARNING: Dimensions of vector arguments must match. This function does not check for consistency of argument dimensions. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown). More...
 
virtual void NumericalHessianCentral (IVector x, IVector stepSizes, ref IVector aux1, ref IVector aux2, ref IMatrix hessian, bool useAnalyticalGradient)
 Calculates numerical second derivatives (Hessian) of this function by the central difference formula. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown). More...
 
virtual void NumericalHessianCentral (IVector x, double stepSize, ref IVector aux1, ref IVector aux2, ref IMatrix hessian, bool useAnalyticalGradient)
 Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown). More...
 
void TestSpeed (IVector parameters, int numEvaluations, bool randomPerturbations, double relativePerturbationSize, bool calcValue, bool calcGradient, bool calcHessian, bool writeLastResult)
 Tests speed of evaluation of the current scalar function and writes results to the console. More...
 
void TestGradient (IVector parameters, IVector stepSizes, int stepReductionFactor, int numStepReductions, bool checkNumerical, bool writeErrorComponents, bool writeGradientComponents)
 Tests the calculation of gradients of the current scalar function. More...
 
void TestGradient (IVector parameters, IVector stepSizes, int stepReductionFactor, int numStepReductions, bool checkNumerical, bool writeErrorComponents, bool writeGradientComponents, bool useCentralDifference)
 Tests the calculation of gradients of the current scalar function. More...
 
void TestHessian (IVector parameters, IVector stepSizes, int stepReductionFactor, int numStepReductions, bool checkNumerical, bool writeErrorComponents, bool writeHessianComponents)
 Tests the calculation of Hessians of the current scalar function. More...
 
void TestHessian (IVector parameters, IVector stepSizes, int stepReductionFactor, int numStepReductions, bool checkNumerical, bool writeErrorComponents, bool writeHessianComponents, bool useCentralDifference)
 Tests the calculation of Hessians of the current scalar function. More...
 
void Test (IVector from, IVector to, int numProbes, IVector stepSizes, double tolerance, bool testDerivatives, bool testSecondDerivatives, bool printDifferences, bool printResults)
 Performs numerical tests on the function, with output written to the console. Derivatives and second derivatives are tested and compared to numerical derivatives. More...
 
void Test (IVector from, IVector to, int numProbes, IVector stepSizes, double tolerance)
 Performs numerical tests on the function, with output written to the console. Derivatives and second derivatives are tested and compared to numerical derivatives. This method tests first and second order derivatives, prints differences between analytical and numerical values to the console, and prints reports where absolute differences exceed rolerance. More...
 
void Test (IVector from, IVector to, int numProbes, double stepSize, double tolerance, bool testDerivatives, bool testSecondDerivatives, bool printDifferences, bool printResults)
 Performs numerical tests on the function, with output written to the console. Derivatives and second derivatives are tested and compared to numerical derivatives. More...
 
void Test (IVector from, IVector to, int numProbes, double stepSize, double tolerance)
 Performs numerical tests on the function, with output written to the console. Derivatives and second derivatives are tested and compared to numerical derivatives. More...
 

Protected Attributes

string _name
 
string _description
 

Properties

virtual string Name [get, set]
 Returns a short name of thecurrent function. More...
 
virtual string Description [get, set]
 Returns a short description of the current function. More...
 
abstract bool ValueDefined [get, protected set]
 Tells whether value of the function is defined by implementation. More...
 
abstract bool GradientDefined [get, protected set]
 Tells whether the first derivative is defined for this function (by implementation, not mathematically) More...
 
abstract bool HessianDefined [get, protected set]
 Tells whether the second derivative is defined for this function (by implementation, not mathematically) More...
 
- Properties inherited from IG.Num.IScalarFunctionUntransformed
string Name [get]
 Returns a short name of the function. More...
 
string Description [get]
 Returns a short description of the function. More...
 
bool ValueDefined [get]
 Tells whether value of the function is defined by implementation. More...
 
bool GradientDefined [get]
 Tells whether the first derivative is defined for this function (by implementation, not mathematically) More...
 
bool HessianDefined [get]
 Tells whether the second derivative is defined for this function (by implementation, not mathematically) More...
 

Detailed Description

Base class for defining scalar functions without possibility of affine transformation of parameters.

More or less all scalar functions should derive from this class.

$A Igor xx May10 Dec10; TODO: implement ICloneable

Member Function Documentation

abstract double IG.Num.ScalarFunctionUntransformedBase.Value ( IVector  parameters)
pure virtual
abstract void IG.Num.ScalarFunctionUntransformedBase.GradientPlain ( IVector  parameters,
IVector  gradient 
)
pure virtual

Calculates first order derivatives (gradient) of this function at the specified parameters. WARNING: Plain function, does not check consistency of arguments.

Parameters
parametersVector of parameters where derivatives are evaluated.
gradientVector where first order derivatives (the gradient) are stored.

Implements IG.Num.IScalarFunctionUntransformed.

Implemented in IG.Num.ScalarFunctionQuadratic, IG.Num.Func3dBase, IG.Num.ScalarFunctionLinear, IG.Num.Func2dBase, IG.Num.ScalarFunctionRadialUntransformed, IG.Num.ScalarFunctionBase, and IG.Num.ScalarFunctionConstant.

virtual void IG.Num.ScalarFunctionUntransformedBase.Gradient ( IVector  parameters,
ref IVector  gradient 
)
inlinevirtual

Calculates first order derivatives (gradient) of this function at the specified parameters.

Parameters
parametersVector of parameters where derivatives are evaluated.
gradientVector where first order derivatives (gradient) are stored. Passed by reference.

Implements IG.Num.IScalarFunctionUntransformed.

References IG.Num.IVector.GetNew().

Referenced by IG.Lib.ScalarFunctionLoader.Example().

abstract void IG.Num.ScalarFunctionUntransformedBase.HessianPlain ( IVector  parameters,
IMatrix  hessian 
)
pure virtual

Calculates the second derivative (Hessian matrix) of this function at the specified parameters. WARNING: Plain function, does not check consistency of arguments.

Parameters
parametersVector of parameters where derivatives are evaluated.
hessianMatrix where second derivatives (Hessian matrix) are stored.

Implements IG.Num.IScalarFunctionUntransformed.

Implemented in IG.Num.ScalarFunctionQuadratic, IG.Num.Func3dBase, IG.Num.ScalarFunctionLinear, IG.Num.Func2dBase, IG.Num.ScalarFunctionRadialUntransformed, IG.Num.ScalarFunctionBase, and IG.Num.ScalarFunctionConstant.

virtual void IG.Num.ScalarFunctionUntransformedBase.Hessian ( IVector  parameters,
ref IMatrix  hessian 
)
inlinevirtual

Calculates the second derivative (Hessian matrix) of this function at the specified parameters.

Parameters
parametersVector of parameters where derivatives are evaluated.
hessianMatrix where second derivatives (Hessian matrix) are stored. Passed by reference.

Implements IG.Num.IScalarFunctionUntransformed.

References IG.Num.IVector.GetNewMatrix().

Referenced by IG.Lib.ScalarFunctionLoader.Example().

virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalGradientForwardPlain ( IVector  x,
IVector  stepSizes,
IVector  gradient 
)
inlinevirtual

Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used.

WARNING: Dimensions of vector arguments must match. This function does not check for consistency of argument dimensions.

REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint at which derivative is calculated.
stepSizesStep size for numerical differentiation.
gradientVector where calculated derivatives (function gradient) are stored.
void IG.Num.ScalarFunctionUntransformedBase.NumericalGradientForward ( IVector  x,
IVector  stepSizes,
ref IVector  gradient 
)
inline

Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used.

If result vector doesn't have correct dimensions or it is not allocated, then allocation is performed first.

Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which gradient is calculated.
stepSizesStep sizes for numerical differentiation.
gradientVector where the calculated gradient is stored.

References IG.Num.IVector.GetNew().

void IG.Num.ScalarFunctionUntransformedBase.NumericalGradientForward ( IVector  x,
double  stepSize,
ref IVector  gradient 
)
inline

Calculates numerical derivatives (gradient) of this function. Forward difference formula is used.

Warning: This method internally allocates a new vector where step sizes are stored.

If result vector doesn't have correct dimensions or it is not allocated, then allocation is performed first.

Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which gradient is calculated.
stepSizesStep size for numerical differentiation (the same in all directions).
gradientVector where the calculated gradient is stored.

TODO: When NumericalDerivativePlain is tested enough, replace this function in sulch a way that stepSize is used directly in a copy of that function (currently a vetor of step sizes is created where each component holds the same step size.)

References IG.Num.IVector.GetNew().

virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalGradientCentralPlain ( IVector  x,
IVector  stepSizes,
IVector  gradient 
)
inlinevirtual

Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used.

Warning: Dimensions of vector arguments must match. This function does not check for consistency of argument dimensions.

Remark: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint at which derivative is calculated.
stepSizesStep size for numerical differentiation.
gradientVector where calculated derivatives (function gradient) are stored.
void IG.Num.ScalarFunctionUntransformedBase.NumericalGradientCentral ( IVector  x,
IVector  stepSizes,
ref IVector  gradient 
)
inline

Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used.

If result vector doesn't have correct dimensions or it is not allocated, then allocation is performed first.

Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which gradient is calculated.
stepSizesStep sizes for numerical differentiation.
gradientVector where the calculated gradient is stored.

References IG.Num.IVector.GetNew().

void IG.Num.ScalarFunctionUntransformedBase.NumericalGradientCentral ( IVector  x,
double  stepSize,
ref IVector  gradient 
)
inline

Calculates numerical derivatives (gradient) of this function. Forward difference formula is normally used.

Warning: This method internally allocates a new vector where step sizes are stored.

If the result vector doesn't have correct dimensions or it is not allocated, then allocation is performed first.

Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which gradient is calculated.
stepSizesStep size for numerical differentiation (the same in all directions).
gradientVector where the calculated gradient is stored.

TODO: When NumericalDerivativePlain is tested enough, replace this function in sulch a way that stepSize is used directly in a copy of that function (currently a vetor of step sizes is created where each component holds the same step size.)

References IG.Num.IVector.GetNew().

virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianForwardPlain ( IVector  x,
IVector  stepSizes,
IVector  aux,
IMatrix  hessian 
)
inlinevirtual

Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. WARNING: Dimensions of vector arguments must match. This function does not check for consistency of argument dimensions. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which derivative is calculated.
auxAuxiliary storage vector, must be of the same dimension as vector of parameters.
stepSizesStep size for numerical differentiation.
hessianMatrix where calculated second derivatives (function Hessian) are stored.
virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianForward ( IVector  x,
IVector  stepSizes,
ref IVector  aux,
ref IMatrix  hessian 
)
inlinevirtual

Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which derivative is calculated.
auxAuxiliary storage vector, must be of the same dimension as vector of parameters.
stepSizesStep size for numerical differentiation.
hessianMatrix where calculated second derivatives (function Hessian) are stored.

References IG.Num.IVector.GetNew(), and IG.Num.IVector.GetNewMatrix().

virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianForward ( IVector  x,
double  stepSize,
ref IVector  aux,
ref IMatrix  hessian 
)
inlinevirtual

Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which derivative is calculated.
auxAuxiliary storage vector, must be of the same dimension as vector of parameters.
stepSizeStep size for numerical differentiation (the same in all directions).
hessianMatrix where calculated second derivatives (function Hessian) are stored.

TODO: When NumericalSecondDerivativePlain is tested enough, replace this function in sulch a way that stepSize is used directly in a copy of that function (currently a vetor of step sizes is created where each component holds the same step size.)

References IG.Num.IVector.GetNew().

virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianCentralPlain ( IVector  x,
IVector  stepSizes,
IVector  aux1,
IVector  aux2,
IMatrix  hessian 
)
inlinevirtual

Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. WARNING: Dimensions of vector arguments must match. This function does not check for consistency of argument dimensions. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which derivative is calculated.
aux1Auxiliary storage vector, must be of the same dimension as vector of parameters.
stepSizesStep size for numerical differentiation.
hessianMatrix where calculated second derivatives (function Hessian) are stored.
virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianCentral ( IVector  x,
IVector  stepSizes,
ref IVector  aux1,
ref IVector  aux2,
ref IMatrix  hessian 
)
inlinevirtual

Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which derivative is calculated.
aux1Auxiliary storage vector, must be of the same dimension as vector of parameters.
stepSizesStep size for numerical differentiation.
hessianMatrix where calculated second derivatives (function Hessian) are stored.

References IG.Num.IVector.GetNew(), and IG.Num.IVector.GetNewMatrix().

virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianCentral ( IVector  x,
double  stepSize,
ref IVector  aux1,
ref IVector  aux2,
ref IMatrix  hessian 
)
inlinevirtual

Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which derivative is calculated.
stepSizeStep sizes for numerical differentiation.
aux1Auxiliary storage vector, must be of the same dimension as vector of parameters.
aux2The secont auxiliary storage vector, must be of the same dimension as vector of parameters.
hessianMatrix where calculated second derivatives (function Hessian) are stored.

TODO: When NumericalSecondDerivativePlain is tested enough, replace this function in sulch a way that stepSize is used directly in a copy of that function (currently a vetor of step sizes is created where each component holds the same step size.)

References IG.Num.IVector.GetNew().

virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianCentralPlain ( IVector  x,
IVector  stepSizes,
IVector  aux1,
IVector  aux2,
IMatrix  hessian,
bool  useAnalyticalGradient 
)
inlinevirtual

Calculates numerical second derivatives (Hessian) of this function by the central difference formula. WARNING: Dimensions of vector arguments must match. This function does not check for consistency of argument dimensions. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which derivative is calculated.
aux1Auxiliary storage vector, must be of the same dimension as vector of parameters.
aux2Another auxiliary storage vector, must be of the same dimension as vector of parameters.
stepSizesStep size for numerical differentiation.
hessianMatrix where calculated second derivatives (function Hessian) are stored.
useAnalyticalGradientIf true then analytical gradient are used when provided by the current function.
virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianCentral ( IVector  x,
IVector  stepSizes,
ref IVector  aux1,
ref IVector  aux2,
ref IMatrix  hessian,
bool  useAnalyticalGradient 
)
inlinevirtual

Calculates numerical second derivatives (Hessian) of this function by the central difference formula. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which derivative is calculated.
aux1Auxiliary storage vector, must be of the same dimension as vector of parameters.
aux2Another auxiliary storage vector, must be of the same dimension as vector of parameters.
stepSizesStep size for numerical differentiation.
hessianMatrix where calculated second derivatives (function Hessian) are stored.
useAnalyticalGradientIf true then analytical gradient are used when provided by the current function.

References IG.Num.IVector.GetNew(), and IG.Num.IVector.GetNewMatrix().

virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianCentral ( IVector  x,
double  stepSize,
ref IVector  aux1,
ref IVector  aux2,
ref IMatrix  hessian,
bool  useAnalyticalGradient 
)
inlinevirtual

Calculates numerical second derivatives (Hessian) of this function. Forward difference formula is normally used. REMARK: if auxiliary vector or result matrix don't have correct dimensions or they are not allocated, then allocation is performed first. REMARK: Vector x is changed during operation, but is set to initial value before function returns (unless an exception is thrown).

Parameters
xPoint (vector of parameters) at which derivative is calculated.
stepSizeStep sizes for numerical differentiation.
aux1Auxiliary storage vector, must be of the same dimension as vector of parameters.
aux2The second auxiliary storage vector, must be of the same dimension as vector of parameters.
hessianMatrix where calculated second derivatives (function Hessian) are stored.
useAnalyticalGradientIf true then analytical gradient are used when provided by the current function.

TODO: When NumericalSecondDerivativePlain is tested enough, replace this function in sulch a way that stepSize is used directly in a copy of that function (currently a vetor of step sizes is created where each component holds the same step size.)

References IG.Num.IVector.GetNew().

void IG.Num.ScalarFunctionUntransformedBase.TestSpeed ( IVector  parameters,
int  numEvaluations,
bool  randomPerturbations,
double  relativePerturbationSize,
bool  calcValue,
bool  calcGradient,
bool  calcHessian,
bool  writeLastResult 
)
inline

Tests speed of evaluation of the current scalar function and writes results to the console.

Parameters
parametersCentral value of parameters at which function value, gradient and/or Hessian is evaluated.
numEvaluationsNumber of evaluations performed.
randomPerturbationsWhether to use random perturbations or not.
relativePerturbationSizeRelative size of random perturbations, when used.
calcValueWhether function value is calculated.
calcGradientWhether function gradient is calculated.
calcHessianWhether function Hessian is calculated.
writeLastResultWhether results of the last calculation are written to console.

The specified number of function values, gradients and/or Hessians is evaluated, and time of evaluation is reported (with average time for a single evaluation also reported).

References IG.Num.RandomGenerator.Global, IG.Num.VectorBase.Multiply(), IG.Num.IRandomGenerator.NextDouble(), IG.Lib.StopWatch.Start(), IG.Num.IVector.ToString(), IG.Num.IMatrix.ToString(), IG.Lib.StopWatch.TotalCpuTime, and IG.Lib.StopWatch.TotalTime.

void IG.Num.ScalarFunctionUntransformedBase.TestGradient ( IVector  parameters,
IVector  stepSizes,
int  stepReductionFactor,
int  numStepReductions,
bool  checkNumerical,
bool  writeErrorComponents,
bool  writeGradientComponents 
)
inline

Tests the calculation of gradients of the current scalar function.

Differentiation is performed according to the central difference formula.

Calculations of numerical and analytical gradients can be verified.

Numerical gradients can be calculated at different step szes that are iteratively reduced by the specified integer factor, which gives indication of precision.

Parameters
parametersVector of parameters at which function gradient is calculated.
stepSizesVector of initial step sizes used for function differentiation.
stepReductionFactorFactor greater than 1 by which step size is reduced at each iteration.
numStepReductionsNumber of step size reductions.
checkNumericalWhether check is also made only on basis of numerical values.
writeErrorComponentsWhether gradient errors (and differences between results at different step sizes in the case of pure numerical check) in component-wise form are also written to the console (if fallse, only norms are written).
writeGradientComponentsWhether gradients (calculated and analytical) are written in component-wise form.
void IG.Num.ScalarFunctionUntransformedBase.TestGradient ( IVector  parameters,
IVector  stepSizes,
int  stepReductionFactor,
int  numStepReductions,
bool  checkNumerical,
bool  writeErrorComponents,
bool  writeGradientComponents,
bool  useCentralDifference 
)
inline

Tests the calculation of gradients of the current scalar function.

Calculations of numerical and analytical gradients can be verified.

Numerical gradients can be calculated at different step szes that are iteratively reduced by the specified integer factor, which gives indication of precision.

Parameters
parametersVector of parameters at which function gradient is calculated.
stepSizesVector of initial step sizes used for function differentiation.
stepReductionFactorFactor greater than 1 by which step size is reduced at each iteration.
numStepReductionsNumber of step size reductions.
checkNumericalWhether check is also made only on basis of numerical values.
writeErrorComponentsWhether gradient errors (and differences between results at different step sizes in the case of pure numerical check) in component-wise form are also written to the console (if fallse, only norms are written).
writeGradientComponentsWhether gradients (calculated and analytical) are written in component-wise form.
useCentralDifferenceWhether the more precise but also more time consuming central difference scheme is used for numerical differentiation.

References IG.Num.IVector.GetCopy(), IG.Num.VectorBase.Multiply(), IG.Num.IVector.SetConstant(), IG.Num.VectorBase.Subtract(), and IG.Num.IVector.ToString().

void IG.Num.ScalarFunctionUntransformedBase.TestHessian ( IVector  parameters,
IVector  stepSizes,
int  stepReductionFactor,
int  numStepReductions,
bool  checkNumerical,
bool  writeErrorComponents,
bool  writeHessianComponents 
)
inline

Tests the calculation of Hessians of the current scalar function.

Calculations of numerical and analytical Hessians can be verified.

Numerical Hessians can be calculated at different step szes that are iteratively reduced by the specified integer factor, which gives indication of precision.

Parameters
parametersVector of parameters at which function Hessian is calculated.
stepSizesVector of initial step sizes used for function differentiation.
stepReductionFactorFactor greater than 1 by which step size is reduced at each iteration.
numStepReductionsNumber of step size reductions.
checkNumericalWhether check is also made only on basis of numerical values.
writeErrorComponentsWhether Hessian errors (and differences between results at different step sizes in the case of pure numerical check) in component-wise form are also written to the console (if fallse, only norms are written).
writeHessianComponentsWhether Hessians (calculated and analytical) are written in component-wise form.
void IG.Num.ScalarFunctionUntransformedBase.TestHessian ( IVector  parameters,
IVector  stepSizes,
int  stepReductionFactor,
int  numStepReductions,
bool  checkNumerical,
bool  writeErrorComponents,
bool  writeHessianComponents,
bool  useCentralDifference 
)
inline

Tests the calculation of Hessians of the current scalar function.

Calculations of numerical and analytical Hessians can be verified.

Numerical Hessians can be calculated at different step szes that are iteratively reduced by the specified integer factor, which gives indication of precision.

Parameters
parametersVector of parameters at which function Hessian is calculated.
stepSizesVector of initial step sizes used for function differentiation.
stepReductionFactorFactor greater than 1 by which step size is reduced at each iteration.
numStepReductionsNumber of step size reductions.
checkNumericalWhether check is also made only on basis of numerical values.
writeErrorComponentsWhether Hessian errors (and differences between results at different step sizes in the case of pure numerical check) in component-wise form are also written to the console (if fallse, only norms are written).
writeHessianComponentsWhether Hessians (calculated and analytical) are written in component-wise form.
useCentralDifferenceWhether the central difference formula is used for numerial differentiation.

References IG.Num.IVector.GetCopy(), IG.Num.VectorBase.Multiply(), IG.Num.IMatrix.SetConstant(), IG.Num.MatrixBase.Subtract(), and IG.Num.IVector.ToString().

void IG.Num.ScalarFunctionUntransformedBase.Test ( IVector  from,
IVector  to,
int  numProbes,
IVector  stepSizes,
double  tolerance,
bool  testDerivatives,
bool  testSecondDerivatives,
bool  printDifferences,
bool  printResults 
)
inline

Performs numerical tests on the function, with output written to the console. Derivatives and second derivatives are tested and compared to numerical derivatives.

Parameters
fromInitial parameters on which tests are performed.
toFinal parameters on which tests are performed.
numProbesNumber of points on which tests are performed. Points are linearly distributed between from and to.
stepSizesStep sizes for numerical differentiation.
toleranceAbsolute tolerance for match between numerical and analytical values.
testDerivativesSpecifies whether first order derivatives should be tested.
testSecondDerivativesSpecifies whether second order derivatives should be tested.
printDifferencesSpecifies whether differences between numerical and analytical derivatives should be printed.
printResultsSpecifies whether results should be printed.

References IG.Num.VectorBase.Add(), IG.Num.VectorBase.Copy(), IG.Num.VectorBase.Divide(), IG.Num.IVector.GetNew(), IG.Num.VectorBase.Multiply(), IG.Num.VectorBase.Subtract(), and IG.Num.MatrixBase.Subtract().

void IG.Num.ScalarFunctionUntransformedBase.Test ( IVector  from,
IVector  to,
int  numProbes,
IVector  stepSizes,
double  tolerance 
)
inline

Performs numerical tests on the function, with output written to the console. Derivatives and second derivatives are tested and compared to numerical derivatives. This method tests first and second order derivatives, prints differences between analytical and numerical values to the console, and prints reports where absolute differences exceed rolerance.

Parameters
fromInitial parameters on which tests are performed.
toFinal parameters on which tests are performed.
numProbesNumber of points on which tests are performed. Points are linearly distributed between from and to.
stepSizesStep sizes for numerical differentiation.
toleranceAbsolute tolerance for match between numerical and analytical values.
void IG.Num.ScalarFunctionUntransformedBase.Test ( IVector  from,
IVector  to,
int  numProbes,
double  stepSize,
double  tolerance,
bool  testDerivatives,
bool  testSecondDerivatives,
bool  printDifferences,
bool  printResults 
)
inline

Performs numerical tests on the function, with output written to the console. Derivatives and second derivatives are tested and compared to numerical derivatives.

Parameters
fromInitial parameters on which tests are performed.
toFinal parameters on which tests are performed.
numProbesNumber of points on which tests are performed. Points are linearly distributed between from and to.
stepSizeStep size for numerical differentiation (the same in all directions).
toleranceAbsolute tolerance for match between numerical and analytical values.
testDerivativesSpecifies whether first order derivatives should be tested.
testSecondDerivativesSpecifies whether second order derivatives should be tested.
printDifferencesSpecifies whether differences between numerical and analytical derivatives should be printed.
printResultsSpecifies whether results should be printed.

References IG.Num.IVector.GetNew().

void IG.Num.ScalarFunctionUntransformedBase.Test ( IVector  from,
IVector  to,
int  numProbes,
double  stepSize,
double  tolerance 
)
inline

Performs numerical tests on the function, with output written to the console. Derivatives and second derivatives are tested and compared to numerical derivatives.

Parameters
fromInitial parameters on which tests are performed.
toFinal parameters on which tests are performed.
numProbesNumber of points on which tests are performed. Points are linearly distributed between from and to.
stepSizeStep size for numerical differentiation (the same in all directions).
toleranceAbsolute tolerance for match between numerical and analytical values.

Member Data Documentation

string IG.Num.ScalarFunctionUntransformedBase._name
protected
string IG.Num.ScalarFunctionUntransformedBase._description
protected

Property Documentation

virtual string IG.Num.ScalarFunctionUntransformedBase.Name
getset

Returns a short name of thecurrent function.

virtual string IG.Num.ScalarFunctionUntransformedBase.Description
getset

Returns a short description of the current function.

abstract bool IG.Num.ScalarFunctionUntransformedBase.ValueDefined
getprotected set

Tells whether value of the function is defined by implementation.

abstract bool IG.Num.ScalarFunctionUntransformedBase.GradientDefined
getprotected set

Tells whether the first derivative is defined for this function (by implementation, not mathematically)

abstract bool IG.Num.ScalarFunctionUntransformedBase.HessianDefined
getprotected set

Tells whether the second derivative is defined for this function (by implementation, not mathematically)


The documentation for this class was generated from the following file: