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.Num.QuadraticBasis Class Reference

Vector function containing quadratic basis in a n-dimensional vector space. Composed of (n+1)*(n+2)/2 functions: 1, x_1, ..., x_n, 0.5*x_1^2, 0.5*x_2^2, ..., 0.5*x_n^2, x_1*x_2, x_1*x_3, ..., x_1*x_n, ..., x_2*x_3, ..., x_2*x_n, ..., ..., x_n-1*x_n. More...

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

Public Member Functions

 QuadraticBasis (int dimension)
 Constructs a vector function containing quadratic basis for the specified dimension. Composed of (n+1)*(n+2)/2 functions: 1, x_1, ..., x_n, 0.5*x_1^2, 0.5*x_2^2, ..., 0.5*x_n^2, x_1*x_2, x_1*x_3, ..., x_1*x_n, ..., x_2*x_3, ..., x_2*x_n, ..., ..., x_n-1*x_n. More...
 
int[] GetFunctionDefinition (int which)
 Returns a table of indices defining the specified function of the quadratic basis. Table contains up to two indices of variables whose product represents the specific basis function. [] (empty array) means constant term, [1] means x1, [2] means x2, [1,1] means x1^2, [2,2] means x2^2, [1,2] means x1*x2, [3,5] means x4*x5, etc. More...
 
void GetFunctionDefinition (int which, out int numTerms, out int firstVariableIndex, out int secondVariableIndex)
 Returns data about the specific function of this vector function containing quadratic basis. Examples: numTerms = 0: constant (1) numTerms = 1: linear terms, firstVariableIndex is index of the variable. numTerms = 2: quadratic terms, firstVariableIndex and secondVariableIndex are indices of variables whose product gives this basis function. More...
 
override double Value (IVectorFunctionResults evaluationData, int which)
 Calculates and returns the particular component of the vector function value. More...
 
override double Derivative (IVectorFunctionResults evaluationData, int which, int component)
 Calculates and returns the particular component of the vector function's derivative. More...
 
override double SecondDerivative (IVectorFunctionResults evaluationData, int which, int rowNum, int columnNum)
 Calculates and returns the particular component of the vector function's second derivative (Hessian). More...
 
- Public Member Functions inherited from IG.Num.VectorFunctionBaseComponentWise
override void Evaluate (IVectorFunctionResults evaluationData)
 Performs evaluation of requwester function results and writes them to the provided data structure. Uses Evaluate(IVector, ref bool, ref List{double}, ref bool, ref List{IVector}, ref bool, ref List{IMatrix}) to do the job. More...
 
override void Evaluate (IVector parameters, ref bool calculateValues, ref List< double > values, ref bool calculateGradients, ref List< IVector > gradients, ref bool calculateHessians, ref List< IMatrix > hessians)
 Calculation of values, gradients, and hessians of the vector function according to request flags. Uses functions for component-wise evaluation to do the job. More...
 
- Public Member Functions inherited from IG.Num.VectorFunctionBaseGeneral
 VectorFunctionBaseGeneral ()
 
void SetNumParameters (int num)
 Sets number of parameters of the current vector function to the specified value. More...
 
void SetNumValues (int num)
 Sets number of values of the vector function to the specified value. More...
 
virtual double Value (IVector parameters, int which)
 Calculates and returns the particular component of the vector function value. More...
 
virtual double Derivative (IVector parameters, int which, int component)
 Calculates and returns the particular component of the vector function derivative. More...
 
virtual double SecondDerivative (IVector parameters, int which, int rowNum, int columnNum)
 Calculates and returns the particular component of the vector function's second derivative (Hessian). More...
 
void Value (IVector parameters, ref List< double > values)
 Returns the value of vector function at the specified parameter. More...
 
void Derivative (IVector parameters, ref List< IVector > gradients)
 Returns the first derivative of this function at the specified parameter. More...
 
void SecondDerivative (IVector parameters, ref List< IMatrix > hessians)
 Returns the second derivative (Hessian) of this function at the specified arameter. More...
 
double LinearCombinationValue (IVectorFunctionResults evaluationData, IVector coefficients)
 Returns value of linear combination of functions contained in this vector function, with specified coefficients at specified parameters. More...
 
