| 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 | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Properties | Private Attributes | List of all members
IG.Num.Func3dBase Class Referenceabstract

Base class for scalar functions of 3 variables (base for implementation of IFunc3d interface). More...

Inheritance diagram for IG.Num.Func3dBase:
[legend]
Collaboration diagram for IG.Num.Func3dBase:
[legend]

## Public Member Functions
abstract double | Value (double x, double y, double z)
| Calculates and returns value of the current 3D scalar function. More...
virtual double | Value (vec3 parameters)
| Calculates and returns value of the current 3D scalar function. More...
abstract void | Gradient (double x, double y, double z, out double gradx, out double grady, out double gradz)
| Calculates gradient of the current 3D scalar function and returns its components through the specified output variables. More...
virtual vec3 | Gradient (vec3 parameters)
| Calculates and returns gradient of the current 3D scalar function. More...
abstract void | Hessian (double x, double y, double z, out double dxx, out double dyy, out double dzz, out double dxy, out double dxz, out double dyz)
| Calculates Hessian of the current 3D scalar function and returns its component through the specified output variables. More...
virtual mat3 | Hessian (vec3 parameters)
| Calculates and returns Hessian of the current 3D scalar function and returns it (in the form of a mat3 struct). More...
override double | Value (IVector parameters)
| Returns the value of the current function at the specified parameters. More...
override 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...
override 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...
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...

## Static Public Member Functions
static void | Example ()
| Example of use of a 3D function. More...

## Protected Member Functions
| Func3dBase ()

## Static Protected Member Functions
static void | TestFunction (IFunc3d f)
| Demonstrates use of a 3D function by printing to the console 5 values and gradients of the function on the line connecting the two points (0, 0, 0) and (1, 1, 1). More...
static void | TestFunction (IFunc3d f, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, int numPoints)
| Demonstrates use of a 3D function by printing to the console some values and gradients of the function on the line connecting the two specified points. More...

## Properties
override bool | ValueDefined`[get, protected set]`
| Whether calculation of function value is defined. Defaulet is true. More...
override bool | GradientDefined`[get, protected set]`
| Whether calculation of functio ngradient is defined. Default is false. More...
override bool | HessianDefined`[get, protected set]`
| Whether calculation of function Hessian is defined. Default is false. More...
int | NumParam`[get]`
| Gets number of 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.IFunc3d
bool | ValueDefined`[get]`
| Whether calculation of function value is defined. More...
bool | GradientDefined`[get]`
| Whether calculation of function ngradient is defined. More...
bool | HessianDefined`[get]`
| Whether calculation of function Hessian is defined. More...

## Private Attributes
bool | _valueDefined = true
bool | _gradientDefined = false
bool | _hessianDefined = false

## Additional Inherited Members
Protected Attributes inherited from IG.Num.ScalarFunctionUntransformedBase
string | _name
string | _description

## Detailed Description

Base class for scalar functions of 3 variables (base for implementation of IFunc3d interface).

Beside the IFunc3d interface, this class also implements the IScalarFunction interface. This does not affect efficiency but adds the functionality for using objects as general (untransformed) scalar functions.

$A Igor Apr09;

## Constructor & Destructor Documentation

IG.Num.Func3dBase.Func3dBase | ( |  | ) |
| inline protected

## Member Function Documentation

abstract double IG.Num.Func3dBase.Value | ( | double | x,
|  | double | y,
|  | double | z
| ) |  |
| pure virtual

Calculates and returns value of the current 3D scalar function.

Parameters

  x | First parameter.
  y | Second parameter.
  z | Third parameter.

Implements IG.Num.IFunc3d.

Implemented in IG.Gr3d.ExampleValueFunctionDiff3D, IG.Gr3d.VtkPlotBase.ExampleValueFunctionDiff21, IG.Gr3d.VtkPlotBase.Func3dZero, IG.Gr3d.VtkPlotBase.Func3dZ, IG.Num.Func3dExamples.Func3dXYZ, IG.Num.Func3dVectorFormBase, and IG.Num.Func3dFromScalarFunction.

virtual double IG.Num.Func3dBase.Value | ( | vec3 | parameters | ) |
| inline virtual

Calculates and returns value of the current 3D scalar function.

