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

Cubic function, f(x) = a3*x*x*x + a2*x*x + a1*x + a0. Specific properties: Zero - returns a zero. Zero1 - returns the fierst zero. Zero2 - returns the second zero. Zero3 - returns the third zero. NumZeros - returns number of zeros (0, 1 or 3). HasZero - either the function has a zero or not. Min - returns function's strict minimum. Max - returns function's strict maximum. More...

+ Inheritance diagram for IG.Num.Func.Cubic:
+ Collaboration diagram for IG.Num.Func.Cubic:

Public Member Functions

 Cubic (double a3, double a2, double a1, double a0)
 Creates a cubic function, coefficients are specified in the descending order. More...
 
void SetCoefficients (double a3, double a2, double a1, double a0)
 Sets coefficients of the cubic function represented by the current object. More...
 
void SetInterpolation (double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
 Initializes the cubic interpolation function with specified four function values. More...
 
void SetInterpolation (double x1, double y1, double d1, double x2, double y2, double d2)
 Initializes the cubic interpolation function with specified two function values and one derivative. More...
 
int Zeros (out double x1, out double x2, out double x3)
 Calculates and returns real zeros of the function. Also returns the number of real zeros (0, 1 or 3). More...
 
override bool HigherDerivativeDefined (int order)
 Tells whether the derivative of the given order is defined for this function (by implementation, not mathematically) More...
 
- Public Member Functions inherited from IG.Num.RealFunction
 RealFunction (DlgFunctionValue valueDelegate)
 Constructs a new function where delegates are provided for calculation of function valu. More...
 
 RealFunction (DlgFunctionValue valueDelegate, DlgFunctionValue derivativeDelegate)
 Constructs a new function where delegates are provided for calculation of function valu and first derivative. More...
 
 RealFunction (DlgFunctionValue valueDelegate, DlgFunctionValue derivativeDelegate, DlgFunctionValue secondDerivativeDelegate)
 
 RealFunction (DlgFunctionValue valueDelegate, DlgFunctionValue derivativeDelegate, DlgFunctionValue secondDerivativeDelegate, DlgFunctionValue integralDelegate)
 Constructs a new function where delegates are provided for calculation of function value, derivatives and integral. More...
 
 RealFunction (DlgFunctionValue valueDelegate, DlgFunctionValue derivativeDelegate, DlgFunctionValue secondDerivativeDelegate, DlgFunctionValue integralDelegate, DlgFunctionValue inverseDelegate)
 Constructs a new function where delegates are provided for calculation of function value, derivatives, integral and inverse. More...
 
 RealFunction (DlgFunctionValue valueDelegate, DlgFunctionValue derivativeDelegate, DlgFunctionValue secondDerivativeDelegate, DlgFunctionHigherDerivative higherDerivativeDelegate, DlgFunctionValue integralDelegate, DlgFunctionValue inverseDelegate)
 Constructs a new function where delegates are provided for calculation of function value, derivatives, integral and inverse. More...
 
RealFunction CloneFunction ()
 
object Clone ()
 
double TransformedArgument (double t)
 
double InverseTransformedArgument (double x)
 
virtual void SetTransformationParameters (double kx, double sx, double ky, double sy)
 Sets parameters of the affine transformation parameters for both co-ordinates. More...
 
virtual void SetXTransformationParameters (double kx, double sx)
 Sets parameters of the affine transformation parameters for independent variable. More...
 
override double Value (double x)
 Returns the value of this function at the specified parameter. More...
 
override double Derivative (double x)
 Returns the first derivative of this function at the specified parameter. More...
 
override double Derivative (double x, int order)
 Returns the derivative of the given order of this function at the specified parameter. More...
 
override bool HigherDerivativeDefined (int order)
 Tells whether the derivative of the given order is defined for this function (by implementation, not mathematically). Returns true if either the internal variable indicates true or the appropriate delegate is non-null. More...
 
override double SecondDerivative (double x)
 Returns the second derivative of the given order of this function at the specified arameter. More...
 
override double Integral (double x)
 Returns definite integral of the current function from 0 to the function argument. More...
 
override double Inverse (double y)
 Returns value of the inverse of the current function at the specified value of dependent variable. More...
 
- Public Member Functions inherited from IG.Num.RealFunctionBase
void Tabulate (double from, double to, int numPoints)
 Tabulates the current function and its first and second derivatives (when available) on the specified interval, in the specified number of points. More...
 
void Tabulate (double from, double to, int numPoints, bool printDerivatives)
 Tabulates the current function and its first and eventually second derivatives (when available) on the specified interval, in the specified number of points. More...
 
void Tabulate (double from, double to, int numPoints, bool printDerivatives, bool printSecondDerivatives)
 Tabulates the current function and eventually its first and second derivatives (when available) on the specified interval, in the specified number of points. More...
 
virtual double NumericalIntegral (double from, double to, int numintervals)
 Calculates numerical integral of this function. Simpson's formula is used. More...
 
virtual double NumericalDerivative (double x, double stepsize)
 Calculates numerical derivative of this function. Central difference formula is used. More...
 
virtual double NumericalSecondDerivative (double x, double stepsize)
 Calculates numerical second order derivative of this function. Central difference formula is used. More...
 
virtual void Test ()
 Performs numerical tests with parameters adjusted for specific function. This function can be be overridden in derived classes, however its current implementation may be relatively well suited for most weighting and basic functions. More...
 
virtual void Test (double from, double to, int numProbes, double stepSize, double tolerance)
 Performs some numerical tests on the current function, such as correctness of first and second derivatives, integral and inverse of the function. Results are written to the standard output. Whenever a numerical result does not match the corresponding analytical value calculated by the function, a visible notification is written. More...
 
override string ToString ()
 

Protected Member Functions

override double RefValue (double x)
 Returns the value of reference (untransformed) function. More...
 
override double RefDerivative (double x)
 Returns the first derivative of reference (untransformed) function. More...
 
override double RefSecondDerivative (double x)
 Returns the second derivative of the given order of reference (untransformed) function. More...
 
override double RefDerivative (double x, int order)
 Returns the derivative of the given order of reference (untransformed) function. More...
 
override double RefIntegral (double x)
 Returns definite integral of reference (untransformed) function from 0 to the function argument. More...
 
override double RefInverse (double y)
 Returns inverse of the reference (untransformed) function. More...
 
- Protected Member Functions inherited from IG.Num.RealFunction
 RealFunction ()
 

Protected Attributes

double _a0
 
- Protected Attributes inherited from IG.Num.RealFunction
bool _valueDefined = false
 
bool _derivativeDefined = false
 
int _highestDerivativeDefined = 0
 
bool _secondDerivativeDefined = false
 
bool _integralDefined = false
 
bool _inverseDefined = false
 
- Protected Attributes inherited from IG.Num.RealFunctionBase
string _name
 
string _description
 

Properties

object Lock [get]
 This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. More...
 
double a0 [get, protected set]
 Returns the constant term coefficient of the cubic function. More...
 
double a1 [get, protected set]
 Returns the linear term coefficitne of the cubic function. More...
 
double a2 [get, protected set]
 Returns the quadratic term coefficitne of the cubic function. More...
 
double a3 [get, protected set]
 Returns the cubic term coefficitne of the cubic function. More...
 
Quadratic RefQuad [get]
 
double Zero [get]
 Returns the first zero of the current cubic function. Throws InvalidOperationException if the function does not have real zeros. More...
 
double Zero1 [get]
 Returns the first zero of the current cubic function. Throws InvalidOperationException if the function does not have real zeros. More...
 
double Zero2 [get]
 Returns the second zero of the current cubic function. Throws InvalidOperationException if the function does not have two distinct real zeros. More...
 
double Zero3 [get]
 Returns the third zero of the current cubic function. Throws InvalidOperationException if the function does not have three distinct real zeros. More...
 
bool HasZero [get]
 Returns true if this cubic function has at least one real zero, false otherwise. More...
 
int NumZeros [get]
 Returns number of zeros of the current cubic function. More...
 
bool HasMaximum [get]
 Returns true if this cubic function has a strict maximum. More...
 
double Maximum [get]
 Gets strict maximum of this cubic function. If the function does not have one then exeption is thrown. More...
 
bool HasMinimum [get]
 Returns true if this cubic function has a strict minimum. More...
 
double Minimum [get]
 Gets strict minimum of this cubic function. If the function does not have one then exeption is thrown. More...
 
override bool ValueDefined [get, set]
 
override bool DerivativeDefined [get, set]
 
override bool SecondDerivativeDefined [get, set]
 
override bool IntegralDefined [get, set]
 
Cubic RefInv [get]
 
override bool InverseDefined [get, set]
 
- Properties inherited from IG.Num.RealFunction
override string Name [get, set]
 Returns a code name of the function (not necessarily unique). More...
 
override string Description [get, set]
 Returns a short description of the function (not necessarily unique). More...
 
override RealFunctionBase DerivativeFunction [get]
 Returns a function that represents a derivative of the current function. More...
 
override RealFunctionBase InverseFunction [get]
 Returns a function that represents inverse of the current function. More...
 
override RealFunctionBase IntegralFunction [get]
 Returns a function that represents definite integral of the current function from 0 to function argument. More...
 
bool DoTransform [get, private set]
 Whether or not transformation (stretch/shift) is applied to the reference function, either in x or to y. Setter sets value both for transformation in X and Y direction. More...
 
bool TransformX [get, private set]
 Whether or not reference function is stretched/shifted in x direction. More...
 
bool TransformY [get, private set]
 Whether or not reference function is stretched/shifted in x direction. More...
 
double ScaleX [get, set]
 Gets or sets the scaling factor for independent variable. More...
 
double ShiftX [get, set]
 Gets or sets the shift of independent variable. More...
 
double ScaleY [get, set]
 Gets or sets the scaling factor for function value. More...
 
double ShiftY [get, set]
 Gets or sets the shift for function value. More...
 
override bool ValueDefined [get, set]
 Tells whether value of the function is defined by implementation. Getter returns true if internal flag is set OR appropriate delegate is defined. Setter sets the internal flag (i.e. delegate must also be set to null if getter should return false). More...
 
override bool DerivativeDefined [get, set]
 Tells whether the first derivative is defined for this function (by implementation, not mathematically). Getter returns true if internal flag is set OR appropriate delegate is defined. Setter sets the internal flag (i.e. delegate must also be set to null if getter should return false). More...
 
override bool SecondDerivativeDefined [get, set]
 Tells whether the second derivative is defined for this function (by implementation, not mathematically). Getter returns true if internal flag is set OR appropriate delegate is defined. Setter sets the internal flag (i.e. delegate must also be set to null if getter should return false). More...
 
override bool IntegralDefined [get, set]
 Indicates whether integral is defined for this function (w.r. implementation). Getter returns true if internal flag is set OR appropriate delegate is defined. Setter sets the internal flag (i.e. delegate must also be set to null if getter should return false). More...
 
override bool InverseDefined [get, set]
 Indicates whether inverse is defined for this function (w.r. implementation). Getter returns true if internal flag is set OR appropriate delegate is defined. Setter sets the internal flag (i.e. delegate must also be set to null if getter should return false). More...
 
- Properties inherited from IG.Num.RealFunctionBase
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...
 
virtual RealFunctionBase DerivativeFunction [get]
 Returns a function object that represents a derivative of this function. Returns null if this is not implemented. More...
 
virtual RealFunctionBase IntegralFunction [get]
 Returns a function object that represents a definite integral of this function from 0 to 1. Returns null if not implemented. More...
 
virtual RealFunctionBase InverseFunction [get]
 Returns a function object that represents an inverse function of this function. Returns null if not implemented. More...
 
abstract bool ValueDefined [get, set]
 Tells whether value of the function is defined by implementation. More...
 
abstract bool DerivativeDefined [get, set]
 Tells whether the first derivative is defined for this function (by implementation, not mathematically) More...
 
abstract bool SecondDerivativeDefined [get, set]
 Tells whether the second derivative is defined for this function (by implementation, not mathematically) More...
 
abstract bool IntegralDefined [get, set]
 Tells whether analytical itegral of the function is defined or not. More...
 
abstract bool InverseDefined [get, set]
 Tells whether analytical inverse function is defined or not. More...
 
- Properties inherited from IG.Num.IRealFunction
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 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 IntegralDefined [get]
 Tells whether analytical itegral of the function is defined or not. More...
 
bool InverseDefined [get]
 Tells whether analytical inverse function is defined or not. More...
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

Private Member Functions

int Extremes (ref double x1, ref double y1, ref double d1, ref double x2, ref double y2, ref double d2)
 Calculates and returns extremes of the cubic function, and returns number of extremes. More...
 

Private Attributes

object _mainLock = new object()
 
double _a1
 
double _a2
 
double _a3
 
Quadratic _refquad
 
Cubic _refinv
 

Additional Inherited Members

- Static Public Member Functions inherited from IG.Num.RealFunction
static void TestSpeed ()
 Compares calculation times of three ways of evaluations of exponential function: directly by Math.Exp(), through a delegate initialized by this function, and through a Function object initialized by this function. The number of repetitions is pre-defined. More...
 
static void TestSpeed (long numiterations)
 Compares calculation times of three ways of evaluations of exponential function: directly by Math.Exp(), through a delegate initialized by this function, and through a Function object initialized by this function. More...
 
- Static Public Member Functions inherited from IG.Num.RealFunctionBase
static void ExampleTests ()
 

Detailed Description

Cubic function, f(x) = a3*x*x*x + a2*x*x + a1*x + a0. Specific properties: Zero - returns a zero. Zero1 - returns the fierst zero. Zero2 - returns the second zero. Zero3 - returns the third zero. NumZeros - returns number of zeros (0, 1 or 3). HasZero - either the function has a zero or not. Min - returns function's strict minimum. Max - returns function's strict maximum.

Constructor & Destructor Documentation

IG.Num.Func.Cubic.Cubic ( double  a3,
double  a2,
double  a1,
double  a0 
)
inline

Creates a cubic function, coefficients are specified in the descending order.

Parameters
a3cubic term coefficitnt.
a2quadratic term coefficient.
a1linear term coefficient.
a0constant term coefficient.

Member Function Documentation

void IG.Num.Func.Cubic.SetCoefficients ( double  a3,
double  a2,
double  a1,
double  a0 
)
inline

Sets coefficients of the cubic function represented by the current object.

Parameters
a3cubic term coefficient.
a2quadratic term coeficient.
a1linear term coefficient.
a0constant term coefficient.
void IG.Num.Func.Cubic.SetInterpolation ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3,
double  x4,
double  y4 
)
inline

