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

A ScalarFunction class used as base class for dynamically loaded scalar functions. Functions loaded from scripts will inherit from this class, which enables script writers to assemble just the minimum necessary amount of code. More...

+ Inheritance diagram for IG.Lib.LoadableScalarFunctionBase:
+ Collaboration diagram for IG.Lib.LoadableScalarFunctionBase:

Public Member Functions

 LoadableScalarFunctionBase ()
 Constructs reference scalar function of vector variable defined by the user (witout any transfomrations). More...
 
 LoadableScalarFunctionBase (IAffineTransformation transf)
 Constructs a scalar function of vector argument defined by the user defined function and affine transformation of parameters. More...
 
override double ReferenceValue (IVector parameters)
 Returns the value of this function at the specified parameter in the reference coordinate system. More...
 
override void ReferenceGradientPlain (IVector parameters, IVector gradient)
 Calculates the first derivative (gradient) of this function at the specified parameter in the reference coordinate system. More...
 
override void ReferenceHessianPlain (IVector parameters, IMatrix hessian)
 Calculates the second derivative (Hessian) of this function at the specified parameters in the reference coordinate system. More...
 
- Public Member Functions inherited from IG.Num.ScalarFunctionBase
 ScalarFunctionBase (IAffineTransformation transf)
 Constructs a scalar function that is identical to some reference funciton acting on affine transformed parameters. More...
 
override double Value (IVector x)
 Returns the value of this function at the specified parameter. More...
 
override void GradientPlain (IVector x, IVector gradient)
 Returns the first derivative of this function at the specified parameter. More...
 
override void HessianPlain (IVector x, IMatrix hessian)
 Returns the second derivative (Hessian) of this function at the specified arameter. More...
 
- Public Member Functions inherited from IG.Num.ScalarFunctionUntransformedBase
virtual void Evaluate (IScalarFunctionResults data)
 Evaluates whatever needs to be evaluated and stores the results on the specified storage object. More...
 
virtual void Gradient (IVector parameters, ref IVector gradient)
 Calculates first order derivatives (gradient) of this function at the specified parameters. 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 Member Functions

abstract void InitDynamic ()
 Initialization of variables that are used by dynamic loading mechanisim. This function must be overridden in derived classes. More...
 
- Protected Member Functions inherited from IG.Num.ScalarFunctionBase
 ScalarFunctionBase ()
 Default constructor for scalar functions of affine transformed parameters. Constructs untransformed reference function. More...
 

Protected Attributes

string[] _independentVariableNames = null
 
string _returnedValueName = null
 
string[] _gradientDefinitionStrings = null
 
string[][] _hessianDefinitionStrings = null
 
int _numParam
 
bool _valueDefined = false
 
- Protected Attributes inherited from IG.Num.ScalarFunctionBase
IVector _refParam
 
IVector _refGrad
 
IMatrix _refHess
 
- Protected Attributes inherited from IG.Num.ScalarFunctionUntransformedBase
string _name
 
string _description
 

Properties

virtual int NumParameters [get]
 Gets number of parameters of the current user defined scalar function. More...
 
override string Name [get, set]
 Function name. More...
 
override string Description [get, set]
 Function description. More...
 
override bool ValueDefined [get, protected set]
 Whether calculation of value is implemented for the current scalar function. More...
 
override bool GradientDefined [get, protected set]
 Whether calculation of gradient is implemeted for the current scalar function. More...
 
override bool HessianDefined [get, protected set]
 Whether calculation of second derivative is implemented for the current function. More...
 
- Properties inherited from IG.Num.ScalarFunctionBase
virtual IAffineTransformation Transformation [get, set]
 Transformation of parameters. Actual function is evaluated as some reference function evaluated at inverse affine-transformed parameters. More...
 
- Properties inherited from IG.Num.ScalarFunctionUntransformedBase
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...
 
- Properties inherited from IG.Num.IScalarFunction
IAffineTransformation Transformation [get, set]
 Affine transformation of parameters. Actual function is evaluated as reference function evaluated at inverse affine transformed parameters. More...
 

Private Attributes

string _functionArgumentParametersName = null
 
string _functionArgumentGradientName = null
 
string _functionArgumentHessianName = null
 
string _independentVariableName = null
 
string _valueDefinitionString = null
 
bool _gradientDefined = false
 
bool _hessianDefined = false
 

Detailed Description

