| IGLib 1.5 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
Public Member Functions | Protected Attributes | Properties | List of all members
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:
[legend]
Collaboration diagram for IG.Num.ScalarFunctionUntransformedBase:
[legend]

## 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

virtual void IG.Num.ScalarFunctionUntransformedBase.Evaluate | ( | IScalarFunctionResults | data | ) |
| inline virtual

Evaluates whatever needs to be evaluated and stores the results on the specified storage object.

Parameters

  data | Evaluation data object where results of calculation are stored. It also contains flags taht specify what needs to be calculated, and resulting flags specifying what has been calculated.

Implements IG.Num.IScalarFunctionUntransformed.

References IG.Num.IScalarFunctionResults.Calculated, IG.Num.IScalarFunctionResults.CalculatedGradient, IG.Num.IScalarFunctionResults.CalculatedHessian, IG.Num.IScalarFunctionResults.CalculatedValue, IG.Num.IScalarFunctionResults.ErrorCode, IG.Num.IScalarFunctionResults.ErrorString, IG.Num.IVector.GetNew(), IG.Num.IVector.GetNewMatrix(), IG.Num.IScalarFunctionResults.Gradient, IG.Num.IScalarFunctionResults.Hessian, IG.Num.IScalarFunctionResults.Parameters, IG.Num.IScalarFunctionResults.ReqGradient, IG.Num.IScalarFunctionResults.ReqHessian, IG.Num.IScalarFunctionResults.ReqValue, IG.Num.IScalarFunctionResults.SetGradientReference(), IG.Num.IScalarFunctionResults.SetHessianReference(), and IG.Num.IScalarFunctionResults.Value.

abstract double IG.Num.ScalarFunctionUntransformedBase.Value | ( | IVector | parameters | ) |
| pure virtual

Returns the value of this function at the specified parameter.

Implements IG.Num.IScalarFunctionUntransformed.

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

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

  parameters | Vector of parameters where derivatives are evaluated.
  gradient | Vector 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
| ) |  |
| inline virtual

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

Parameters

  parameters | Vector of parameters where derivatives are evaluated.
  gradient | Vector 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

  parameters | Vector of parameters where derivatives are evaluated.
  hessian | Matrix 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
| ) |  |
| inline virtual

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

Parameters

  parameters | Vector of parameters where derivatives are evaluated.
  hessian | Matrix 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
| ) |  |
| inline virtual

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

  x | Point at which derivative is calculated.
  stepSizes | Step size for numerical differentiation.
  gradient | Vector 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

  x | Point (vector of parameters) at which gradient is calculated.
  stepSizes | Step sizes for numerical differentiation.
  gradient | Vector 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

  x | Point (vector of parameters) at which gradient is calculated.
  stepSizes | Step size for numerical differentiation (the same in all directions).
  gradient | Vector 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
| ) |  |
| inline virtual

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

  x | Point at which derivative is calculated.
  stepSizes | Step size for numerical differentiation.
  gradient | Vector 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

  x | Point (vector of parameters) at which gradient is calculated.
  stepSizes | Step sizes for numerical differentiation.
  gradient | Vector 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

  x | Point (vector of parameters) at which gradient is calculated.
  stepSizes | Step size for numerical differentiation (the same in all directions).
  gradient | Vector 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
| ) |  |
| inline virtual

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

  x | Point (vector of parameters) at which derivative is calculated.
  aux | Auxiliary storage vector, must be of the same dimension as vector of parameters.
  stepSizes | Step size for numerical differentiation.
  hessian | Matrix where calculated second derivatives (function Hessian) are stored.

virtual void IG.Num.ScalarFunctionUntransformedBase.NumericalHessianForward | ( | IVector | x,
|  | IVector | stepSizes,
|  | ref IVector | aux,
|  | ref IMatrix | hessian
| ) |  |
| inline virtual

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

  x | Point (vector of parameters) at which derivative is calculated.
  aux | Auxiliary storage vector, must be of the same dimension as vector of parameters.
  stepSizes | Step size for numerical differentiation.
  hessian | Matrix 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
| ) |  |
| inline virtual

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

  x | Point (vector of parameters) at which derivative is calculated.
  aux | Auxiliary storage vector, must be of the same dimension as vector of parameters.
  stepSize | Step size for numerical differentiation (the same in all directions).
  hessian | Matrix 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
| ) |  |
| inline virtual

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

  x | Point (vector of parameters) at which derivative is calculated.
  aux1 | Auxiliary storage vector, must be of the same dimension as vector of parameters.
  stepSizes | Step size for numerical differentiation.
  hessian | Matrix 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
| ) |  |
| inline virtual

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

  x | Point (vector of parameters) at which derivative is calculated.
  aux1 | Auxiliary storage vector, must be of the same dimension as vector of parameters.
  stepSizes | Step size for numerical differentiation.
  hessian | Matrix 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
| ) |  |
| inline virtual

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

  x | Point (vector of parameters) at which derivative is calculated.
  stepSize | Step sizes for numerical differentiation.
  aux1 | Auxiliary storage vector, must be of the same dimension as vector of parameters.
  aux2 | The secont auxiliary storage vector, must be of the same dimension as vector of parameters.
  hessian | Matrix 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
| ) |  |
| inline virtual

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

  x | Point (vector of parameters) at which derivative is calculated.
  aux1 | Auxiliary storage vector, must be of the same dimension as vector of parameters.
  aux2 | Another auxiliary storage vector, must be of the same dimension as vector of parameters.
  stepSizes | Step size for numerical differentiation.
  hessian | Matrix where calculated second derivatives (function Hessian) are stored.
  useAnalyticalGradient | If 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