Initializes the cubic interpolation function with specified four function values.

Parameters
x1Abscissa of the first point.
y1Value at the first point.
x2Abscissa of the second point.
y2Value at the second point.
x3Abscissa of the third point.
y3Value at the third point.
x4Abscissa of the third point.
y4Value at the third point.

Referenced by IG.Num.Func.GetCubicInterpolation().

void IG.Num.Func.Cubic.SetInterpolation ( double  x1,
double  y1,
double  d1,
double  x2,
double  y2,
double  d2 
)
inline

Initializes the cubic interpolation function with specified two function values and one derivative.

Parameters
x1Abscissa of the first point.
y1Value at the first point.
d1Derivative at the first point.
x2Abscissa of the second point.
y2Value at the second point.
d2Derivative at the second point.
int IG.Num.Func.Cubic.Zeros ( out double  x1,
out double  x2,
out double  x3 
)
inline

Calculates and returns real zeros of the function. Also returns the number of real zeros (0, 1 or 3).

Parameters
x1The first zero (output parameter).
x2The second zero (output parameter).
x3The third real zero (output parameter).
Returns
Number of distinct real zeros.

References IG.Num.M.arch(), IG.Num.M.arsh(), and IG.Num.s.

int IG.Num.Func.Cubic.Extremes ( ref double  x1,
ref double  y1,
ref double  d1,
ref double  x2,
ref double  y2,
ref double  d2 
)
inlineprivate

