Public Types | Public Member Functions

rt_variable< InterfaceType > Class Template Reference

Representation of an variable (a variable). If the supplied argument is some vector type, a traits system accesses the id-th component. More...

#include <variable.hpp>

Public Types

typedef InterfaceType::numeric_type numeric_type

Public Member Functions

 rt_variable (id_type my_id)
id_type id () const
numeric_type operator() (numeric_type value) const
 Evaluation of the variable by a scalar value. Only valid if the variable ID is zero.
template<typename ScalarType >
rt_constant< ScalarType > operator() (rt_constant< ScalarType > const &other) const
 Evaluation of the variable by a ViennaMath runtime constant. Throws an exception if the variable index is larger than zero.
template<long value>
long operator() (ct_constant< value > const &other) const
 Evaluation of the variable by a ViennaMath compiletime constant. Throws an exception if the variable index is larger than zero.
template<typename VectorType >
numeric_type operator() (VectorType const &v) const
 Evaluation of the variable by a point (vector). Any vector type with .size() member function is supported (eventully, get_from_vector() needs to be overloaded).
InterfaceType * clone () const
 Returns a copy of the variable. The returned pointer is not automatically deleted, thus the caller needs to ensure deletion.
numeric_type eval (std::vector< double > const &v) const
 Interface function for evaluating the variable. Returns the 'id_'-th entry of the vector.
numeric_type eval (numeric_type val) const
 Interface function for evaluating the variable. Throws an exception if the id_ member is larger than zero.
std::string deep_str () const
 Returns a detailed string fully describing the variable.
numeric_type unwrap () const
 Tries to evaluate the scalar value of the expression, but a variable cannot be converted to a constant and thus an error is thrown.
InterfaceType * substitute (const InterfaceType *e, const InterfaceType *repl) const
 If 'e' is equal to this variable, the corresponding replacement in 'repl' is returned. Otherwise, a copy of the variable is returned. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion.
InterfaceType * substitute (std::vector< const InterfaceType * > const &e, std::vector< const InterfaceType * > const &repl) const
 Checks whether one of the expressions in 'e' are equal to the variable. If yes, then the corresponding replacement in 'repl' is returned. Otherwise, a copy of the variable is returned. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion.
bool deep_equal (const InterfaceType *other) const
 Returns true if the variable is strictly equal to the expression given by 'other' (both type and variable-ID match).
bool shallow_equal (const InterfaceType *other) const
 Returns a short string specifying that this object is a variable.
InterfaceType * diff (const InterfaceType *diff_var) const
 Differentiates the variable with respect to 'diff_var' and returns the resulting expression. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion.

Detailed Description

template<typename InterfaceType>
class viennamath::rt_variable< InterfaceType >

Representation of an variable (a variable). If the supplied argument is some vector type, a traits system accesses the id-th component.

Template Parameters:
InterfaceType The expression runtime interface to inherit from. Usually rt_expression_interface, but extensions are possible.

Member Typedef Documentation

typedef InterfaceType::numeric_type numeric_type

Constructor & Destructor Documentation

rt_variable ( id_type  my_id  )  [inline, explicit]

Member Function Documentation

InterfaceType* clone (  )  const [inline]

Returns a copy of the variable. The returned pointer is not automatically deleted, thus the caller needs to ensure deletion.

bool deep_equal ( const InterfaceType *  other  )  const [inline]

Returns true if the variable is strictly equal to the expression given by 'other' (both type and variable-ID match).

std::string deep_str (  )  const [inline]

Returns a detailed string fully describing the variable.

InterfaceType* diff ( const InterfaceType *  diff_var  )  const [inline]

Differentiates the variable with respect to 'diff_var' and returns the resulting expression. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion.

numeric_type eval ( numeric_type  val  )  const [inline]

Interface function for evaluating the variable. Throws an exception if the id_ member is larger than zero.

numeric_type eval ( std::vector< double > const &  v  )  const [inline]

Interface function for evaluating the variable. Returns the 'id_'-th entry of the vector.

id_type id (  )  const [inline]
long operator() ( ct_constant< value > const &  other  )  const [inline]

Evaluation of the variable by a ViennaMath compiletime constant. Throws an exception if the variable index is larger than zero.

numeric_type operator() ( numeric_type  value  )  const [inline]

Evaluation of the variable by a scalar value. Only valid if the variable ID is zero.

numeric_type operator() ( VectorType const &  v  )  const [inline]

Evaluation of the variable by a point (vector). Any vector type with .size() member function is supported (eventully, get_from_vector() needs to be overloaded).

rt_constant<ScalarType> operator() ( rt_constant< ScalarType > const &  other  )  const [inline]

Evaluation of the variable by a ViennaMath runtime constant. Throws an exception if the variable index is larger than zero.

bool shallow_equal ( const InterfaceType *  other  )  const [inline]

Returns a short string specifying that this object is a variable.

InterfaceType* substitute ( const InterfaceType *  e,
const InterfaceType *  repl 
) const [inline]

If 'e' is equal to this variable, the corresponding replacement in 'repl' is returned. Otherwise, a copy of the variable is returned. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion.

InterfaceType* substitute ( std::vector< const InterfaceType * > const &  e,
std::vector< const InterfaceType * > const &  repl 
) const [inline]

Checks whether one of the expressions in 'e' are equal to the variable. If yes, then the corresponding replacement in 'repl' is returned. Otherwise, a copy of the variable is returned. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion.

numeric_type unwrap (  )  const [inline]

Tries to evaluate the scalar value of the expression, but a variable cannot be converted to a constant and thus an error is thrown.


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