walberla::math::FunctionParser Class Reference

Detailed Description

Function parser, for parsing and evaluating functions.

Can parse mathematical expressions containing the standard arithmetic operations(+,-,/,*) , brackets, functions (cos,sin,exp,sqrt) and variables

After parsing an expression, values can be bound to variables using a symbol table.

Example:

p.parse("(t*t +5) + exp(Pi/2) * sin(cos(1)) ");
std::map<string,double> symbolTable;
symbolTable["Pi"]=3.141;
symbolTable["t"] = 24;
p.evaluate(symbolTable);

#include <Parser.h>

Public Member Functions

 FunctionParser ()
 
 ~FunctionParser ()
 
void parse (const std::string &equation)
 
double evaluate (const std::map< std::string, double > &symbolTable) const
 
const bool & isConstant () const
 
const bool & isZero () const
 
bool symbolExists (const std::string &symbol) const
 

Protected Member Functions

 FunctionParser (const FunctionParser &other)
 
FunctionParseroperator= (const FunctionParser &other)
 

Protected Attributes

exprtk::expression< double > * expression_
 
exprtk::symbol_table< double > * symbolTable_
 
bool isConstant_
 
bool isZero_
 

Constructor & Destructor Documentation

◆ FunctionParser() [1/2]

walberla::math::FunctionParser::FunctionParser ( )

◆ ~FunctionParser()

walberla::math::FunctionParser::~FunctionParser ( )

◆ FunctionParser() [2/2]

walberla::math::FunctionParser::FunctionParser ( const FunctionParser other)
protected

Member Function Documentation

◆ evaluate()

double walberla::math::FunctionParser::evaluate ( const std::map< std::string, double > &  symbolTable) const

◆ isConstant()

const bool& walberla::math::FunctionParser::isConstant ( ) const
inline

◆ isZero()

const bool& walberla::math::FunctionParser::isZero ( ) const
inline

◆ operator=()

FunctionParser& walberla::math::FunctionParser::operator= ( const FunctionParser other)
protected

◆ parse()

void walberla::math::FunctionParser::parse ( const std::string &  equation)

◆ symbolExists()

bool walberla::math::FunctionParser::symbolExists ( const std::string &  symbol) const

Member Data Documentation

◆ expression_

exprtk::expression<double>* walberla::math::FunctionParser::expression_
protected

◆ isConstant_

bool walberla::math::FunctionParser::isConstant_
protected

◆ isZero_

bool walberla::math::FunctionParser::isZero_
protected

◆ symbolTable_

exprtk::symbol_table<double>* walberla::math::FunctionParser::symbolTable_
protected

The documentation for this class was generated from the following files:
FunctionParser()
Definition: Parser.cpp:68