Calculates and returns extremes of the cubic function, and returns number of extremes.

Parameters
x1Abscissa of the first extreme.
y1Value in the first extreme.
d1Second derivative in the first extreme.
x2Abscissa of the first extreme.
y2Function value in the first extreme.
d2Second derivative in the first extreme.
Returns
override double IG.Num.Func.Cubic.RefValue ( double  x)
inlineprotectedvirtual

Returns the value of reference (untransformed) function.

Reimplemented from IG.Num.RealFunction.

override double IG.Num.Func.Cubic.RefDerivative ( double  x)
inlineprotectedvirtual

Returns the first derivative of reference (untransformed) function.

Reimplemented from IG.Num.RealFunction.

override double IG.Num.Func.Cubic.RefSecondDerivative ( double  x)
inlineprotectedvirtual

Returns the second derivative of the given order of reference (untransformed) function.

Reimplemented from IG.Num.RealFunction.

override double IG.Num.Func.Cubic.RefDerivative ( double  x,
int  order 
)
inlineprotectedvirtual

Returns the derivative of the given order of reference (untransformed) function.

Reimplemented from IG.Num.RealFunction.

override bool IG.Num.Func.Cubic.HigherDerivativeDefined ( int  order)
inline

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

Implements IG.Num.IRealFunction.