void LinearCombinationDerivative (IVectorFunctionResults evaluationData, IVector coefficients, ref IVector res)
 Returns gradient of linear combination of functions contained in this vector function, with specified coefficients at specified parameters. More...
 
double LinearCombinationDerivative (IVectorFunctionResults evaluationData, IVector coefficients, int component)
 Returns the specified component of gradient of combination of functions contained in this vector function, with specified coefficients at specified parameters. More...
 
void LinearCombinationSecondDerivative (IVectorFunctionResults evaluationData, IVector coefficients, ref IMatrix res)
 
double LinearCombinationSecondDerivative (IVectorFunctionResults evaluationData, IVector coefficients, int rowNum, int columnNum)
 Returns the specified component of Hessian of combination of functions contained in this vector function, with specified coefficients at specified parameters. More...
 
double LinearCombinationValue (IVector parameters, IVector coefficients)
 Returns value of linear combination of functions contained in this vector function, with specified coefficients at specified parameters. More...
 
void LinearCombinationDerivative (IVector parameters, IVector coefficients, ref IVector res)
 Returns gradient of linear combination of functions contained in this vector function, with specified coefficients at specified parameters. More...
 
double LinearCombinationDerivative (IVector parameters, IVector coefficients, int component)
 Returns the specified component of gradient of combination of functions contained in this vector function, with specified coefficients at specified parameters. More...
 
void LinearCombinationSecondDerivative (IVector parameters, IVector coefficients, ref IMatrix res)
 Calculates second derivatives of the linear combination of components of vector functions and stores them to the specified matrix. More...
 
double LinearCombinationSecondDerivative (IVector parameters, IVector coefficients, int rowNum, int columnNum)
 Returns the specified component of Hessian of combination of functions contained in this vector function, with specified coefficients at specified parameters. More...
 
virtual void NumericalDerivative (IVector x, IVector stepSize, ref List< IVector > derivative)
 Calculates numerical derivative of this function. Central difference formula is used. More...
 
virtual void NumericalSecondDerivative (IVector x, IVector stepsizes, ref List< IVector > secondDerivatives)
 Calculates numerical second order derivative of this function. Central difference formula is used. More...
 

Static Public Member Functions

static int NumQuadraticBasisFunctions (int dimension)
 Returns number of basis functions in quadratic polynomial basis of the specified dimenson. This is a helper method. More...
 
static void Example ()
 Example for this class, just runs examples form the LinearBasis class. More...
 

Protected Attributes

int[][] functionDefinitions
 Definitions of basis functions. Each definition is an array of at most 2 indices specifying the product of which variables (zero-base) is a specific function. At index 0, length of array is 0. At indices 1 through n+1 it is 1 (linear terms), and at remaining indices it is 2. More...
 
int[,] quatraticTerms
 2D table of indices specifying for each quadratic term which function it corresponds to (since up to quadratic terms this is trivial). More...
 
- Protected Attributes inherited from IG.Num.VectorFunctionBaseGeneral
object _lock = new object()
 
string _name
 
string _description
 
int _numParameters = -1
 
int _numValues = -1
 
bool _valuesDefined = true
 
bool _derivativeDefined = false
 
bool _secondDerivativeDefined = false
 
bool _componentEvaluation = false
 

Private Member Functions

 QuadraticBasis ()
 
int GetConstantTermIndex ()
 Returns index of the constant function in this quadratic basis. More...
 
int GetLinearTermIndex (int varIndex)
 Returns index of the specified linear function in this quadratic basis. More...
 
int GetQuadraticTermIndex (int varIndex1, int varIndex2)
 Returns index of the specified quadratic function in this quadratic basis. Order of indices specifying the term is not important. More...
 

Additional Inherited Members

- Properties inherited from IG.Num.VectorFunctionBaseComponentWise
override bool ComponentWiseEvaluation [get, protected set]
 Returns true, indicating that individual components of functions and eventually their deirvatives is performed directly. More...
 
- Properties inherited from IG.Num.VectorFunctionBaseGeneral
object Lock [get]
 