Parameters

  parameters | Vector of function parameters (in form of the vec3 struct.

Returns
  Function value.

Implements IG.Num.IFunc3d.

Reimplemented in IG.Num.Func3dQuadratic, IG.Num.Func3dLinear, and IG.Num.Func3dVectorFormBase.

References IG.Num.vec3.x, IG.Num.vec3.y, and IG.Num.vec3.z.

abstract void IG.Num.Func3dBase.Gradient | ( | double | x,
|  | double | y,
|  | double | z,
|  | out double | gradx,
|  | out double | grady,
|  | out double | gradz
| ) |  |
| pure virtual

Calculates gradient of the current 3D scalar function and returns its components through the specified output variables.

Parameters

  x | First parameter.
  y | Second parameter.
  z | Third parameter.
  gradx | First component of the returned gradient.
  grady | Second component of the returned gradient.
  gradz | Third component of the returned gradient.

Implements IG.Num.IFunc3d.

Implemented in IG.Gr3d.VtkPlotBase.Func3dZero, IG.Gr3d.VtkPlotBase.Func3dZ, IG.Num.Func3dExamples.Func3dXYZ, IG.Num.Func3dVectorFormBase, IG.Num.Func3dBaseNoGradient, and IG.Num.Func3dFromScalarFunction.

virtual vec3 IG.Num.Func3dBase.Gradient | ( | vec3 | parameters | ) |
| inline virtual

Calculates and returns gradient of the current 3D scalar function.

Parameters

  parameters | Vector of parameters (in form of the vec3 struct)

<returnreturns>Gradient of the current 3D scalar function (in form of the vec3 struct)</returnreturns>

Implements IG.Num.IFunc3d.

Reimplemented in IG.Num.Func3dQuadratic, IG.Num.Func3dLinear, and IG.Num.Func3dVectorFormBase.

References IG.Num.vec3.x, IG.Num.vec3.y, and IG.Num.vec3.z.

abstract void IG.Num.Func3dBase.Hessian | ( | double | x,
|  | double | y,
|  | double | z,
|  | out double | dxx,
|  | out double | dyy,
|  | out double | dzz,
|  | out double | dxy,
|  | out double | dxz,
|  | out double | dyz
| ) |  |
| pure virtual

Calculates Hessian of the current 3D scalar function and returns its component through the specified output variables.

Parameters

  x | First parameter.
  y | Second parameter.
  z | Third parameter.
  dxx | Component 1-1 of the calculated Hessian.
  dyy | Component 2-2 of the calculated Hessian.
  dzz | Component 3-3 of the calculated Hessian.
  dxy | Component 1-2 of the calculated Hessian.
  dxz | Component 1-3 of the calculated Hessian.
  dyz | Component 2-3 of the calculated Hessian.

Implements IG.Num.IFunc3d.

Implemented in IG.Num.Func3dVectorFormBase, IG.Num.Func3dBaseNoGradient, IG.Num.Func3dBaseNoHessian, and IG.Num.Func3dFromScalarFunction.

virtual mat3 IG.Num.Func3dBase.Hessian | ( | vec3 | parameters | ) |
| inline virtual

Calculates and returns Hessian of the current 3D scalar function and returns it (in the form of a mat3 struct).

Implements IG.Num.IFunc3d.

Reimplemented in IG.Num.Func3dQuadratic, IG.Num.Func3dLinear, and IG.Num.Func3dVectorFormBase.

References IG.Num.vec3.x, IG.Num.vec3.y, and IG.Num.vec3.z.

override double IG.Num.Func3dBase.Value | ( | IVector | parameters | ) |
| inline

Returns the value of the current function at the specified parameters.

Parameters

  parameters | Vector of parameters for which value is evaluated. Its dimension must be equal to 3.

Implements IG.Num.IScalarFunctionUntransformed.

override void IG.Num.Func3dBase.GradientPlain | ( | IVector | parameters,
|  | IVector | gradient
| ) |  |
| inline

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.

override void IG.Num.Func3dBase.HessianPlain | ( | IVector | parameters,
|  | IMatrix | hessian
| ) |  |
| inline

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.

static void IG.Num.Func3dBase.TestFunction | ( | IFunc3d | f | ) |
| inline static protected

Demonstrates use of a 3D function by printing to the console 5 values and gradients of the function on the line connecting the two points (0, 0, 0) and (1, 1, 1).

Parameters

  f | Function whose values and gradients are evaluated and printed.

static void IG.Num.Func3dBase.TestFunction | ( | IFunc3d | f,
|  | double | xmin,
|  | double | xmax,
|  | double | ymin,
|  | double | ymax,
|  | double | zmin,
|  | double | zmax,
|  | int | numPoints
| ) |  |
| inline static protected

Demonstrates use of a 3D function by printing to the console some values and gradients of the function on the line connecting the two specified points.

Parameters

  f | Function whose values and gradients are evaluated and printed.
  xmin | Min. x.
  xmax | Max. x.
  ymin | Min. y.
  ymax | Max. y.
  zmin | Min. z.
  zmax | Max. z.
  numPoints | Number of points in which function values and gradients are printed.

References IG.Num.IFunc3d.Gradient(), IG.Num.IFunc3d.GradientDefined, IG.Num.IFunc3d.Value(), and IG.Num.IFunc3d.ValueDefined.

static void IG.Num.Func3dBase.Example | ( |  | ) |
| inline static

Example of use of a 3D function.

## Member Data Documentation

bool IG.Num.Func3dBase._valueDefined = true
| private

bool IG.Num.Func3dBase._gradientDefined = false
| private

bool IG.Num.Func3dBase._hessianDefined = false
| private

## Property Documentation

override bool IG.Num.Func3dBase.ValueDefined
| get protected set

Whether calculation of function value is defined. Defaulet is true.

override bool IG.Num.Func3dBase.GradientDefined
| get protected set

Whether calculation of functio ngradient is defined. Default is false.

override bool IG.Num.Func3dBase.HessianDefined
| get protected set

Whether calculation of function Hessian is defined. Default is false.

int IG.Num.Func3dBase.NumParam
| get

Gets number of parameters.

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

- igbase/numeric/geometry/Function3d.cs