Solvers and expressions
Configure expression evaluation and operator precedence.
-
enum snt::exs::TokenType
List of operator types
Values:
-
enum snt::exs::OperationType
Type of an operation
Values:
-
enumerator UNARY_OPERATION
Unary operation operates on the atom value.
-
enumerator BINARY_OPERATION
Binary operation operates between two atoms.
-
enumerator TERNARY_OPERATION
Ternary operation operates with three atoms.
-
enumerator GROUP_OPERATION
Group operation operates on various number of atoms.
-
enumerator UNARY_OPERATION
-
enum snt::exs::OperatorType
List of all operators
Values:
-
enumerator NONE_OPERATOR
Item is not an operator.
-
enumerator ADD_OPERATOR
Addition of values.
-
enumerator SUBTRACT_OPERATOR
Subtraction of values.
-
enumerator MULTIPLY_OPERATOR
Multiplication of values.
-
enumerator DIVIDE_OPERATOR
Division of values.
-
enumerator POWER_OPERATOR
Power of a value.
-
enumerator MODULO_OPERATOR
Modulo of values.
-
enumerator NOT_OPERATOR
Logical negation.
-
enumerator AND_OPERATOR
Logical and.
-
enumerator OR_OPERATOR
Logical or.
-
enumerator EQUAL_OPERATOR
Logical equality.
-
enumerator NOT_EQUAL_OPERATOR
Logical difference.
-
enumerator LESS_EQUAL_OPERATOR
Logical less or equal.
-
enumerator GREATER_EQUAL_OPERATOR
Logical greater or equal.
-
enumerator LESS_OPERATOR
Logical less.
-
enumerator GREATER_OPERATOR
Logical greater.
-
enumerator CONDITION_OPERATOR
Conditional operator.
-
enumerator PARENTHESES_OPERATOR
Parentheses.
-
enumerator EXPONENT_OPERATOR
Exponents.
-
enumerator LOGARITHM_OPERATOR
Logarithm.
-
enumerator LOGARITHM_10_OPERATOR
Logarithm with a base 10.
-
enumerator LOGARITHM_BASE_OPERATOR
Logarithm with an arbitrary base.
-
enumerator POWER_BASE_OPERATOR
Power with an arbitrary base.
-
enumerator SQUARE_ROOT_OPERATOR
Square root.
-
enumerator CUBIC_ROOT_OPERATOR
Cubic root.
-
enumerator SINUS_OPERATOR
Sinus.
-
enumerator COSINUS_OPERATOR
Cosinus.
-
enumerator TANGENS_OPERATOR
Tangens.
-
enumerator NUM_OPERATOR_TYPES
Total number of operators.
-
enumerator NONE_OPERATOR
-
using snt::exs::StepListType = std::vector<std::pair<OperationType, std::vector<int>>>
-
static std::string snt::exs::trim(const std::string &str, const std::string &whitespace = " \t")
Remove leading and trailing spaces from a string
- Parameters:
str – String that should be trimmed
whitespace – String with whitespace characters that will be removed
-
struct BaseSettings
- #include <settings.h>
Base structure for expression solver settings
Subclassed by snt::dip::LogicalSettings, snt::dip::NumericalSettings
-
class Exception : public snt::core::Exception
- #include <exceptions.h>
Subclassed by snt::exs::MissingException, snt::exs::ParserException
-
class Expression
- #include <expression.h>
Parsed expression with an ordered list of executable steps.
-
class MissingException : public snt::exs::Exception
- #include <exceptions.h>
Missing exception is triggered when functionality is not implemented yet
Public Functions
-
inline MissingException(std::string message, std::string file, std::size_t line)
-
inline MissingException(std::string message, std::string file, std::size_t line)
-
class ParserException : public snt::exs::Exception
- #include <exceptions.h>
Parser exceptions are triggered by problems during expression parsing
-
template<class ATOM, class SETTINGS = BaseSettings>
class Solver - #include <solver.h>
Main expression solver class
Note that internal solver and operator routines use static_cast to convert between AtomGrand and actual ATOM type. Although it may seem dangerous, within a particular solver we need to guarantee that AtomGrand will have only one derived type.
Public Functions
-
inline Solver(const SETTINGS &set = {})
Default solver constructor
- Parameters:
set – Solver settings
-
inline Solver(const OperatorList &o, const SETTINGS &set = {})
Solver constructor with modified operators
- Parameters:
o – List of operators
set – Solver settings
-
inline Solver(const StepList &s, const SETTINGS &set = {})
Solver constructor with modified operator steps
- Parameters:
s – List of operator steps
set – Solver settings
-
inline Solver(const OperatorList &o, const StepList &s, const SETTINGS &set = {})
Custom solver constructor
- Parameters:
o – List of operators
s – List of operator steps
set – Solver settings
-
inline void set_settings(const SETTINGS &set = {})
Set solver settings
- Parameters:
set – New structure with settings
-
inline ATOM eval(std::string expression)
Main solver routine
- Parameters:
expression – Expression that should be solved
- Returns:
Final atom object with a solution
-
inline Solver(const SETTINGS &set = {})
-
class StepList
- #include <step_list.h>
Ordered execution steps generated from an EXS expression.
Public Functions
-
void append(OperationType t, const std::vector<int> &s)
Append one execution step.
- Parameters:
t – Operation category to execute.
s – Operator identifiers executed for this step.
Public Members
-
StepListType steps
-
void append(OperationType t, const std::vector<int> &s)