Advanced Multi-Physics (AMP)
On-Line Documentation
MathExpr.h
Go to the documentation of this file.
1#ifndef included_AMP_MathExpr
2#define included_AMP_MathExpr
3
4
5#include <initializer_list>
6#include <memory>
7#include <string>
8#include <vector>
9
10#include "AMP/utils/tinyexpr/tinyexpr.h"
11
12
13namespace AMP {
14
15
24{
25public:
28
35 explicit MathExpr( std::string expression,
36 std::vector<std::string> variables = std::vector<std::string>() );
37
43 explicit MathExpr( double value );
44
46 MathExpr( const MathExpr & ) = delete;
47
49 MathExpr &operator=( const MathExpr & ) = delete;
50
53
56
59
61 MathExpr clone() const;
62
64 inline const auto &getExpr() const { return d_expr; }
65
67 inline const auto &getVars() const { return d_vars; }
68
75 double operator()( const std::initializer_list<double> &data = {} ) const;
76
83 double operator()( const double *data ) const;
84
86 bool operator==( const MathExpr &rhs ) const;
87
89 bool operator!=( const MathExpr &rhs ) const { return !operator==( rhs ); }
90
91private:
92 void initialize();
93
94 std::string d_expr;
95 te_expr *d_fun = nullptr;
96 std::vector<std::string> d_vars;
97 std::vector<te_variable> d_tevar;
98 mutable std::vector<double> d_data;
99};
100
101
102} // namespace AMP
103
104#endif
A class used to evaluate math expressions.
Definition MathExpr.h:24
double operator()(const double *data) const
Evaluate.
std::vector< std::string > d_vars
Definition MathExpr.h:96
MathExpr(MathExpr &&rhs)
Move constructor.
te_expr * d_fun
Definition MathExpr.h:95
double operator()(const std::initializer_list< double > &data={}) const
Evaluate.
MathExpr & operator=(MathExpr &&rhs)
Move assignment operator.
const auto & getExpr() const
Return the expression.
Definition MathExpr.h:64
MathExpr(const MathExpr &)=delete
Copy constructor.
std::vector< double > d_data
Definition MathExpr.h:98
bool operator==(const MathExpr &rhs) const
Check if two expressions are the same.
MathExpr(double value)
Scalar.
bool operator!=(const MathExpr &rhs) const
Check if two expressions are different.
Definition MathExpr.h:89
std::vector< te_variable > d_tevar
Definition MathExpr.h:97
MathExpr()
Empty constructor.
MathExpr & operator=(const MathExpr &)=delete
Assignment operator.
std::string d_expr
Definition MathExpr.h:94
MathExpr(std::string expression, std::vector< std::string > variables=std::vector< std::string >())
Default constructor.
const auto & getVars() const
Return the variables.
Definition MathExpr.h:67
void initialize()
~MathExpr()
Destructor.
MathExpr clone() const
Clone the expression.



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:41.
Comments on this page