CAPD::DynSys Library  6.0.0
capd::map::BasicFunction< Scalar > Class Template Reference

This class is a basic for further protected inheritance to classes Function, Map ... More...

#include <capd/map/BasicFunction.h>

Public Types

typedef Scalar ScalarType
 
typedef capd::autodiff::DagIndexer< ScalarTypeDAG
 
typedef DAG::size_type size_type
 
typedef capd::autodiff::Node NodeType
 

Public Member Functions

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 Scalar &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 Scalar *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 ScalarTypegetCurrentTime () 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...
 
template<class Iterator >
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

 BasicFunction ()
 creates an univariate constant function f(x)=0 More...
 
 BasicFunction (const std::string &s)
 parses expression from given string. More...
 
 BasicFunction (const char *s)
 parses expression from given string. More...
 
 BasicFunction (const BasicFunction &f)
 copying constructor More...
 
template<typename Function >
 BasicFunction (Function f, int dimIn, int dimOut, int noParam)
 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...
 
virtual ~BasicFunction ()
 virtual destructor - releases memory allocated for DAG representing function, map or vector field More...
 
void operator= (const std::string &)
 substitution from string. Parses expression and compute new DAG. More...
 
void operator= (const char *)
 substitution from string. Parses expression and compute new DAG. More...
 
void operator= (const BasicFunction &)
 assignment from another object More...
 
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...
 
template<class V >
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

std::vector< capd::autodiff::AbstractNode< ScalarType > * > m_nodes
 
std::vector< capd::autodiff::Nodem_fullGraph
 graph representing the expression More...
 
std::vector< capd::autodiff::MyNodem_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...
 

Detailed Description

template<typename Scalar>
class capd::map::BasicFunction< Scalar >

This class is a basic for further protected inheritance to classes Function, Map ...

It provides constructors and methods common for all inherited classes. In particular

  • parsing expressions from a string
  • parsing expressions from routines and computing DAGs
  • memory management
  • setting parameters in expressions
  • evaluation of DAG
Attention
The class is for inheritance only and is mainly written to avoid code redundancy. It is for developers of the library only. Users of the CAPD library should not use this class directly in own programs.

Member Typedef Documentation

◆ DAG

template<typename Scalar >
typedef capd::autodiff::DagIndexer<ScalarType> capd::map::BasicFunction< Scalar >::DAG

◆ NodeType

template<typename Scalar >
typedef capd::autodiff::Node capd::map::BasicFunction< Scalar >::NodeType

◆ ScalarType

template<typename Scalar >
typedef Scalar capd::map::BasicFunction< Scalar >::ScalarType

◆ size_type

template<typename Scalar >
typedef DAG::size_type capd::map::BasicFunction< Scalar >::size_type

Constructor & Destructor Documentation

◆ BasicFunction() [1/5]

template<typename Scalar >
capd::map::BasicFunction< Scalar >::BasicFunction
protected

creates an univariate constant function f(x)=0

◆ BasicFunction() [2/5]

template<typename Scalar >
capd::map::BasicFunction< Scalar >::BasicFunction ( const std::string &  s)
protected

parses expression from given string.

◆ BasicFunction() [3/5]

template<typename Scalar >
capd::map::BasicFunction< Scalar >::BasicFunction ( const char *  s)
protected

parses expression from given string.

◆ BasicFunction() [4/5]

template<typename Scalar >
capd::map::BasicFunction< Scalar >::BasicFunction ( const BasicFunction< Scalar > &  f)
protected

copying constructor

◆ BasicFunction() [5/5]

template<typename Scalar >
template<typename Function >
capd::map::BasicFunction< Scalar >::BasicFunction ( Function  f,
int  dimIn,
int  dimOut,
int  noParam 
)
inlineprotected

parses expression from given routine.

Allocates memory for jet propagation of degree 'degree'

Parameters
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

◆ ~BasicFunction()

template<typename Scalar >
virtual capd::map::BasicFunction< Scalar >::~BasicFunction ( )
inlineprotectedvirtual

virtual destructor - releases memory allocated for DAG representing function, map or vector field

Member Function Documentation

◆ addMultiindexToMask()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::addMultiindexToMask ( const capd::vectalg::Multiindex mi)
inline

Adds new multiindex (along with dependencies) to the existing mask.

Parameters
mimultiindex to be added to the mask
Warning
causes undefined behavior if the mask has not been set before call to this method.

◆ applyC1Mask()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::applyC1Mask
protected

◆ clean()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::clean
protected

resets all allocated data

◆ copyObject()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::copyObject ( const BasicFunction< Scalar > &  f)
protected

an auxiliary function used in copying constructor and assignment operator

◆ createDefault()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::createDefault
protected

used to create a default object without expression. Creates a univariate constant function f(x)=0

◆ createEvalPath()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::createEvalPath
protected

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.

◆ createFromText()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::createFromText ( std::string  s)
protected

parses expression from given string. Allocates memory for ODE solver of order 'order'

◆ deleteNodes()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::deleteNodes
protected

◆ differentiateTime()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::differentiateTime

sets first derivative of time with respect to time equal to 1

◆ dimension()

template<typename Scalar >
size_type capd::map::BasicFunction< Scalar >::dimension ( ) const
inline

returns number of main variables (does not count time and parameters)

◆ eval() [1/2]

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::eval ( size_type  coeffNo) const
inlineprotected