A ScalarFunction class used as base class for dynamically loaded scalar functions. Functions loaded from scripts will inherit from this class, which enables script writers to assemble just the minimum necessary amount of code.

$A Igor Jun10;

Constructor & Destructor Documentation

IG.Lib.LoadableScalarFunctionBase.LoadableScalarFunctionBase ( )
inline

Constructs reference scalar function of vector variable defined by the user (witout any transfomrations).

IG.Lib.LoadableScalarFunctionBase.LoadableScalarFunctionBase ( IAffineTransformation  transf)
inline

Constructs a scalar function of vector argument defined by the user defined function and affine transformation of parameters.

Parameters
transfAffine transformation that is applied to parameters. If null then the fuction is identical to the reference (untransformed) user-defined function.

$A Igor Sep10;

Member Function Documentation

abstract void IG.Lib.LoadableScalarFunctionBase.InitDynamic ( )
protectedpure virtual

Initialization of variables that are used by dynamic loading mechanisim. This function must be overridden in derived classes.

Implemented in IG.Script.ScritpScalarFunctionExample.Container.Function.

override double IG.Lib.LoadableScalarFunctionBase.ReferenceValue ( IVector  parameters)
inlinevirtual

Returns the value of this function at the specified parameter in the reference coordinate system.

Parameters
parametersVector of parameters (in the REFERENCE system) where function is evaluated.

Implements IG.Num.ScalarFunctionBase.

Reimplemented in IG.Script.ScritpScalarFunctionExample.Container.Function.

override void IG.Lib.LoadableScalarFunctionBase.ReferenceGradientPlain ( IVector  parameters,
IVector  gradient 
)
inlinevirtual

Calculates the first derivative (gradient) of this function at the specified parameter in the reference coordinate system.

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

Implements IG.Num.ScalarFunctionBase.

Reimplemented in IG.Script.ScritpScalarFunctionExample.Container.Function.

override void IG.Lib.LoadableScalarFunctionBase.ReferenceHessianPlain ( IVector  parameters,
IMatrix  hessian 
)
inlinevirtual

Calculates the second derivative (Hessian) of this function at the specified parameters in the reference coordinate system.

Parameters
parametersVector of parameters (in the REFERENCE system) where Hessian is evaluated.
hessianMatrix where second derivatives (Hessian) are stored.

Implements IG.Num.ScalarFunctionBase.

Reimplemented in IG.Script.ScritpScalarFunctionExample.Container.Function.

Member Data Documentation

string [] IG.Lib.LoadableScalarFunctionBase._independentVariableNames = null
protected
string IG.Lib.LoadableScalarFunctionBase._returnedValueName = null
protected
string IG.Lib.LoadableScalarFunctionBase._functionArgumentParametersName = null
private
string IG.Lib.LoadableScalarFunctionBase._functionArgumentGradientName = null
private
string IG.Lib.LoadableScalarFunctionBase._functionArgumentHessianName = null
private
string IG.Lib.LoadableScalarFunctionBase._independentVariableName = null
private
string IG.Lib.LoadableScalarFunctionBase._valueDefinitionString = null
private
string [] IG.Lib.LoadableScalarFunctionBase._gradientDefinitionStrings = null
protected
string [][] IG.Lib.LoadableScalarFunctionBase._hessianDefinitionStrings = null
protected
int IG.Lib.LoadableScalarFunctionBase._numParam
protected
bool IG.Lib.LoadableScalarFunctionBase._valueDefined = false
protected
bool IG.Lib.LoadableScalarFunctionBase._gradientDefined = false
private
bool IG.Lib.LoadableScalarFunctionBase._hessianDefined = false
private

Property Documentation

virtual int IG.Lib.LoadableScalarFunctionBase.NumParameters
get

Gets number of parameters of the current user defined scalar function.

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

override string IG.Lib.LoadableScalarFunctionBase.Name
getset

Function name.

override string IG.Lib.LoadableScalarFunctionBase.Description
getset

Function description.

override bool IG.Lib.LoadableScalarFunctionBase.ValueDefined
getprotected set

Whether calculation of value is implemented for the current scalar function.

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

override bool IG.Lib.LoadableScalarFunctionBase.GradientDefined
getprotected set

Whether calculation of gradient is implemeted for the current scalar function.

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

override bool IG.Lib.LoadableScalarFunctionBase.HessianDefined
getprotected set

Whether calculation of second derivative is implemented for the current function.

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


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