Atoms and tokens
Value atoms and token containers used by custom solvers.
-
using snt::exs::AtomValueType = std::variant<double, bool>
Type of default atom value.
-
class Atom : public snt::exs::AtomBase<Atom, AtomValueType>
- #include <atom.h>
Default atom class
Public Functions
-
Atom(const Atom &a) = default
Copy constructor of an atom
- Parameters:
a – Reference to an atom from which we copy the values
-
inline Atom(AtomValueType v)
Initialise an empty vector of a specific type
- Parameters:
v – Atom value type
-
virtual std::string to_string() override
Get a string representation of an atom
-
virtual void math_add(Atom *other) override
Add this value to another value
- Parameters:
other – Pointer to another atom
-
virtual void math_subtract(Atom *other) override
Subtract another value from this value
- Parameters:
other – Pointer to another atom
-
virtual void math_negate() override
Negate value of this value
-
virtual void math_multiply(Atom *other) override
Multiply this value with another value
- Parameters:
other – Pointer to another atom
-
virtual void math_divide(Atom *other) override
Divide this value with another value
- Parameters:
other – Pointer to another atom
-
virtual void math_power(Atom *other) override
Raise this values to a given power
- Parameters:
other – Pointer to another atom
-
virtual void math_modulo(Atom *other) override
Perform modulo on this atom
- Parameters:
other – Pointer to another atom
-
virtual void math_exponent() override
Get an exponential value of this value
-
virtual void math_logarithm() override
Get a natural logarithm of this value
-
virtual void math_logarithm_10() override
Get a decadic logarithm of this value
-
virtual void math_logarithm_base(Atom *other) override
Get a logarithm with arbitrary base of this value
- Parameters:
other – Pointer to another atom
-
virtual void math_power_base(Atom *other) override
Get power with arbitrary base of this value
- Parameters:
other – Pointer to another atom
-
virtual void math_square_root() override
Get square root value of this value
-
virtual void math_cubic_root() override
Get cubic root of this value
-
virtual void math_sinus() override
Get sinus of this value
-
virtual void math_cosinus() override
Get cosinus of this value
-
virtual void math_tangens() override
Get tangens value of this value
-
virtual void comparison_equal(Atom *other) override
Compare equality of this and other value
- Parameters:
other – Pointer to another atom
-
virtual void comparison_not_equal(Atom *other) override
Compare difference of ths and other value
- Parameters:
other – Pointer to another atom
-
virtual void comparison_less_equal(Atom *other) override
Compare if this value is less or equal than other
- Parameters:
other – Pointer to another atom
-
virtual void comparison_greater_equal(Atom *other) override
Compare if this value is greater or equal than other
- Parameters:
other – Pointer to another atom
-
virtual void comparison_less(Atom *other) override
Compare if this value is less than other
- Parameters:
other – Pointer to another atom
-
virtual void comparison_greater(Atom *other) override
Compare if this value is greater than other
- Parameters:
other – Pointer to another atom
-
virtual void logical_not() override
Get logical negation of this value
-
virtual void logical_and(Atom *other) override
Get logical and of this and other value
- Parameters:
other – Pointer to another atom
Public Static Functions
-
static AtomValueType from_string(const std::string &s, BaseSettings *set = nullptr)
Create and atom object from a string
- Parameters:
s – String corresponding to an atom
set – Pointer to solver settings
-
Atom(const Atom &a) = default
-
template<typename ATOM, typename VALUE>
class AtomBase : public snt::exs::AtomGrand - #include <atom_base.h>
Base atom class
Public Functions
-
inline AtomBase &operator=(const AtomBase &a)
Copy the atom value into this object.
- Parameters:
a – Source atom whose value is copied.
-
inline AtomBase &operator=(AtomBase &&a) noexcept
Move the atom value into this object.
- Parameters:
a – Source atom whose value is moved.
-
inline virtual void math_add(ATOM *other)
Add another value.
- Parameters:
other – Other value used in the operation.
-
inline virtual void math_add(AtomGrand *other) override
Add this value to another value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_subtract(AtomGrand *other) override
Subtract another value from this value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_multiply(AtomGrand *other) override
Multiply this value with another value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_divide(AtomGrand *other) override
Divide this value with another value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_power(AtomGrand *other) override
Raise this values to a given power
- Parameters:
other – Pointer to another atom
-
inline virtual void math_modulo(AtomGrand *other) override
Perform modulo on this atom
- Parameters:
other – Pointer to another atom
-
inline virtual void math_logarithm_base(AtomGrand *other) override
Get a logarithm with arbitrary base of this value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_power_base(AtomGrand *other) override
Get power with arbitrary base of this value
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_equal(AtomGrand *other) override
Compare equality of this and other value
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_not_equal(AtomGrand *other) override
Compare difference of ths and other value
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_less_equal(AtomGrand *other) override
Compare if this value is less or equal than other
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_greater_equal(AtomGrand *other) override
Compare if this value is greater or equal than other
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_less(AtomGrand *other) override
Compare if this value is less than other
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_greater(AtomGrand *other) override
Compare if this value is greater than other
- Parameters:
other – Pointer to another atom
-
inline virtual void logical_and(ATOM *other)
Apply a logical AND operation.
- Parameters:
other – Other value used in the operation.
-
inline virtual void logical_and(AtomGrand *other) override
Get logical and of this and other value
- Parameters:
other – Pointer to another atom
-
inline virtual void logical_or(ATOM *other)
Apply a logical OR operation.
- Parameters:
other – Other value used in the operation.
-
inline AtomBase &operator=(const AtomBase &a)
-
class AtomGrand
- #include <atom_grand.h>
Virtual base class actually used in the solver
Subclassed by snt::exs::AtomBase< LogicalAtom, ValueNodeData >, snt::exs::AtomBase< NumericalAtom, ValueNodeData >, snt::exs::AtomBase< Atom, AtomValueType >, snt::exs::AtomBase< SubstanceAtom, ElementMap >, snt::exs::AtomBase< CalculatorAtom, Quantity >, snt::exs::AtomBase< UnitAtom, Measurement >, snt::exs::AtomBase< ATOM, VALUE >
Public Functions
-
virtual ~AtomGrand() = default
Default class destructor
-
virtual std::string to_string() = 0
Get a string representation of an atom
-
void print()
Print out atoms representation
-
inline virtual void math_add(AtomGrand *other)
Add this value to another value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_subtract(AtomGrand *other)
Subtract another value from this value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_negate()
Negate value of this value
-
inline virtual void math_multiply(AtomGrand *other)
Multiply this value with another value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_divide(AtomGrand *other)
Divide this value with another value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_power(AtomGrand *other)
Raise this values to a given power
- Parameters:
other – Pointer to another atom
-
inline virtual void math_modulo(AtomGrand *other)
Perform modulo on this atom
- Parameters:
other – Pointer to another atom
-
inline virtual void math_exponent()
Get an exponential value of this value
-
inline virtual void math_logarithm()
Get a natural logarithm of this value
-
inline virtual void math_logarithm_10()
Get a decadic logarithm of this value
-
inline virtual void math_logarithm_base(AtomGrand *other)
Get a logarithm with arbitrary base of this value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_power_base(AtomGrand *other)
Get power with arbitrary base of this value
- Parameters:
other – Pointer to another atom
-
inline virtual void math_square_root()
Get square root value of this value
-
inline virtual void math_cubic_root()
Get cubic root of this value
-
inline virtual void math_sinus()
Get sinus of this value
-
inline virtual void math_cosinus()
Get cosinus of this value
-
inline virtual void math_tangens()
Get tangens value of this value
-
inline virtual void comparison_equal(AtomGrand *other)
Compare equality of this and other value
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_not_equal(AtomGrand *other)
Compare difference of ths and other value
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_less_equal(AtomGrand *other)
Compare if this value is less or equal than other
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_greater_equal(AtomGrand *other)
Compare if this value is greater or equal than other
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_less(AtomGrand *other)
Compare if this value is less than other
- Parameters:
other – Pointer to another atom
-
inline virtual void comparison_greater(AtomGrand *other)
Compare if this value is greater than other
- Parameters:
other – Pointer to another atom
-
inline virtual void logical_not()
Get logical negation of this value
-
inline virtual void logical_and(AtomGrand *other)
Get logical and of this and other value
- Parameters:
other – Pointer to another atom
-
virtual ~AtomGrand() = default
-
class AtomList
- #include <atom_list.h>
Ordered collection of EXS expression atoms.
Public Functions
-
class Token
- #include <token.h>
Lexical token produced by the EXS expression parser.
-
class TokenList : public snt::exs::TokenListBase
- #include <token_list.h>
Collection of tokens used during expression parsing.
Public Functions
-
inline TokenList(OperatorList *o, BaseSettings *set = nullptr)
-
inline void append(TokenType t)
Append a token with no integer payload.
- Parameters:
t – Token category.
-
inline void append(TokenType t, int o)
Append a token carrying an integer payload.
- Parameters:
t – Token category.
o – Integer token payload, such as an operator index.
-
inline void append(TokenType t, std::unique_ptr<AtomGrand> at)
Append a token that owns an expression atom.
-
inline void operate(const std::vector<int> &ops, OperationType oitype)
-
inline virtual void print(bool details = false) override
Format the object as text.
- Parameters:
details – Detailed diagnostic explanation.
-
inline std::string to_string(bool details = false)
-
inline TokenList(OperatorList *o, BaseSettings *set = nullptr)
-
class TokenListBase
- #include <token_list_base.h>
Common storage and operations for EXS token lists.
Subclassed by snt::exs::TokenList