◆ eval() [2/2]

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::eval ( size_type  degree,
size_type  coeffNo 
) const
inlineprotected

◆ evalHomogenousPolynomial() [1/2]

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::evalHomogenousPolynomial ( ) const
inlineprotected

◆ evalHomogenousPolynomial() [2/2]

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::evalHomogenousPolynomial ( size_type  degree,
size_type  coeffNo = 0 
) const
inlineprotected

◆ getCurrentTime()

template<typename Scalar >
const Scalar & capd::map::BasicFunction< Scalar >::getCurrentTime

returns actual value of variable that represents time in an ODE

◆ getMask() [1/3]

template<typename Scalar >
const bool* capd::map::BasicFunction< Scalar >::getMask ( ) const
inline

◆ getMask() [2/3]

template<typename Scalar >
bool capd::map::BasicFunction< Scalar >::getMask ( size_type  i) const
inline

◆ getMask() [3/3]

template<typename Scalar >
bool capd::map::BasicFunction< Scalar >::getMask ( size_type  i,
size_type  j 
) const
inline

◆ getOrder()

template<typename Scalar >
size_type capd::map::BasicFunction< Scalar >::getOrder ( ) const
inline

returns current order of expansion with respect to the time variable

◆ getParameter() [1/2]

template<typename Scalar >
BasicFunction< Scalar >::ScalarType capd::map::BasicFunction< Scalar >::getParameter ( const std::string &  name) const

◆ getParameter() [2/2]

template<typename Scalar >
BasicFunction< Scalar >::ScalarType capd::map::BasicFunction< Scalar >::getParameter ( size_type  d) const

◆ imageDimension()

template<typename Scalar >
size_type capd::map::BasicFunction< Scalar >::imageDimension ( ) const
inline

returns number of functions (dimension of counterdomain)

◆ operator=() [1/3]

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::operator= ( const BasicFunction< Scalar > &  f)
protected

assignment from another object

◆ operator=() [2/3]

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::operator= ( const char *  s)
protected

substitution from string. Parses expression and compute new DAG.

◆ operator=() [3/3]

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::operator= ( const std::string &  s)
protected

substitution from string. Parses expression and compute new DAG.

◆ realloc()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::realloc ( size_type  degree)
protected

reallocates memory for computation of derivatives up to order 'degree'

◆ reset()

template<typename Scalar >
template<typename Function >
void capd::map::BasicFunction< Scalar >::reset ( Function  f,
int  dimIn,
int  dimOut,
int  noParam 
)
protected

parses expression from given routine.

Assignment of new function parsed from a routine.

Allocates memory for jet propagation of degree 'degree'

Parameters
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

◆ resetMask()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::resetMask ( )
inline

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.

◆ setArgument()

template<typename Scalar >
template<class V >
void capd::map::BasicFunction< Scalar >::setArgument ( const V &  v) const
protected

◆ setCurrentTime()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::setCurrentTime ( const ScalarType a_time) const

sets actual value of variable that represents time in an ODE.

◆ setMask()

template<typename Scalar >
template<class Iterator >
void capd::map::BasicFunction< Scalar >::setMask ( Iterator  b,
Iterator  e 
)
inline

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.

Parameters
[b,e)iterator range which contains collection of multiindices
Warning
The method causes undefined behavior if a multiindex in the collection exceeds limits of the map (like dimension, maximal allowed degree).

◆ setOrder()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::setOrder ( size_type  order)

allocates necessary memory for ODE solver of order 'order'

◆ setParameter() [1/2]

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::setParameter ( const std::string &  name,
const ScalarType value 
)

sets new value of a parameter. If parameter not found there is no effect.

◆ setParameter() [2/2]

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::setParameter ( size_type  d,
const Scalar value 
)

sets new value of a parameter of index d.

◆ setParameters()

template<typename Scalar >
void capd::map::BasicFunction< Scalar >::setParameters ( const Scalar values,
size_type  d 
)

simultaneously sets values of many parameters. It is assumed that given vector contains values of subsequent parameters.

Member Data Documentation

◆ m_dag

template<typename Scalar >
DAG capd::map::BasicFunction< Scalar >::m_dag
mutableprotected

data structure that stores all the coefficients. Provides suitable indexing and evaluation of expression.

◆ m_evalPath

template<typename Scalar >
std::vector<capd::autodiff::MyNode> capd::map::BasicFunction< Scalar >::m_evalPath
protected

reduced graph - only nodes with nontrivial evaluations are left

◆ m_fullGraph

template<typename Scalar >
std::vector<capd::autodiff::Node> capd::map::BasicFunction< Scalar >::m_fullGraph
protected

graph representing the expression

◆ m_indexOfFirstParam

template<typename Scalar >
size_type capd::map::BasicFunction< Scalar >::m_indexOfFirstParam
protected

if equal to m_var.size() then no parameters specified

◆ m_nodes

template<typename Scalar >
std::vector<capd::autodiff::AbstractNode<ScalarType>*> capd::map::BasicFunction< Scalar >::m_nodes
protected

◆ m_pos

template<typename Scalar >
std::vector<int> capd::map::BasicFunction< Scalar >::m_pos
protected

indices of roots of expressions for each component

◆ m_var

template<typename Scalar >
std::vector<std::string> capd::map::BasicFunction< Scalar >::m_var
protected

variables, time and parameters


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