virtual string Name [get, set]
 Returns a short name of the function. More...
 
virtual string Description [get, set]
 Returns a short description of the function. More...
 
virtual int NumParameters [get, protected set]
 Gets number of parameters of the current vector function (-1 for not defined, in case that function works with different numbers of parameters). More...
 
virtual int NumValues [get, protected set]
 Gets number of values of the current vector function (-1 for not defined, e.g. in case that function works with different numbers of parameters and number of functions depends on number of parameters). More...
 
virtual bool ComponentWiseEvaluation [get, protected set]
 Tells whether the function supports evaluation of individual components. If not then evaluation is performed through the Evaluate function. More...
 
virtual bool ValueDefined [get, protected set]
 Tells whether value of the function is defined by implementation. More...
 
virtual bool DerivativeDefined [get, protected set]
 Tells whether the first derivative is defined for this function (by implementation, not mathematically) More...
 
virtual bool SecondDerivativeDefined [get, protected set]
 Tells whether the second derivative is defined for this function (by implementation, not mathematically) More...
 
IVectorFunctionResults AuxResults [get]
 
VectorFunctionBase.ObjectStoreResults ResultsStore [get]
 Store of result objects for reuse. More...
 
- Properties inherited from IG.Num.IVectorFunction
string Name [get]
 Returns a short name of the function. More...
 
string Description [get]
 Returns a short description of the function. More...
 
int NumParameters [get]
 Gets number of parameters of the current vector function (-1 for not defined, in case that function works with different numbers of parameters). More...
 
int NumValues [get]
 Gets number of values of the current vector function (-1 for not defined, e.g. in case that function works with different numbers of parameters and number of functions depends on number of parameters). More...
 
bool ValueDefined [get]
 Tells whether value of the function is defined by implementation. More...
 
bool DerivativeDefined [get]
 Tells whether the first derivative is defined for this function (by implementation, not mathematically) More...
 
bool SecondDerivativeDefined [get]
 Tells whether the second derivative is defined for this function (by implementation, not mathematically) More...
 
bool ComponentWiseEvaluation [get]
 Tells whether the function supports evaluation of individual components. If not then evaluation is performed through the Evaluate function. More...
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

Detailed Description

Vector function containing quadratic basis in a n-dimensional vector space. Composed of (n+1)*(n+2)/2 functions: 1, x_1, ..., x_n, 0.5*x_1^2, 0.5*x_2^2, ..., 0.5*x_n^2, x_1*x_2, x_1*x_3, ..., x_1*x_n, ..., x_2*x_3, ..., x_2*x_n, ..., ..., x_n-1*x_n.

$A Igor xx Apr10;

Constructor & Destructor Documentation

IG.Num.QuadraticBasis.QuadraticBasis ( )
inlineprivate
IG.Num.QuadraticBasis.QuadraticBasis ( int  dimension)
inline

Constructs a vector function containing quadratic basis for the specified dimension. Composed of (n+1)*(n+2)/2 functions: 1, x_1, ..., x_n, 0.5*x_1^2, 0.5*x_2^2, ..., 0.5*x_n^2, x_1*x_2, x_1*x_3, ..., x_1*x_n, ..., x_2*x_3, ..., x_2*x_n, ..., ..., x_n-1*x_n.

Parameters
dimensionSpace dimension.

Member Function Documentation

static int IG.Num.QuadraticBasis.NumQuadraticBasisFunctions ( int  dimension)
inlinestatic

Returns number of basis functions in quadratic polynomial basis of the specified dimenson. This is a helper method.

Parameters
dimensionDimension of the space in which linear polynomial basis functions are calculated.
int [] IG.Num.QuadraticBasis.GetFunctionDefinition ( int  which)
inline

Returns a table of indices defining the specified function of the quadratic basis. Table contains up to two indices of variables whose product represents the specific basis function. [] (empty array) means constant term, [1] means x1, [2] means x2, [1,1] means x1^2, [2,2] means x2^2, [1,2] means x1*x2, [3,5] means x4*x5, etc.

Parameters
which
Returns
void IG.Num.QuadraticBasis.GetFunctionDefinition ( int  which,
out int  numTerms,
out int  firstVariableIndex,
out int  secondVariableIndex 
)
inline

