![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Represents part of a formula. More...
#include <agrum/tools/core/math/formula.h>
Public Attributes | |
token_type | type |
The token_type stored by this gum::FormulaPart. More... | |
double | number |
The value stored by this gum::FormulaPart. More... | |
char | character |
The value stored by this gum::FormulaPart. More... | |
token_function | function |
The value stored by this gum::FormulaPart. More... | |
Public Member Functions | |
Constructors and destructor | |
FormulaPart () | |
Class constructor. More... | |
FormulaPart (token_type t, double n) | |
Constructor for doubles. More... | |
FormulaPart (token_type t, char c) | |
Constructor for chars. More... | |
FormulaPart (token_type t, token_function func) | |
Constructor for functions. More... | |
FormulaPart (const FormulaPart &source) | |
Copy constructor. More... | |
FormulaPart (FormulaPart &&source) | |
Move constructor. More... | |
~FormulaPart () | |
Class destuctor. More... | |
source The gum::FormulaPart to copy. | |
Move operator.
| |
FormulaPart & | operator= (const FormulaPart &source) |
FormulaPart & | operator= (FormulaPart &&source) |
Getters and setters | |
std::string | str () const |
Returns a string representation of this gum::FormulaPart value. More... | |
bool | isLeftAssociative () const |
Returns true if this gum::FormulaPart is left associative. More... | |
bool | isRightAssociative () const |
Returns true if this gum::FormulaPart is right associative. More... | |
int | precedence () const |
Returns the precedence priority of the value stored in this gum::FormulaPart. More... | |
size_t | argc () const |
Returns the number of argument of the function stored in this gum::FormulaPart. More... | |
FormulaPart | eval (const std::vector< FormulaPart > &args) const |
Returns the evaluation of the vector of gum::FormulaPart as arguments of the value stored in this gum::FormulaPart. More... | |
Public Types | |
enum | token_type { NUMBER, OPERATOR, PARENTHESIS, NIL, FUNCTION, ARG_SEP } |
The tokens constituting a formula. More... | |
enum | token_function { exp, log, ln, pow, sqrt, nil } |
The functions allowed in a formula. More... | |
Represents part of a formula.
This class is used by the gum::Formula class to store intermediate results when solving the formula using the Shuntin-yard algorithm.
The functions allowed in a formula.
Enumerator | |
---|---|
exp | |
log | |
ln | |
pow | |
sqrt | |
nil |
Definition at line 73 of file formula.h.
The tokens constituting a formula.
Enumerator | |
---|---|
NUMBER | |
OPERATOR | |
PARENTHESIS | |
NIL | |
FUNCTION | |
ARG_SEP |
Definition at line 62 of file formula.h.
gum::FormulaPart::FormulaPart | ( | ) |
Class constructor.
Definition at line 85 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::FormulaPart::FormulaPart | ( | token_type | t, |
double | n | ||
) |
Constructor for doubles.
t | The token_type of this gum::FormulaPart. |
n | The value of this gum::FormulaPart. |
Definition at line 89 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::FormulaPart::FormulaPart | ( | token_type | t, |
char | c | ||
) |
Constructor for chars.
t | The token_type of this gum::FormulaPart. |
c | The value of this gum::FormulaPart. |
Definition at line 94 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::FormulaPart::FormulaPart | ( | token_type | t, |
token_function | func | ||
) |
Constructor for functions.
t | The token_type of this gum::FormulaPart. |
func | The value of this gum::FormulaPart. |
Definition at line 99 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::FormulaPart::FormulaPart | ( | const FormulaPart & | source | ) |
Copy constructor.
source | The gum::FormulaPart to copy. |
Definition at line 104 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::FormulaPart::FormulaPart | ( | FormulaPart && | source | ) |
Move constructor.
source | The gum::FormulaPart to move. |
Definition at line 110 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::FormulaPart::~FormulaPart | ( | ) |
Class destuctor.
Definition at line 116 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
Returns the number of arguments expected by the function stored in this gum::FormulaPart.
Definition at line 131 of file formula_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Returns the evaluation of the vector of gum::FormulaPart as arguments of the value stored in this gum::FormulaPart.
Args are backwards !
args | The arguments, in backards, passed to the value stored in this gum::FormulaPart. |
OperationNotAllowed | Raised if the value stored is not a function. |
Definition at line 191 of file formula_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Returns the number of arguments expected by the operator stored in this gum::FormulaPart.
Definition at line 111 of file formula_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Returns the evaluation of the vector of gum::FormulaPart as arguments of the value stored in this gum::FormulaPart.
Args are backwards !
args | The arguments, in backards, passed to the value stored in this gum::FormulaPart. |
OperationNotAllowed | Raised if the value stored is not an operator. |
Definition at line 157 of file formula_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE size_t gum::FormulaPart::argc | ( | ) | const |
Returns the number of argument of the function stored in this gum::FormulaPart.
OperationNotAllowed | Raised if the value stored is not a function. |
Definition at line 94 of file formula_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE FormulaPart gum::FormulaPart::eval | ( | const std::vector< FormulaPart > & | args | ) | const |
Returns the evaluation of the vector of gum::FormulaPart as arguments of the value stored in this gum::FormulaPart.
Args are backwards !
args | The arguments, in backards, passed to the value stored in this gum::FormulaPart. |
OperationNotAllowed | Raised if the value stored is neither a function nor an operator. |
Definition at line 217 of file formula_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE bool gum::FormulaPart::isLeftAssociative | ( | ) | const |
Returns true if this gum::FormulaPart is left associative.
OperationNotAllowed | Raised if the value stored is not an operator. |
Definition at line 32 of file formula_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE bool gum::FormulaPart::isRightAssociative | ( | ) | const |
Returns true if this gum::FormulaPart is right associative.
OperationNotAllowed | Raised if the value stored is not an operator. |
Definition at line 55 of file formula_inl.h.
References gum::Set< Key, Alloc >::emplace().
FormulaPart & gum::FormulaPart::operator= | ( | const FormulaPart & | source | ) |
Definition at line 121 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
FormulaPart & gum::FormulaPart::operator= | ( | FormulaPart && | source | ) |
Definition at line 132 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
INLINE int gum::FormulaPart::precedence | ( | ) | const |
Returns the precedence priority of the value stored in this gum::FormulaPart.
OperationNotAllowed | Raised if the value stored is not an operator. |
Definition at line 67 of file formula_inl.h.
References gum::Set< Key, Alloc >::emplace().
std::string gum::FormulaPart::str | ( | ) | const |
Returns a string representation of this gum::FormulaPart value.
Definition at line 143 of file formula.cpp.
References gum::Set< Key, Alloc >::emplace().
char gum::FormulaPart::character |
The value stored by this gum::FormulaPart.
token_function gum::FormulaPart::function |
The value stored by this gum::FormulaPart.
double gum::FormulaPart::number |
The value stored by this gum::FormulaPart.
token_type gum::FormulaPart::type |
The token_type stored by this gum::FormulaPart.