CAPD::DynSys Library  6.0.0
capd::map Namespace Reference

Functions and Maps. More...

Classes

class  BasicFunction
 This class is a basic for further protected inheritance to classes Function, Map ... More...
 
class  CnCoeffSlice
 
class  Function
 Class Function represents a function $ R^n\to R$. More...
 
class  Map
 This class is used to represent a map $ f:R^N->R^M $. More...
 

Functions

int parseVariables (std::string expression, std::vector< std::string > &var)
 
int parseExpression (std::string &expression, const std::vector< std::string > &vars, std::vector< capd::autodiff::Node > &dag, std::map< std::string, int > &knownNodes)
 a general function that parses expression from a given string. It returns: More...
 
int parseMap (unsigned numberOfVariables, std::string expression, const std::vector< std::string > &var, std::vector< capd::autodiff::Node > &dag, std::vector< int > &pos)
 
size_t parseBrackets (const std::string &e, size_t position)
 return a position of '(' which is paired with the last ')' or 0, when there are not any parentheses More...
 
size_t searchForOperator (const std::string &e, unsigned char op, size_t position=std::string::npos)
 
size_t searchForFunction (const std::string &fun, const std::string &e)
 returns position of arguments of function fun , or 0 if fun does not appear or is an argument for some other function More...
 
bool searchForFunction (const std::string &fun, const std::string &equation, std::string &args)
 Checks if equation is of the form fun(params) More...
 
std::string & removeBrackets (std::string &eq)
 This function removes exterior brackets. More...
 
void splitVariables (const std::string &, const std::string &, std::vector< std::string > &result)
 
bool isConstant (std::string &, double &value)
 
bool stringToDouble (std::string const &text, double &result)
 Converts given text to double (returns true on success) More...
 
void removeWhiteSpaces (std::string &text)
 removes all white spaces from text More...
 
void optimizeDAG (std::vector< capd::autodiff::Node > &dag, std::vector< int > &pos)
 
bool checkPrefix (const std::string &prefix, const std::string &text)
 Checks if text begins with prefix. More...
 
void optimizeMul (std::vector< capd::autodiff::Node > &dag, int left, int right, int i)
 
void optimizeSum (std::vector< capd::autodiff::Node > &dag, int left, int right, int i)
 
void optimizeSub (std::vector< capd::autodiff::Node > &dag, int left, int right, int i)
 
void optimizeDiv (std::vector< capd::autodiff::Node > &dag, int left, int right, int i)
 
void optimizeUnivariateFunction (std::vector< capd::autodiff::Node > &dag, int left, int i, capd::autodiff::NodeType n, capd::autodiff::NodeType nConst, capd::autodiff::NodeType nTime, capd::autodiff::NodeType nFunTime)
 
void optimizePow (std::vector< capd::autodiff::Node > &dag, std::vector< int > &pos, int left, int right, int i)
 

Detailed Description

Functions and Maps.

Function Documentation

◆ checkPrefix()

bool capd::map::checkPrefix ( const std::string &  prefix,
const std::string &  text 
)

Checks if text begins with prefix.

Parameters
prefix
text
Returns
true if text begins with prefix, false otherwise

◆ isConstant()

bool capd::map::isConstant ( std::string &  s,
double &  value 
)

◆ optimizeDAG()

void capd::map::optimizeDAG ( std::vector< capd::autodiff::Node > &  dag,
std::vector< int > &  pos 
)

◆ optimizeDiv()

void capd::map::optimizeDiv ( std::vector< capd::autodiff::Node > &  dag,
int  left,
int  right,
int  i 
)

◆ optimizeMul()

void capd::map::optimizeMul ( std::vector< capd::autodiff::Node > &  dag,
int  left,
int  right,
int  i 
)

◆ optimizePow()

void capd::map::optimizePow ( std::vector< capd::autodiff::Node > &  dag,
std::vector< int > &  pos,
int  left,
int  right,
int  i 
)

◆ optimizeSub()

void capd::map::optimizeSub ( std::vector< capd::autodiff::Node > &  dag,
int  left,
int  right,
int  i 
)

◆ optimizeSum()

void capd::map::optimizeSum ( std::vector< capd::autodiff::Node > &  dag,
int  left,
int  right,
int  i 
)

◆ optimizeUnivariateFunction()

void capd::map::optimizeUnivariateFunction ( std::vector< capd::autodiff::Node > &  dag,
int  left,
int  i,
capd::autodiff::NodeType  n,
capd::autodiff::NodeType  nConst,
capd::autodiff::NodeType  nTime,
capd::autodiff::NodeType  nFunTime 
)

◆ parseBrackets()

size_t capd::map::parseBrackets ( const std::string &  e,
size_t  position = std::string::npos 
)

return a position of '(' which is paired with the last ')' or 0, when there are not any parentheses

◆ parseExpression()

int capd::map::parseExpression ( std::string &  expression,
const std::vector< std::string > &  vars,
std::vector< capd::autodiff::Node > &  dag,
std::map< std::string, int > &  knownNodes 
)

a general function that parses expression from a given string. It returns:

Parameters
[out]vars- vector of variables and parameters
[out]dag- DAG of the expression represented as an array. Each element of the array encodes operation, and index of left and/or right subexpressions.
[out]knownNodes- this is a temporary variable for recursive calls of this function. It contains an array of already recognized subexpression. Used for optimization of DAG.

◆ parseMap()

int capd::map::parseMap ( unsigned  numberOfVariables,
std::string  expression,
const std::vector< std::string > &  var,
std::vector< capd::autodiff::Node > &  dag,
std::vector< int > &  pos 
)

◆ parseVariables()

int capd::map::parseVariables ( std::string  expression,
std::vector< std::string > &  var 
)

◆ removeBrackets()

std::string & capd::map::removeBrackets ( std::string &  eq)

This function removes exterior brackets.

◆ removeWhiteSpaces()

void capd::map::removeWhiteSpaces ( std::string &  text)

removes all white spaces from text

◆ searchForFunction() [1/2]

size_t capd::map::searchForFunction ( const std::string &  fun,
const std::string &  eq 
)

returns position of arguments of function fun , or 0 if fun does not appear or is an argument for some other function

◆ searchForFunction() [2/2]

bool capd::map::searchForFunction ( const std::string &  fun,
const std::string &  equation,
std::string &  args 
)

Checks if equation is of the form fun(params)

Parameters
[in]funfunction name to be searched for
[in]equationwhere to search
[out]argsif equation has form "fun(params)" then on exit it contains "(args)" otherwise it is not changed
Returns
true if equation has correct form, false otherwise

◆ searchForOperator()

size_t capd::map::searchForOperator ( const std::string &  e,
unsigned char  op,
size_t  position = std::string::npos 
)

◆ splitVariables()

void capd::map::splitVariables ( const std::string &  what,
const std::string &  where,
std::vector< std::string > &  result 
)

◆ stringToDouble()

bool capd::map::stringToDouble ( std::string const &  text,
double &  result 
)

Converts given text to double (returns true on success)

Converts given text to double.

Parameters
[in]textdouble number in the C format
[out]resulton success value of converted text, on failure result is not changed
Returns
true on success, false if given text do not contain correct number or contains some additional characters.