Returns data about the specific function of this vector function containing quadratic basis. Examples: numTerms = 0: constant (1) numTerms = 1: linear terms, firstVariableIndex is index of the variable. numTerms = 2: quadratic terms, firstVariableIndex and secondVariableIndex are indices of variables whose product gives this basis function.

Parameters
whichSpecifies the function whose definition is queried.
numTermsReturns number of terms in the product that defines the function (0 for constant, 1 for linear terms, 2 for quadratic terms)
firstVariableIndexReturns index of the first variable in the product. If 0 then the specific function is constant.
secondVariableIndexReturns index of the second variable in the product. If 0 then the specific function is linear or constant.
int IG.Num.QuadraticBasis.GetConstantTermIndex ( )
inlineprivate

Returns index of the constant function in this quadratic basis.

int IG.Num.QuadraticBasis.GetLinearTermIndex ( int  varIndex)
inlineprivate

Returns index of the specified linear function in this quadratic basis.

Parameters
varIndexSpecifies which linear term to return.
int IG.Num.QuadraticBasis.GetQuadraticTermIndex ( int  varIndex1,
int  varIndex2 
)
inlineprivate

Returns index of the specified quadratic function in this quadratic basis. Order of indices specifying the term is not important.

Parameters
varIndex1Index of the first variable in the product.
varIndex2Index of the second variable of the product.
override double IG.Num.QuadraticBasis.Value ( IVectorFunctionResults  evaluationData,
int  which 
)
inlinevirtual

Calculates and returns the particular component of the vector function value.

Parameters
evaluationDataEvaluation data that contains function parameters and can store function resuts. If the function does not support component-wise evaluation then results will be stored to this structure and returned from it. This makes reuse possible - when different components are evaluated subsequently with the same parameters, results are calculated only for the first time.
whichSpecifies which function to evaluate.

Implements IG.Num.VectorFunctionBaseComponentWise.

Reimplemented in IG.Num.QuadraticBasisSafer.

References IG.Num.IVectorFunctionResults.Parameters.

override double IG.Num.QuadraticBasis.Derivative ( IVectorFunctionResults  evaluationData,
int  which,
int  component 
)
inlinevirtual

Calculates and returns the particular component of the vector function's derivative.

Parameters
evaluationDataEvaluation data that contains function parameters and can store function resuts. Not used in this class, can be null.
whichSpecifies which function to take.
componentSpecifies which compoonent of the gradient should be returned.

Implements IG.Num.VectorFunctionBaseComponentWise.

Reimplemented in IG.Num.QuadraticBasisSafer.

References IG.Num.IVectorFunctionResults.Parameters.

override double IG.Num.QuadraticBasis.SecondDerivative ( IVectorFunctionResults  evaluationData,
int  which,
int  rowNum,
int  columnNum 
)
inlinevirtual

Calculates and returns the particular component of the vector function's second derivative (Hessian).

Parameters
evaluationDataEvaluation data that contains function parameters and can store function resuts. Not used in this class, can be null.
whichSpecifies which function to take.
rowNumSpecifies which row of the Hessian (matrix of second derivatives) should be returned.
columnNumSpecifies which column of the Hessian (matrix of second derivatives) should be returned.

Implements IG.Num.VectorFunctionBaseComponentWise.

Reimplemented in IG.Num.QuadraticBasisSafer.

References IG.Num.IVectorFunctionResults.Parameters.

static void IG.Num.QuadraticBasis.Example ( )
inlinestatic

Example for this class, just runs examples form the LinearBasis class.

References IG.Num.LinearBasis.Example().

Member Data Documentation

int [][] IG.Num.QuadraticBasis.functionDefinitions
protected

Definitions of basis functions. Each definition is an array of at most 2 indices specifying the product of which variables (zero-base) is a specific function. At index 0, length of array is 0. At indices 1 through n+1 it is 1 (linear terms), and at remaining indices it is 2.

int [,] IG.Num.QuadraticBasis.quatraticTerms
protected

2D table of indices specifying for each quadratic term which function it corresponds to (since up to quadratic terms this is trivial).


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