| ) |  |
| inline virtual

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

  x | Point (vector of parameters) at which derivative is calculated.
  aux1 | Auxiliary storage vector, must be of the same dimension as vector of parameters.
  aux2 | Another auxiliary storage vector, must be of the same dimension as vector of parameters.
  stepSizes | Step size for numerical differentiation.
  hessian | Matrix where calculated second derivatives (function Hessian) are stored.
  useAnalyticalGradient | If 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
| ) |  |
| inline virtual

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

  x | Point (vector of parameters) at which derivative is calculated.
  stepSize | Step sizes for numerical differentiation.
  aux1 | Auxiliary storage vector, must be of the same dimension as vector of parameters.
  aux2 | The second auxiliary storage vector, must be of the same dimension as vector of parameters.
  hessian | Matrix where calculated second derivatives (function Hessian) are stored.
  useAnalyticalGradient | If 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

  parameters | Central value of parameters at which function value, gradient and/or Hessian is evaluated.
  numEvaluations | Number of evaluations performed.
  randomPerturbations | Whether to use random perturbations or not.
  relativePerturbationSize | Relative size of random perturbations, when used.
  calcValue | Whether function value is calculated.
  calcGradient | Whether function gradient is calculated.
  calcHessian | Whether function Hessian is calculated.
  writeLastResult | Whether 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

  parameters | Vector of parameters at which function gradient is calculated.
  stepSizes | Vector of initial step sizes used for function differentiation.
  stepReductionFactor | Factor greater than 1 by which step size is reduced at each iteration.
  numStepReductions | Number of step size reductions.
  checkNumerical | Whether check is also made only on basis of numerical values.
  writeErrorComponents | Whether 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).
  writeGradientComponents | Whether 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

  parameters | Vector of parameters at which function gradient is calculated.
  stepSizes | Vector of initial step sizes used for function differentiation.
  stepReductionFactor | Factor greater than 1 by which step size is reduced at each iteration.
  numStepReductions | Number of step size reductions.
  checkNumerical | Whether check is also made only on basis of numerical values.
  writeErrorComponents | Whether 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).
  writeGradientComponents | Whether gradients (calculated and analytical) are written in component-wise form.
  useCentralDifference | Whether 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

  parameters | Vector of parameters at which function Hessian is calculated.
  stepSizes | Vector of initial step sizes used for function differentiation.
  stepReductionFactor | Factor greater than 1 by which step size is reduced at each iteration.
  numStepReductions | Number of step size reductions.
  checkNumerical | Whether check is also made only on basis of numerical values.
  writeErrorComponents | Whether 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).
  writeHessianComponents | Whether 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

  parameters | Vector of parameters at which function Hessian is calculated.
  stepSizes | Vector of initial step sizes used for function differentiation.
  stepReductionFactor | Factor greater than 1 by which step size is reduced at each iteration.
  numStepReductions | Number of step size reductions.
  checkNumerical | Whether check is also made only on basis of numerical values.
  writeErrorComponents | Whether 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).
  writeHessianComponents | Whether Hessians (calculated and analytical) are written in component-wise form.
  useCentralDifference | Whether 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

  from | Initial parameters on which tests are performed.
  to | Final parameters on which tests are performed.
  numProbes | Number of points on which tests are performed. Points are linearly distributed between from and to.
  stepSizes | Step sizes for numerical differentiation.
  tolerance | Absolute tolerance for match between numerical and analytical values.
  testDerivatives | Specifies whether first order derivatives should be tested.
  testSecondDerivatives | Specifies whether second order derivatives should be tested.
  printDifferences | Specifies whether differences between numerical and analytical derivatives should be printed.
  printResults | Specifies 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

  from | Initial parameters on which tests are performed.
  to | Final parameters on which tests are performed.
  numProbes | Number of points on which tests are performed. Points are linearly distributed between from and to.
  stepSizes | Step sizes for numerical differentiation.
  tolerance | Absolute 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

  from | Initial parameters on which tests are performed.
  to | Final parameters on which tests are performed.
  numProbes | Number of points on which tests are performed. Points are linearly distributed between from and to.
  stepSize | Step size for numerical differentiation (the same in all directions).
  tolerance | Absolute tolerance for match between numerical and analytical values.
  testDerivatives | Specifies whether first order derivatives should be tested.
  testSecondDerivatives | Specifies whether second order derivatives should be tested.
  printDifferences | Specifies whether differences between numerical and analytical derivatives should be printed.
  printResults | Specifies 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

  from | Initial parameters on which tests are performed.
  to | Final parameters on which tests are performed.
  numProbes | Number of points on which tests are performed. Points are linearly distributed between from and to.
  stepSize | Step size for numerical differentiation (the same in all directions).
  tolerance | Absolute 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
| get set

Returns a short name of thecurrent function.

virtual string IG.Num.ScalarFunctionUntransformedBase.Description
| get set

Returns a short description of the current function.

abstract bool IG.Num.ScalarFunctionUntransformedBase.ValueDefined
| get protected set

Tells whether value of the function is defined by implementation.

abstract bool IG.Num.ScalarFunctionUntransformedBase.GradientDefined
| get protected set

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

abstract bool IG.Num.ScalarFunctionUntransformedBase.HessianDefined
| get protected 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:

- igbase/numeric/FunctionScalarUntransformedBase.cs