override double IG.Num.Func.Cubic.RefIntegral ( double  x)
inlineprotectedvirtual

Returns definite integral of reference (untransformed) function from 0 to the function argument.

Reimplemented from IG.Num.RealFunction.

override double IG.Num.Func.Cubic.RefInverse ( double  y)
inlineprotectedvirtual

Returns inverse of the reference (untransformed) function.

Reimplemented from IG.Num.RealFunction.

Member Data Documentation

object IG.Num.Func.Cubic._mainLock = new object()
private
double IG.Num.Func.Cubic._a0
protected
double IG.Num.Func.Cubic._a1
private
double IG.Num.Func.Cubic._a2
private
double IG.Num.Func.Cubic._a3
private
Quadratic IG.Num.Func.Cubic._refquad
private
Cubic IG.Num.Func.Cubic._refinv
private

Property Documentation

object IG.Num.Func.Cubic.Lock
get

This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.

double IG.Num.Func.Cubic.a0
getprotected set

Returns the constant term coefficient of the cubic function.

double IG.Num.Func.Cubic.a1
getprotected set

Returns the linear term coefficitne of the cubic function.

double IG.Num.Func.Cubic.a2
getprotected set

Returns the quadratic term coefficitne of the cubic function.

double IG.Num.Func.Cubic.a3
getprotected set

