CVM Class Library
8.1
This C++ class library encapsulates concepts of vector and different matrices including square, band, symmetric and hermitian ones in Euclidean space of real and complex numbers.
|
End-user class encapsulating elementary function of real or complex numbers (depending on T
type).
More...
#include <cfun.h>
Public Types | |
typedef FunctionFactory< T > ::BasePointer | BasePointer |
Shared pointer to BaseFunction. |
Public Member Functions | |
basic_function () | |
Default constructor. | |
basic_function (const string_array &saVars) | |
Constructor. | |
basic_function (const T &dConst) | |
Constructor. | |
basic_function (const basic_function &rf) | |
Copy Constructor. | |
basic_function (basic_function &&rf) | |
Move Constructor. | |
basic_function (const std::string &sInput) | |
Constructor. | |
basic_function (const string_array &saVars, const std::string &sBody) | |
Constructor. | |
basic_function (const string_array &saVars, const std::string &sBody, const string_array &saParameters, const string_array &saMeanings) | |
Constructor. | |
virtual | ~basic_function () |
Destructor. | |
const string_array & | vars () const |
Variables. | |
size_t | vars_num () const |
Number of variables. | |
T | value (const T *pd) const |
Numerical value. | |
T | operator() (const T *pd) const |
Numerical value. | |
T | operator() (const T &d) const |
Numerical value. | |
T | operator() (const T &d1, const T &d2) const |
Numerical value. | |
T | operator() (const T &d1, const T &d2, const T &d3) const |
Numerical value. | |
T | operator() () const |
Numerical value. | |
std::string | format (int nPrecision=0) const |
Function body as a string. | |
std::string | vformat (int nPrecision=0) const |
Function variables and body as a string. | |
bool | operator== (const basic_function &rf) const |
Functions comparison. | |
bool | operator!= (const basic_function &rf) const |
Functions comparison. | |
basic_function | drv (size_t nVarNum=0) const |
Partial derivative. | |
basic_function & | simp () |
Simplifier. | |
basic_function & | operator= (const basic_function &rfSrc) |
Assignment operator. | |
basic_function & | operator= (basic_function &&rfSrc) |
Move assignment operator. | |
basic_function & | operator= (const T &rdSrc) |
Assignment operator. | |
basic_function | operator- () const |
Unary minus operator. | |
basic_function | operator+ (const basic_function &rf) const throw (cvmexception) |
Addition operator. | |
basic_function | operator- (const basic_function &rf) const throw (cvmexception) |
Subtraction operator. | |
basic_function | operator* (const basic_function &rf) const throw (cvmexception) |
Multiplication operator. | |
basic_function | operator/ (const basic_function &rf) const throw (cvmexception) |
Division operator. | |
basic_function | operator^ (const basic_function &rf) const throw (cvmexception) |
Power to operator. | |
basic_function & | operator+= (const basic_function &rf) throw (cvmexception) |
Increment operator. | |
basic_function & | operator-= (const basic_function &rf) throw (cvmexception) |
Decrement operator. | |
basic_function & | operator*= (const basic_function &rf) throw (cvmexception) |
Multiply and assign operator. | |
basic_function & | operator/= (const basic_function &rf) throw (cvmexception) |
Divide and assign operator. | |
basic_function | operator+ (const T &d) const throw (cvmexception) |
Addition operator. | |
basic_function | operator- (const T &d) const throw (cvmexception) |
Subtraction operator. | |
basic_function | operator* (const T &d) const throw (cvmexception) |
Multiplication operator. | |
basic_function | operator/ (const T &d) const throw (cvmexception) |
Division operator. | |
basic_function | operator^ (const T &d) const throw (cvmexception) |
Power to operator. | |
basic_function & | operator+= (const T &d) throw (cvmexception) |
Increment operator. | |
basic_function & | operator-= (const T &d) throw (cvmexception) |
Decrement operator. | |
basic_function & | operator*= (const T &d) throw (cvmexception) |
Multiply and assign operator. | |
basic_function & | operator/= (const T &d) throw (cvmexception) |
Divide and assign operator. | |
basic_function & | operator^= (const T &d) throw (cvmexception) |
Power to and assign operator. | |
basic_function | sat (const basic_function &rf) const throw (cvmexception) |
Satellite function. | |
basic_function | exp () const |
Exponent. | |
basic_function | sqrt () const |
Square root. | |
basic_function | log () const |
Natural logarithm. | |
basic_function | log10 () const |
Common (base 10) logarithm. | |
basic_function | sin () const |
Sine. | |
basic_function | cos () const |
Cosine. | |
basic_function | tan () const |
Tangent. | |
basic_function | asin () const |
Arcsine. | |
basic_function | acos () const |
Arc cosine. | |
basic_function | atan () const |
Arc tangent. | |
basic_function | sinh () const |
Hyperbolic sine. | |
basic_function | cosh () const |
Hyperbolic cosine. | |
basic_function | tanh () const |
Hyperbolic tangent. | |
basic_function | sinint () const |
Integral sine. | |
basic_function | cosint () const |
Integral cosine. | |
basic_function | sign () const |
Sign. | |
basic_function | abs () const |
Absolute value. | |
basic_function | delta (const basic_function &rf) const throw (cvmexception) |
Delta function. | |
basic_function | iif (const basic_function &rfNeg, const basic_function &rfNotNeg) const throw (cvmexception) |
Immediate If function. |
Protected Attributes | |
string_array | mvars |
Array of variables. | |
BasePointer | mp |
Pointer to function's instance. |
Friends | |
basic_function< T > | operator+ (const T &d, const basic_function< T > &rf) |
Addition operator (left sided) | |
basic_function< T > | operator- (const T &d, const basic_function< T > &rf) |
Subtraction operator (left sided) | |
basic_function< T > | operator* (const T &d, const basic_function< T > &rf) |
Multiplication operator (left sided) | |
basic_function< T > | operator/ (const T &d, const basic_function< T > &rf) |
Division operator (left sided) | |
basic_function< T > | operator^ (const T &d, const basic_function< T > &rf) |
Power to operator (left sided) | |
std::ostream & | operator<< (std::ostream &os, const basic_function &rf) |
Output operator. |
End-user class encapsulating elementary function of real or complex numbers (depending on T
type).
Typically used to convert strings entered by a user to computable expressions without need to parse same expression over and over again. Also might be used to simplify computable expressions and to compute derivatives analytically, i.e. without using numerical methods. Functions can have zero, one or more than one variables and can be parameterized.
typedef FunctionFactory<T>::BasePointer basic_function< T >::BasePointer |
Shared pointer to BaseFunction.
|
inline |
Default constructor.
Creates zero function of no variables.
Definition at line 4975 of file cfun.h.
|
inlineexplicit |
Constructor.
Creates zero function with given list of variables.
[in] | saVars | string_array of variables. |
|
inlineexplicit |
Constructor.
Creates constant number function of no variables.
|
inline |
Copy Constructor.
Creates deep (default) or shallow (if bDeep = false
) copy of a function referred by rf
. Shallow copying is reserved for internal use only.
|
inline |
|
inlineexplicit |
Constructor.
Creates function of one or more variables using Wolfram's Mathemaca syntax {var1[,var2,...]} expr
. Throws cvmexception in case of syntax or memory allocation error.
[in] | sInput | String representing a function as {var1[,var2,...]} expr . For expression syntax look at basic_function description. |
|
inline |
Constructor.
Creates function of one or more variables. Throws cvmexception in case of syntax or memory allocation error.
[in] | saVars | String array with variables (may be empty). |
[in] | sBody | String with function expression. For expression syntax look at basic_function description. |
|
inline |
Constructor.
Creates parameterized function of one or more variables. Throws cvmexception in case of syntax or memory allocation error.
[in] | saVars | String array with variables (may be empty). |
[in] | sBody | String with function expression. For expression syntax look at basic_function description. |
[in] | saParameters | String array with parameters (may be empty). |
[in] | saMeanings | String array with parameters' meanings (may be empty, must have the same size as saParameters). |
|
inlinevirtual |
|
inline |
Variables.
Returns constant referense to array of variables.
Definition at line 5258 of file cfun.h.
|
inline |
|
inline |
Numerical value.
Returns numerical value of function for given values of variables. Array's dimension is not verified.
[in] | pd | Array of variables' values. |
|
inline |
Numerical value.
Returns numerical value of function for given values of variables. Array's dimension is not verified.
[in] | pd | Array of variables' values. |
|
inline |
Numerical value.
Returns numerical value of function for given value of single variable. Result is unpredictable if function is of more than one variable.
[in] | d | Variable's value. |
|
inline |
Numerical value.
Returns numerical value of function for given two variables' values. Result is unpredictable if function is of more than two variables.
[in] | d1 | First variable's value. |
[in] | d2 | Second variable's value. |
|
inline |
Numerical value.
Returns numerical value of function for given three variables' values. Result is unpredictable if function is of more than three variables.
[in] | d1 | First variable's value. |
[in] | d2 | Second variable's value. |
[in] | d3 | Third variable's value. |
|
inline |
Numerical value.
Returns numerical value of function for given zero value of single variable or function of no variables. Result is unpredictable if function is of more than one variable.
|
inline |
Function body as a string.
Returns function body formatted as a string.
[in] | nPrecision | Precision of numbers printed. Zero for auto mode (default). |
|
inline |
Function variables and body as a string.
Returns function variables and body formatted as a string in [{var1,var2,...}] expr
format.
[in] | nPrecision | Precision of numbers printed. Zero for auto mode (default). |
Definition at line 5568 of file cfun.h.
|
inline |
Functions comparison.
Returns true if functions are equal and false otherwise.
[in] | rf | Const reference to function to compare with. |
Definition at line 5606 of file cfun.h.
|
inline |
Functions comparison.
Returns true if functions are equal and false otherwise.
[in] | rf | Const reference to function to compare with. |
Definition at line 5637 of file cfun.h.
|
inline |
Partial derivative.
Creates basic_function object as a partial derivative of calling function. Variables set remains the same even if the derivative doesn't depend on some of them. Partial derivative is computed by nVarNum
's variable (0-based, 0 by default).
[in] | nVarNum | Variable's index (0-based, 0 by default). |
Definition at line 5688 of file cfun.h.
|
inline |
Simplifier.
Simplifies basic_function for fatsest numerical computation possible and returns reference to the object changed.
|
inline |
Assignment operator.
Assigns basic_function object to calling one by performing deep copying. No verifications made, it just copies over and returns reference to the object changed.
[in] | rfSrc | Const reference to function to assign. |
|
inline |
|
inline |
Assignment operator.
Assigns real or complex number to calling basic_function object and makes it to be constant function of variables originally set. Returns reference to the object changed.
[in] | rdSrc | Const reference to number to assign. |
|
inline |
Unary minus operator.
Creates basic_function object as calling function with opposite sign.
Definition at line 5828 of file cfun.h.
|
inline |
Addition operator.
Creates basic_function object as sum of calling function and function referred by rf
. Operator throws cvmexception if lists of variables don't match.
[in] | rf | Const reference to function to add. |
Definition at line 5862 of file cfun.h.
|
inline |
Subtraction operator.
Creates basic_function object as difference of calling function and function referred by rf
. Operator throws cvmexception if lists of variables don't match.
[in] | rf | Const reference to function to subtract. |
Definition at line 5896 of file cfun.h.
|
inline |
Multiplication operator.
Creates basic_function object as product of calling function and function referred by rf
. Operator throws cvmexception if lists of variables don't match.
[in] | rf | Const reference to function to multiply by. |
Definition at line 5934 of file cfun.h.
|
inline |
Division operator.
Creates basic_function object as calling function divided by function referred by rf
. Operator throws cvmexception if lists of variables don't match.
[in] | rf | Const reference to function to divide by. |
Definition at line 5972 of file cfun.h.
|
inline |
Power to operator.
Creates basic_function object as calling function powered to function referred by rf
. Operator throws cvmexception if lists of variables don't match.
[in] | rf | Const reference to function to power to. |
Definition at line 6006 of file cfun.h.
|
inline |
Increment operator.
Adds to calling basic_function function referred by rf
and returns reference to the object changed. Operator throws cvmexception if lists of variables don't match.
[in] | rf | Const reference to function to add. |
|
inline |
Decrement operator.
Subtracts from calling basic_function function referred by rf
and returns reference to the object changed. Operator throws cvmexception if lists of variables don't match.
[in] | rf | Const reference to function to subtract. |
|
inline |
Multiply and assign operator.
Multiplies calling basic_function by function referred by rf
and returns reference to the object changed. Operator throws cvmexception if lists of variables don't match.
[in] | rf | Const reference to function to multiply by. |
|
inline |
Divide and assign operator.
Divides calling basic_function by function referred by rf
and returns reference to the object changed. Operator throws cvmexception if lists of variables don't match.
[in] | rf | Const reference to function to multiply by. |
|
inline |
Addition operator.
Creates basic_function object as sum of calling function and real or complex number referred by d
.
[in] | d | Const reference to number to add. |
Definition at line 6200 of file cfun.h.
|
inline |
Subtraction operator.
Creates basic_function object as difference of calling function and real or complex number referred by d
.
[in] | d | Const reference to number to subtract. |
Definition at line 6227 of file cfun.h.
|
inline |
Multiplication operator.
Creates basic_function object as product of calling function and real or complex number referred by d
.
[in] | d | Const reference to number to multiply by. |
Definition at line 6258 of file cfun.h.
|
inline |
Division operator.
Creates basic_function object as division of calling function by real or complex number referred by d
.
[in] | d | Const reference to number to multiply by. |
Definition at line 6288 of file cfun.h.
|
inline |
Power to operator.
Creates basic_function object as power of calling function to real or complex number referred by d
.
[in] | d | Const reference to number to power to. |
Definition at line 6314 of file cfun.h.
|
inline |
Increment operator.
Adds to calling basic_function real or complex number referred by d
and returns reference to the object changed.
[in] | d | Number to add. |
|
inline |
Decrement operator.
Subtracts from calling basic_function real or complex number referred by d
and returns reference to the object changed.
[in] | d | Number to subtract. |
|
inline |
Multiply and assign operator.
Multiplies calling basic_function by real or complex number referred by d
and returns reference to the object changed.
[in] | d | Number to multiply by. |
|
inline |
Divide and assign operator.
Divides calling basic_function by real or complex number referred by d
and returns reference to the object changed.
[in] | d | Number to divide by. |
|
inline |
Power to and assign operator.
Powers calling basic_function to real or complex number referred by d
and returns reference to the object changed.
[in] | d | Number to power to. |
|
inline |
Satellite function.
Creates basic_function object as satellite of calling basic_function and function referred by rf
. For complex numbers real part is used only. Function throws cvmexception if variables don't match.
[in] | rf | Const reference to other function. |
Definition at line 6540 of file cfun.h.
|
inline |
Exponent.
Creates basic_function object as exponent of calling function.
Definition at line 6570 of file cfun.h.
|
inline |
Square root.
Creates basic_function object as square root of calling function.
Definition at line 6601 of file cfun.h.
|
inline |
Natural logarithm.
Creates basic_function object as natural logarithm of calling function.
Definition at line 6632 of file cfun.h.
|
inline |
Common (base 10) logarithm.
Creates basic_function object as common (base 10) logarithm of calling function.
Definition at line 6663 of file cfun.h.
|
inline |
Sine.
Creates basic_function object as sine of calling function.
Definition at line 6694 of file cfun.h.
|
inline |
Cosine.
Creates basic_function object as cosine of calling function.
Definition at line 6725 of file cfun.h.
|
inline |
Tangent.
Creates basic_function object as tangent of calling function.
Definition at line 6755 of file cfun.h.
|
inline |
Arcsine.
Creates basic_function object as arcsine of calling function.
Definition at line 6785 of file cfun.h.
|
inline |
Arc cosine.
Creates basic_function object as arc cosine of calling function.
Definition at line 6815 of file cfun.h.
|
inline |
Arc tangent.
Creates basic_function object as arc tangent of calling function.
Definition at line 6846 of file cfun.h.
|
inline |
Hyperbolic sine.
Creates basic_function object as hyperbolic sine of calling function.
Definition at line 6877 of file cfun.h.
|
inline |
Hyperbolic cosine.
Creates basic_function object as hyperbolic cosine of calling function.
Definition at line 6908 of file cfun.h.
|
inline |
Hyperbolic tangent.
Creates basic_function object as hyperbolic tangent of calling function.
Definition at line 6939 of file cfun.h.
|
inline |
Integral sine.
Creates basic_function object as integral sine of calling function.
Definition at line 6970 of file cfun.h.
|
inline |
Integral cosine.
Creates basic_function object as integral cosine of calling function.
Definition at line 7001 of file cfun.h.
|
inline |
Sign.
Creates basic_function object as sign of calling function. For complex numbers real part is used only.
Definition at line 7052 of file cfun.h.
|
inline |
Absolute value.
Creates basic_function object as absolute value of calling function.
Definition at line 7091 of file cfun.h.
|
inline |
Delta function.
Creates basic_function object as delta function of calling basic_function and function referred by rf
. For complex numbers real part is used only. Function throws cvmexception if variables don't match.
[in] | rf | Const reference to other function. |
Definition at line 7149 of file cfun.h.
|
inline |
Immediate If function.
Creates basic_function object as Immediate If function of calling basic_function and functions referred by rfNeg
and rfNotNeg
. For complex numbers real part of calling function is used only. Function throws cvmexception if variables don't match.
[in] | rfNeg | Const reference to function for negative calling function value. |
[in] | rfNotNeg | Const reference to function for non-negative calling function value. |
Definition at line 7211 of file cfun.h.
|
friend |
Addition operator (left sided)
Creates basic_function object as sum of real or complex number referred by d
and function referred by rf
.
[in] | d | Const reference to number to add to. |
[in] | rf | Const reference to function to add. |
|
friend |
Subtraction operator (left sided)
Creates basic_function object as difference of real or complex number referred by d
and function referred by rf
.
[in] | d | Const reference to number to subtract from. |
[in] | rf | Const reference to function to subtract. |
|
friend |
Multiplication operator (left sided)
Creates basic_function object as product of real or complex number referred by d
and function referred by rf
.
[in] | d | Const reference to number to multiply. |
[in] | rf | Const reference to function to multiply by. |
|
friend |
Division operator (left sided)
Creates basic_function object as division of real or complex number referred by d
by function referred by rf
.
[in] | d | Const reference to number to divide. |
[in] | rf | Const reference to function to divide by. |
|
friend |
Power to operator (left sided)
Creates basic_function object as power of real or complex number referred by d
to function referred by rf
[in] | d | Const reference to number to power. |
[in] | rf | Const reference to function to power to. |
|
friend |
Output operator.
Prints function referred by rf
to output stream referred by os
using Wolfram's Mathemaca syntax {var1[,var2,...]} expr
.
[in] | os | Reference to output stream. |
[in] | rf | Const reference to function to print. |
|
mutableprotected |
|
protected |