CAPD::DynSys Library
6.0.0
|
This class is used to represent a map . More...
#include <capd/map/Map.h>
Public Types | |
typedef MatrixT | MatrixType |
public type: Matrix used in the computations (template parameter) More... | |
typedef MatrixType::RowVectorType | VectorType |
public type: Vector that represent arguments of the map (dimension is equal to number of variables) More... | |
typedef MatrixType::ColumnVectorType | ImageVectorType |
public type: Vector that represent value of the map (dimension is equal to number of functions) More... | |
typedef MatrixType::RefColumnVectorType | RefColumnVectorType |
public type: reference vector that represent value of the map (dimension is equal to number of functions) More... | |
typedef VectorType::ScalarType | ScalarType |
typedef Function< VectorType > | FunctionType |
typedef capd::autodiff::DagIndexer< ScalarType > | DAG |
typedef capd::autodiff::Node | NodeType |
typedef BasicFunction< ScalarType > | BaseFunction |
typedef capd::diffAlgebra::Hessian< ScalarType, ImageVectorType::csDim, VectorType::csDim > | HessianType |
typedef capd::diffAlgebra::Jet< MatrixT, 0 > | JetType |
typedef BaseFunction::size_type | size_type |
Public Member Functions | |
Map () | |
creates an univariate function R->R, f(x)=0 More... | |
Map (const std::string &, size_type degree=1) | |
parses expression from given string. Allocates memory for jet propagation of degree 'degree' More... | |
Map (const char *, size_type degree=1) | |
parses expression from given string. Allocates memory for jet propagation of degree 'degree' More... | |
Map (const Map &f) | |
copying constructor More... | |
template<typename Function > | |
Map (Function f, int dimIn, int dimOut, int noParam, size_type degree=1) | |
parses expression from given routine. More... | |
Map & | operator= (const char *) |
parses expression from a given string and reallocates DAG, does not change already specified degree More... | |
Map & | operator= (const std::string &) |
parses expression from a given string and reallocates DAG, does not change already specified degree More... | |
Map & | operator= (const Map &f) |
assignment from an object More... | |
template<typename Function > | |
void | reset (Function f, int dimIn, int dimOut, int noParam, size_type degree) |
parses expression from given routine. More... | |
template<typename Function > | |
void | reset (Function f, int dimIn, int dimOut, int noParam) |
parses expression from given routine. More... | |
ImageVectorType | operator() (const VectorType &u) const |
evaluates map at a given vector. More... | |
ImageVectorType | operator() (ScalarType t, const VectorType &u) const |
evaluates at a given vector and for given time More... | |
ImageVectorType | operator() (const VectorType &u, MatrixType &out_derivative) const |
computes simultaneously value and derivative of the map for a given vector More... | |
ImageVectorType | operator() (ScalarType t, const VectorType &u, MatrixType &out_derivative) const |
computes simultaneously value and derivative of the map for a given vector and time More... | |
MatrixType | operator[] (const VectorType &u) const |
computes derivative of the map for a given vector More... | |
MatrixType | derivative (const VectorType &u) const |
computes derivative of the map for a given vector More... | |
MatrixType | derivative (ScalarType t, const VectorType &u) const |
computes derivative of the map for a given vector and time More... | |
void | homogenousPolynomial (MatrixType &o_der) const |
Computes derivative of the map at a vector 'u' that was send to any vector or function evaluating value. More... | |
void | homogenousPolynomial (const MatrixType &o_der, HessianType &o_hessian) const |
Computes derivative and hessian of the map at a vector 'u' that was send to any vector or function evaluating value. More... | |
template<class JetT > | |
void | homogenousPolynomial (JetT &x, size_type degree) const |
Computes jet to degree 'degree' of the map at a vector 'u', at which the map was previously evaluated. More... | |
ImageVectorType | operator() (const VectorType &x, MatrixType &out_df, HessianType &out_hf) const |
computes value, first and second order derivatives for a given vector More... | |
ImageVectorType | operator() (ScalarType t, const VectorType &x, MatrixType &out_df, HessianType &out_hf) const |
computes value, first and second order derivatives for a given vector and time More... | |
JetType | operator() (const JetType &x) const |
computes propagation of the jet x through the map and returns jet of normalized partial derivatives of the function . More... | |
JetType | operator() (ScalarType t, const JetType &x) const |
computes propagation of the jet x through the map and returns jet of normalized partial derivatives of the function . More... | |
ImageVectorType | operator() (const VectorType &x, JetType &out_jet) const |
ImageVectorType | operator() (ScalarType t, const VectorType &x, JetType &out_jet) const |
void | computeODECoefficients (VectorType coeffs[], size_type order) const |
iterative computation of Taylor coefficients up to given order for a solution to ODE represented by this map. More... | |
void | computeODECoefficients (VectorType coeffs[], MatrixType dCoeffs[], size_type order) const |
iterative computation of Taylor coefficients up to given order for a solution to ODE represented by this map together with first order variational equations More... | |
void | computeODECoefficients (VectorType coeffs[], MatrixType dCoeffs[], HessianType hCoeffs[], size_type order) const |
iterative computation of Taylor coefficients up to given order for a solution to ODE represented by this map together with first and second order variational equations More... | |
void | computeODECoefficients (JetType coeffs[], size_type degree, size_type order) const |
Iterative computation of Taylor coefficients up to given order for a solution to ODE and its variational equations. More... | |
void | setParameters (const VectorType &values) |
simultaneously sets values of many parameters. It is assumed that given vector contains values of subsequent parameters. More... | |
size_type | degree () const |
returns maximal possible order of space-derivative that the map can compute. Specified by the user in the constructor (default value is 1). More... | |
void | setDegree (size_type degree) |
set maximal order of space-derivatives that the map can compute. More... | |
void | codeTranslation (const char className[], const char userNamespace[], const char relativePath[]=".", size_type maxTimeOrder=32) const |
This method generates code of new class in which DAG is constructed as static array, dimensions are fixed giving the compiler chance for most aggressive optimization. More... | |
size_type | dimension () const |
returns number of main variables (does not count time and parameters) More... | |
size_type | imageDimension () const |
returns number of functions (dimension of counterdomain) More... | |
void | setOrder (size_type) |
allocates necessary memory for ODE solver of order 'order' More... | |
size_type | getOrder () const |
returns current order of expansion with respect to the time variable More... | |
void | setParameter (size_type d, const MatrixT::ScalarType &value) |
sets new value of a parameter of index d. More... | |
void | setParameter (const std::string &name, const ScalarType &value) |
sets new value of a parameter. If parameter not found there is no effect. More... | |
void | setParameters (const MatrixT::ScalarType *values, size_type d) |
simultaneously sets values of many parameters. It is assumed that given vector contains values of subsequent parameters. More... | |
ScalarType | getParameter (size_type d) const |
ScalarType | getParameter (const std::string &name) const |
void | setCurrentTime (const ScalarType &a_time) const |
sets actual value of variable that represents time in an ODE. More... | |
const ScalarType & | getCurrentTime () const |
returns actual value of variable that represents time in an ODE More... | |
void | differentiateTime () const |
sets first derivative of time with respect to time equal to 1 More... | |
void | setMask (Iterator b, Iterator e) |
The iterator range [b,e) should contain a range of Multiinideces the user requires to compute. More... | |
void | addMultiindexToMask (const capd::vectalg::Multiindex &mi) |
Adds new multiindex (along with dependencies) to the existing mask. More... | |
void | resetMask () |
Resets the mask of derivatives. More... | |
const bool * | getMask () const |
bool | getMask (size_type i) const |
bool | getMask (size_type i, size_type j) const |
Protected Member Functions | |
void | generateHeaderFile (const char className[], const char userNamespace[], const char relativePath[], size_type maxTimeOrder=32) const |
void | generateHppFile (const char className[], const char userNamespace[], const char relativePath[], size_type maxTimeOrder=32) const |
void | generateCppFile (const char className[], const char userNamespace[], const char relativePath[], size_type maxTimeOrder=32) const |
void | evalAndCopyResult (JetType &c) const |
void | checkDegree (size_type degree) const |
void | checkOrder (size_type order) const |
void | createDefault () |
used to create a default object without expression. Creates a univariate constant function f(x)=0 More... | |
void | createFromText (std::string s) |
parses expression from given string. Allocates memory for ODE solver of order 'order' More... | |
void | copyObject (const BasicFunction &f) |
an auxiliary function used in copying constructor and assignment operator More... | |
void | clean () |
resets all allocated data More... | |
void | realloc (size_type degree) |
reallocates memory for computation of derivatives up to order 'degree' More... | |
void | createEvalPath () |
creates an evaluation path for the expression. Nodes that do not need evaluation (constants, vars) are removed from DAG of expression. Moreover, evaluation is optimized. More... | |
void | setArgument (const V &v) const |
void | applyC1Mask () const |
void | evalHomogenousPolynomial () const |
void | evalHomogenousPolynomial (size_type degree, size_type coeffNo=0) const |
void | eval (size_type coeffNo) const |
void | eval (size_type degree, size_type coeffNo) const |
void | deleteNodes () |
Protected Attributes | |
size_type | m_degree |
maximal order of derivatives that the map can compute More... | |
std::vector< capd::autodiff::AbstractNode< ScalarType > * > | m_nodes |
std::vector< capd::autodiff::Node > | m_fullGraph |
graph representing the expression More... | |
std::vector< capd::autodiff::MyNode > | m_evalPath |
reduced graph - only nodes with nontrivial evaluations are left More... | |
std::vector< int > | m_pos |
indices of roots of expressions for each component More... | |
std::vector< std::string > | m_var |
variables, time and parameters More... | |
DAG | m_dag |
data structure that stores all the coefficients. Provides suitable indexing and evaluation of expression. More... | |
size_type | m_indexOfFirstParam |
if equal to m_var.size() then no parameters specified More... | |
This class is used to represent a map .
The class provides methods for:
The map is parsed from a human readable string. Syntax of the formula:
Sections par and time are optional.
Dimensions N and M are automatically recognized from the number of variables and functions.
The map can be parsed from a C-like routine. One has to write a global function that defines map and pass it to the constructor. The function that defines a map must have the following signature:
Here:
This class can be used as a vector field defining an ODE. It provides methods for computation of Taylor coefficients of solutions to ODEs and associated variational equations. Although the user can define own ODE solver based on computed coefficients by class Map, we recommend to use class capd::dynsys::BasicTaylor and inherited from it. These classes provide suitable interface for integration of ODEs and variational equations.
About implementation.
Directed acyclic graph (DAG) that encodes a map is stored as well indexed array. Thus processing of it is fast. Moreover, this representation is well suited for:
typedef BasicFunction<ScalarType> capd::map::Map< MatrixT >::BaseFunction |
typedef capd::autodiff::DagIndexer<ScalarType> capd::map::Map< MatrixT >::DAG |
typedef Function<VectorType> capd::map::Map< MatrixT >::FunctionType |
typedef capd::diffAlgebra::Hessian<ScalarType,ImageVectorType::csDim,VectorType::csDim> capd::map::Map< MatrixT >::HessianType |
typedef MatrixType::ColumnVectorType capd::map::Map< MatrixT >::ImageVectorType |
public type: Vector that represent value of the map (dimension is equal to number of functions)
typedef capd::diffAlgebra::Jet<MatrixT,0> capd::map::Map< MatrixT >::JetType |
typedef MatrixT capd::map::Map< MatrixT >::MatrixType |
public type: Matrix used in the computations (template parameter)
typedef capd::autodiff::Node capd::map::Map< MatrixT >::NodeType |
typedef MatrixType::RefColumnVectorType capd::map::Map< MatrixT >::RefColumnVectorType |
public type: reference vector that represent value of the map (dimension is equal to number of functions)
typedef VectorType::ScalarType capd::map::Map< MatrixT >::ScalarType |
typedef BaseFunction::size_type capd::map::Map< MatrixT >::size_type |
typedef MatrixType::RowVectorType capd::map::Map< MatrixT >::VectorType |
public type: Vector that represent arguments of the map (dimension is equal to number of variables)
capd::map::Map< MatrixT >::Map | ( | void | ) |
creates an univariate function R->R, f(x)=0
capd::map::Map< MatrixT >::Map | ( | const std::string & | f, |
size_type | degree = 1 |
||
) |
parses expression from given string. Allocates memory for jet propagation of degree 'degree'
capd::map::Map< MatrixT >::Map | ( | const char * | s, |
size_type | degree = 1 |
||
) |
parses expression from given string. Allocates memory for jet propagation of degree 'degree'
capd::map::Map< MatrixT >::Map | ( | const Map< MatrixT > & | f | ) |
copying constructor
|
inline |
parses expression from given routine.
Allocates memory for jet propagation of degree 'degree'
f | routine that defines function, its signature is: void (NodeType time, NodeType in[], int dimIn, NodeType out[], int dimOut, NodeType param[], int noParam) |
dimIn | number of input variables (dimension of domain) |
dimOut | number of output variables (dimension of codomain) |
noParam | number of parameters |
degree | maximal degree of derivatives that can be computed |
|
inlineinherited |
Adds new multiindex (along with dependencies) to the existing mask.
mi | multiindex to be added to the mask |
|
protectedinherited |
|
inlineprotected |
|
inlineprotected |
|
protectedinherited |
resets all allocated data
void capd::map::Map< MatrixT >::codeTranslation | ( | const char | className[], |
const char | userNamespace[], | ||
const char | relativePath[] = "." , |
||
size_type | maxTimeOrder = 32 |
||
) | const |
This method generates code of new class in which DAG is constructed as static array, dimensions are fixed giving the compiler chance for most aggressive optimization.
This method is used to speed up your computation. DAG that represents an expression is allocated dynamically and thus its processing might be not that fast as in hand optimized code.
[in] | className | - name of the class that will be generated. The code will be generated into file realativePath/className.h. |
[in] | relativePath | - path to folder where generated code will be save |
[in] | userNamespace | - must be specified - the code will be put into this namespace. |
void capd::map::Map< MatrixT >::computeODECoefficients | ( | JetType | coeffs[], |
size_type | degree, | ||
size_type | order | ||
) | const |
Iterative computation of Taylor coefficients up to given order for a solution to ODE and its variational equations.
degree | - The maximal order of derivatives with respect to initial conditions is specified by this argument | |
order | - order of Taylor method (degree of polynomial approximation to the solution) | |
[in,out] | coeffs[0] | - jets of initial conditions for the solution and all variational equations, coeffs[1],...,coeffs[order] - computed coefficients of polynomial approximation to the solution all variational equations |
void capd::map::Map< MatrixT >::computeODECoefficients | ( | VectorType | coeffs[], |
MatrixType | dCoeffs[], | ||
HessianType | hCoeffs[], | ||
size_type | order | ||
) | const |
iterative computation of Taylor coefficients up to given order for a solution to ODE represented by this map together with first and second order variational equations
order | - order of Taylor method (degree of polynomial approximation to the solution) | |
[in] | coeffs[0] | - initial condition for ODE must be the first vector in the table |
[out] | coeffs[1],...,coeffs[order] | - computed coefficients of polynomial approximation |
[in] | dCoeffs[0] | - initial condition for variational equation |
[out] | dCoeffs[1],...,dCoeffs[order] | - computed coefficients of polynomial approximation to the solution to variational equation |
[in] | hCoeffs[0] | - initial condition for second order variational equation |
[out] | hCoeffs[1],...,hCoeffs[order] | - computed coefficients of polynomial approximation to the solution to second order variational equation |
void capd::map::Map< MatrixT >::computeODECoefficients | ( | VectorType | coeffs[], |
MatrixType | dCoeffs[], | ||
size_type | order | ||
) | const |
iterative computation of Taylor coefficients up to given order for a solution to ODE represented by this map together with first order variational equations
order | - order of Taylor method (degree of polynomial approximation to the solution) | |
[in] | coeffs[0] | - initial condition for ODE must be the first vector in the table |
[out] | coeffs[1],...,coeffs[order] | - computed coefficients of polynomial approximation |
[in] | dCoeffs[0] | - initial condition for variational equation |
[out] | dCoeffs[1],...,dCoeffs[order] | - computed coefficients of polynomial approximation to the solution to variational equation |
void capd::map::Map< MatrixT >::computeODECoefficients | ( | VectorType | coeffs[], |
size_type | order | ||
) | const |
iterative computation of Taylor coefficients up to given order for a solution to ODE represented by this map.
order | - order of Taylor method (degree of polynomial approximation to the solution) | |
[in] | coeffs[0] | - initial condition for ODE must be the first vector in the table |
[out] | coeffs[1],...,coeffs[order] | - computed coefficients of polynomial approximation |
|
protectedinherited |
an auxiliary function used in copying constructor and assignment operator
|
protectedinherited |
used to create a default object without expression. Creates a univariate constant function f(x)=0
|
protectedinherited |
creates an evaluation path for the expression. Nodes that do not need evaluation (constants, vars) are removed from DAG of expression. Moreover, evaluation is optimized.
|
protectedinherited |
parses expression from given string. Allocates memory for ODE solver of order 'order'
|
inline |
returns maximal possible order of space-derivative that the map can compute. Specified by the user in the constructor (default value is 1).
|
protectedinherited |
|
inline |
computes derivative of the map for a given vector
|
inline |
computes derivative of the map for a given vector and time
|
inherited |
sets first derivative of time with respect to time equal to 1
|
inlineinherited |
returns number of main variables (does not count time and parameters)
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
protected |
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
protected |
|
protected |
|
protected |
|
inherited |
returns actual value of variable that represents time in an ODE
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
returns current order of expansion with respect to the time variable
|
inherited |
|
inherited |
void capd::map::Map< MatrixT >::homogenousPolynomial | ( | const MatrixType & | o_der, |
HessianType & | o_hessian | ||
) | const |
Computes derivative and hessian of the map at a vector 'u' that was send to any vector or function evaluating value.
In this case computation can be speeded up.
void capd::map::Map< MatrixT >::homogenousPolynomial | ( | JetT & | x, |
size_type | degree | ||
) | const |
Computes jet to degree 'degree' of the map at a vector 'u', at which the map was previously evaluated.
In this case computation can be speeded up.
void capd::map::Map< MatrixT >::homogenousPolynomial | ( | MatrixType & | o_der | ) | const |
Computes derivative of the map at a vector 'u' that was send to any vector or function evaluating value.
In this case computation can be speeded up.
|
inlineinherited |
returns number of functions (dimension of counterdomain)
Map< MatrixT >::JetType capd::map::Map< MatrixT >::operator() | ( | const JetType & | x | ) | const |
computes propagation of the jet x through the map and returns jet of normalized partial derivatives of the function .
Map< MatrixT >::ImageVectorType capd::map::Map< MatrixT >::operator() | ( | const VectorType & | u | ) | const |
evaluates map at a given vector.
Map< MatrixT >::ImageVectorType capd::map::Map< MatrixT >::operator() | ( | const VectorType & | u, |
MatrixType & | out_derivative | ||
) | const |
computes simultaneously value and derivative of the map for a given vector
Map< MatrixT >::ImageVectorType capd::map::Map< MatrixT >::operator() | ( | const VectorType & | x, |
JetType & | out_jet | ||
) | const |
Map< MatrixT >::ImageVectorType capd::map::Map< MatrixT >::operator() | ( | const VectorType & | x, |
MatrixType & | out_df, | ||
HessianType & | out_hf | ||
) | const |
computes value, first and second order derivatives for a given vector
|
inline |
computes propagation of the jet x through the map and returns jet of normalized partial derivatives of the function .
|
inline |
evaluates at a given vector and for given time
|
inline |
computes simultaneously value and derivative of the map for a given vector and time
|
inline |
|
inline |
computes value, first and second order derivatives for a given vector and time
Map< MatrixT > & capd::map::Map< MatrixT >::operator= | ( | const char * | s | ) |
parses expression from a given string and reallocates DAG, does not change already specified degree
Map< MatrixT > & capd::map::Map< MatrixT >::operator= | ( | const Map< MatrixT > & | f | ) |
assignment from an object
Map< MatrixT > & capd::map::Map< MatrixT >::operator= | ( | const std::string & | s | ) |
parses expression from a given string and reallocates DAG, does not change already specified degree
|
inline |
computes derivative of the map for a given vector
|
protectedinherited |
reallocates memory for computation of derivatives up to order 'degree'
|
inline |
parses expression from given routine.
It does not change actual maximal degree of jets that moght be propagated by this map.
f | - routine that defines function, its signature is: void (NodeType time, NodeType in[], int dimIn, NodeType out[], int dimOut, NodeType param[], int noParam) |
dimIn | - number of input variables (dimension of domain) |
dimOut | - number of output variables (dimension of codomain) |
noParam | - number of parameters |
|
inline |
parses expression from given routine.
Allocates memory for jet propagation of degree 'degree'
f | - routine that defines function, its signature is: void (NodeType time, NodeType in[], int dimIn, NodeType out[], int dimOut, NodeType param[], int noParam) |
dimIn | - number of input variables (dimension of domain) |
dimOut | - number of output variables (dimension of codomain) |
noParam | - number of parameters |
|
inlineinherited |
Resets the mask of derivatives.
In consequence, full jet of derivatives will be computed after call to any method that computes derivative, hessian or jet.
|
protectedinherited |
|
inherited |
sets actual value of variable that represents time in an ODE.
void capd::map::Map< MatrixT >::setDegree | ( | size_type | degree | ) |
set maximal order of space-derivatives that the map can compute.
|
inlineinherited |
The iterator range [b,e) should contain a range of Multiinideces the user requires to compute.
The method automatically adds all the depending partial derivatives to this collection and defines a mask for computation of partial derivtives.
[b,e) | iterator range which contains collection of multiindices |
|
inherited |
allocates necessary memory for ODE solver of order 'order'
|
inherited |
sets new value of a parameter. If parameter not found there is no effect.
|
inherited |
sets new value of a parameter of index d.
|
inherited |
simultaneously sets values of many parameters. It is assumed that given vector contains values of subsequent parameters.
void capd::map::Map< MatrixT >::setParameters | ( | const VectorType & | values | ) |
simultaneously sets values of many parameters. It is assumed that given vector contains values of subsequent parameters.
|
mutableprotectedinherited |
data structure that stores all the coefficients. Provides suitable indexing and evaluation of expression.
|
protected |
maximal order of derivatives that the map can compute
|
protectedinherited |
reduced graph - only nodes with nontrivial evaluations are left
|
protectedinherited |
graph representing the expression
|
protectedinherited |
if equal to m_var.size() then no parameters specified
|
protectedinherited |
|
protectedinherited |
indices of roots of expressions for each component
|
protectedinherited |
variables, time and parameters