Biorbd
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
biorbd::utils::Equation Class Reference

Strings that are to be interpreted as equation that can be evaluated. More...

#include <Equation.h>

Inheritance diagram for biorbd::utils::Equation:
biorbd::utils::String

Public Member Functions

 Equation ()
 Construct Equation.
 
 Equation (const char *string)
 Construct Equation. More...
 
 Equation (const biorbd::utils::String &string)
 Construct Equation. More...
 
 Equation (const std::basic_string< char > &string)
 Construct Equation. More...
 
- Public Member Functions inherited from biorbd::utils::String
 String ()
 Construct string.
 
 String (const char *text)
 Construct string. More...
 
 String (const biorbd::utils::String &text)
 Construct string. More...
 
 String (const std::basic_string< char > &text)
 Construct string. More...
 
Stringoperator= (const biorbd::utils::String &other)
 Allow to use operator=. More...
 
String operator+ (unsigned int val)
 Append an unsigned int to the string. More...
 
String operator+ (int val)
 Append an int to the string. More...
 
String operator+ (double val)
 Append a double to the string. More...
 
String operator+ (const char *text)
 Append a char to the string. More...
 
String operator() (unsigned int idx) const
 Get a specific character in the string. More...
 
String operator() (unsigned int startIdx, unsigned int lastIdx) const
 Extract a portion of the string. More...
 
virtual ~String ()
 Destroy class properly.
 
biorbd::utils::String tolower () const
 Return a lower case string. More...
 
biorbd::utils::String toupper () const
 Return an upper case string. More...
 

Static Public Member Functions

static std::vector< biorbd::utils::EquationsplitIntoEquation (biorbd::utils::Equation wholeEq, const std::map< biorbd::utils::Equation, double > &variables)
 Split equation into smaller parts, down to number or math symbols. More...
 
static double evaluateEquation (std::vector< biorbd::utils::Equation > wholeEq)
 Evaluate and return an equation. More...
 
static double evaluateEquation (biorbd::utils::Equation wholeEq)
 Evaluate and return an equation. More...
 
static double evaluateEquation (biorbd::utils::Equation wholeEq, const std::map< biorbd::utils::Equation, double > &variables)
 Evaluate and return an equation. More...
 
static void replaceCste (std::vector< biorbd::utils::Equation > &eq)
 Replace constants in the split equation by a number. More...
 
static void replaceVar (biorbd::utils::Equation &eq, const std::map< biorbd::utils::Equation, double > &variables)
 Replace the varirables in the equation by their values. More...
 
- Static Public Member Functions inherited from biorbd::utils::String
static biorbd::utils::String tolower (const biorbd::utils::String &str)
 Convert a string to a lower case string. More...
 
static biorbd::utils::String toupper (const biorbd::utils::String &str)
 Convert a string to a upper case string. More...
 
static biorbd::utils::String to_string (double val)
 Overload of the to_string C++11 function to allow for X-digits precision. More...
 
static biorbd::utils::String to_string (float val)
 Overload of the to_string C++11 function to allow for X-digits precision. More...
 
static biorbd::utils::String removeTrailing (const biorbd::utils::String &origin, const biorbd::utils::String &trailTag)
 The trailing tags of a string. More...
 

Static Protected Member Functions

static double evaluateEquation (std::vector< biorbd::utils::Equation > eq, unsigned int math)
 Resolve the equation. More...
 
static std::vector< biorbd::utils::EquationprepareMathSymbols ()
 Prepare the mathematical symbols. More...
 

Detailed Description

Strings that are to be interpreted as equation that can be evaluated.

Definition at line 15 of file Equation.h.

Constructor & Destructor Documentation

◆ Equation() [1/3]

biorbd::utils::Equation::Equation ( const char *  string)

Construct Equation.

Parameters
stringThe equation in a char format

Definition at line 31 of file Equation.cpp.

◆ Equation() [2/3]

biorbd::utils::Equation::Equation ( const biorbd::utils::String string)

Construct Equation.

Parameters
stringThe equation in a string format

Definition at line 37 of file Equation.cpp.

◆ Equation() [3/3]

biorbd::utils::Equation::Equation ( const std::basic_string< char > &  string)

Construct Equation.

Parameters
stringThe equation in a list of char format

Definition at line 43 of file Equation.cpp.

Member Function Documentation

◆ evaluateEquation() [1/4]

double biorbd::utils::Equation::evaluateEquation ( biorbd::utils::Equation  wholeEq)
static

Evaluate and return an equation.

Parameters
wholeEqThe whole equation to evaluate
Returns
The evaluated equation

Definition at line 258 of file Equation.cpp.

◆ evaluateEquation() [2/4]

double biorbd::utils::Equation::evaluateEquation ( biorbd::utils::Equation  wholeEq,
const std::map< biorbd::utils::Equation, double > &  variables 
)
static

Evaluate and return an equation.

Parameters
wholeEqThe whole equation to evaluate
variablesThe variables in the equation
Returns
The evaluated equation

Definition at line 252 of file Equation.cpp.

◆ evaluateEquation() [3/4]

double biorbd::utils::Equation::evaluateEquation ( std::vector< biorbd::utils::Equation eq,
unsigned int  math 
)
staticprotected

Resolve the equation.

Parameters
eqThe equation to resolve
mathThe mathematical symbol that is being evaluated now

Definition at line 167 of file Equation.cpp.

◆ evaluateEquation() [4/4]

double biorbd::utils::Equation::evaluateEquation ( std::vector< biorbd::utils::Equation wholeEq)
static

Evaluate and return an equation.

Parameters
wholeEqThe already split equation to evaluate
Returns
The evaluated equation

Definition at line 161 of file Equation.cpp.

◆ prepareMathSymbols()

std::vector< biorbd::utils::Equation > biorbd::utils::Equation::prepareMathSymbols ( )
staticprotected

Prepare the mathematical symbols.

Returns
The math symbols in an order that respect the order of operation

The supported symbols are:

  • "(" – Open a parenthese
  • ")" – Close a parenthese
  • "e" – value of the format 1e2 (i.e. 1x10^2)
  • "/" – Division
  • "*" – Multiplication
  • "+" – Addition
  • "-" – Subtraction, or negative number if it starts the equation

Definition at line 11 of file Equation.cpp.

◆ replaceCste()

void biorbd::utils::Equation::replaceCste ( std::vector< biorbd::utils::Equation > &  eq)
static

Replace constants in the split equation by a number.

Parameters
eqThe split equation

The supported constants are:

  • pi – that evaluates to M_PI, that is $3.14159265358979323846$ on UNIX

Definition at line 137 of file Equation.cpp.

◆ replaceVar()

void biorbd::utils::Equation::replaceVar ( biorbd::utils::Equation eq,
const std::map< biorbd::utils::Equation, double > &  variables 
)
static

Replace the varirables in the equation by their values.

Parameters
eqThe equation to replace the variables
variablesThe variable set

Definition at line 146 of file Equation.cpp.

◆ splitIntoEquation()

std::vector< biorbd::utils::Equation > biorbd::utils::Equation::splitIntoEquation ( biorbd::utils::Equation  wholeEq,
const std::map< biorbd::utils::Equation, double > &  variables 
)
static

Split equation into smaller parts, down to number or math symbols.

Parameters
wholeEqThe whole equation to split
variablesThe set of variables in the equation
Returns
The split equation

Definition at line 49 of file Equation.cpp.


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