Returns the cubic term coefficitne of the cubic function.

Quadratic IG.Num.Func.Cubic.RefQuad
getprotected
double IG.Num.Func.Cubic.Zero
get

Returns the first zero of the current cubic function. Throws InvalidOperationException if the function does not have real zeros.

double IG.Num.Func.Cubic.Zero1
get

Returns the first zero of the current cubic function. Throws InvalidOperationException if the function does not have real zeros.

double IG.Num.Func.Cubic.Zero2
get

Returns the second zero of the current cubic function. Throws InvalidOperationException if the function does not have two distinct real zeros.

double IG.Num.Func.Cubic.Zero3
get

Returns the third zero of the current cubic function. Throws InvalidOperationException if the function does not have three distinct real zeros.

bool IG.Num.Func.Cubic.HasZero
get

Returns true if this cubic function has at least one real zero, false otherwise.

int IG.Num.Func.Cubic.NumZeros
get

Returns number of zeros of the current cubic function.

bool IG.Num.Func.Cubic.HasMaximum
get

Returns true if this cubic function has a strict maximum.

double IG.Num.Func.Cubic.Maximum
get

Gets strict maximum of this cubic function. If the function does not have one then exeption is thrown.

bool IG.Num.Func.Cubic.HasMinimum
get

Returns true if this cubic function has a strict minimum.

double IG.Num.Func.Cubic.Minimum
get

Gets strict minimum of this cubic function. If the function does not have one then exeption is thrown.

override bool IG.Num.Func.Cubic.ValueDefined
getset
override bool IG.Num.Func.Cubic.DerivativeDefined
getset
override bool IG.Num.Func.Cubic.SecondDerivativeDefined
getset
override bool IG.Num.Func.Cubic.IntegralDefined
getset
Cubic IG.Num.Func.Cubic.RefInv
getprotected
override bool IG.Num.Func.Cubic.InverseDefined
getset

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