Advanced Multi-Physics (AMP)
On-Line Documentation
Public Member Functions | Private Member Functions | Private Attributes | List of all members
AMP::MathExpr Class Reference

A class used to evaluate math expressions. More...

#include <MathExpr.h>

Public Member Functions

MathExpr clone () const
 Clone the expression.
 
const auto & getExpr () const
 Return the expression.
 
const auto & getVars () const
 Return the variables.
 
 MathExpr ()
 Empty constructor.
 
 MathExpr (const MathExpr &)=delete
 Copy constructor.
 
 MathExpr (double value)
 Scalar.
 
 MathExpr (MathExpr &&rhs)
 Move constructor.
 
 MathExpr (std::string expression, std::vector< std::string > variables=std::vector< std::string >())
 Default constructor.
 
bool operator!= (const MathExpr &rhs) const
 Check if two expressions are different.
 
double operator() (const double *data) const
 Evaluate.
 
double operator() (const std::initializer_list< double > &data={}) const
 Evaluate.
 
MathExproperator= (const MathExpr &)=delete
 Assignment operator.
 
MathExproperator= (MathExpr &&rhs)
 Move assignment operator.
 
bool operator== (const MathExpr &rhs) const
 Check if two expressions are the same.
 
 ~MathExpr ()
 Destructor.
 

Private Member Functions

void initialize ()
 

Private Attributes

std::vector< double > d_data
 
std::string d_expr
 
te_exprd_fun = nullptr
 
std::vector< te_variabled_tevar
 
std::vector< std::string > d_vars
 

Detailed Description

A class used to evaluate math expressions.

This class provides the ability to evaluate a string as a math expression. Note: currently this class is not thread-safe. Each thread must have a different copy.

Definition at line 23 of file MathExpr.h.

Constructor & Destructor Documentation

◆ MathExpr() [1/5]

AMP::MathExpr::MathExpr ( )

Empty constructor.

◆ MathExpr() [2/5]

AMP::MathExpr::MathExpr ( std::string  expression,
std::vector< std::string >  variables = std::vector< std::string >() 
)
explicit

Default constructor.

Construct a MathExpr object to evaluate an expression with input variables

Parameters
[in]expressionExpression to evaluate: "sqrt(x^2+y^2)"
[in]variablesList of variables: { "x", "y" }

◆ MathExpr() [3/5]

AMP::MathExpr::MathExpr ( double  value)
explicit

Scalar.

Construct a MathExpr object from a scalar value

Parameters
[in]valueScalar value

◆ MathExpr() [4/5]

AMP::MathExpr::MathExpr ( const MathExpr )
delete

Copy constructor.

◆ MathExpr() [5/5]

AMP::MathExpr::MathExpr ( MathExpr &&  rhs)

Move constructor.

◆ ~MathExpr()

AMP::MathExpr::~MathExpr ( )

Destructor.

Member Function Documentation

◆ clone()

MathExpr AMP::MathExpr::clone ( ) const

Clone the expression.

◆ getExpr()

const auto & AMP::MathExpr::getExpr ( ) const
inline

Return the expression.

Definition at line 64 of file MathExpr.h.

References d_expr.

◆ getVars()

const auto & AMP::MathExpr::getVars ( ) const
inline

Return the variables.

Definition at line 67 of file MathExpr.h.

References d_vars.

◆ initialize()

void AMP::MathExpr::initialize ( )
private

◆ operator!=()

bool AMP::MathExpr::operator!= ( const MathExpr rhs) const
inline

Check if two expressions are different.

Definition at line 89 of file MathExpr.h.

References operator==().

◆ operator()() [1/2]

double AMP::MathExpr::operator() ( const double *  data) const

Evaluate.

Evaluate the expression provided in the constructor with given arguments

Parameters
[in]dataList of variable values: { x, y }
Returns
Returns the result

◆ operator()() [2/2]

double AMP::MathExpr::operator() ( const std::initializer_list< double > &  data = {}) const

Evaluate.

Evaluate the expression provided in the constructor with given arguments

Parameters
[in]dataList of variable values: { x, y }
Returns
Returns the result

◆ operator=() [1/2]

MathExpr & AMP::MathExpr::operator= ( const MathExpr )
delete

Assignment operator.

◆ operator=() [2/2]

MathExpr & AMP::MathExpr::operator= ( MathExpr &&  rhs)

Move assignment operator.

◆ operator==()

bool AMP::MathExpr::operator== ( const MathExpr rhs) const

Check if two expressions are the same.

Referenced by operator!=().

Member Data Documentation

◆ d_data

std::vector<double> AMP::MathExpr::d_data
mutableprivate

Definition at line 98 of file MathExpr.h.

◆ d_expr

std::string AMP::MathExpr::d_expr
private

Definition at line 94 of file MathExpr.h.

Referenced by getExpr().

◆ d_fun

te_expr* AMP::MathExpr::d_fun = nullptr
private

Definition at line 95 of file MathExpr.h.

◆ d_tevar

std::vector<te_variable> AMP::MathExpr::d_tevar
private

Definition at line 97 of file MathExpr.h.

◆ d_vars

std::vector<std::string> AMP::MathExpr::d_vars
private

Definition at line 96 of file MathExpr.h.

Referenced by getVars().


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



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:42.
Comments on this page