Public Types | Public Member Functions

rt_constant< ScalarType, InterfaceType > Class Template Reference

Representation of a constant within the expression setting of ViennaMath. More...

#include <constant.hpp>

Public Types

typedef InterfaceType::numeric_type numeric_type

Public Member Functions

 rt_constant (ScalarType s_)
self_type operator() () const
 Evaluates the constant.
template<typename VectorType >
self_type operator() (const VectorType &p) const
 Evaluates the constant by returning its value.
 operator ScalarType () const
 A ViennaMath constant is implicity convertible to its underlying scalar. Since the constructor is explicit, this operation is safe.
InterfaceType * clone () const
 Returns a copy of the constant. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion.
numeric_type eval (std::vector< numeric_type > const &v) const
 (Trivially) Evaluates the constant.
numeric_type eval (numeric_type v) const
 (Trivially) Evaluates the constant.
bool is_constant () const
 A constant is a constant :-).
std::string deep_str () const
 Returns a textual representation of the constant.
numeric_type unwrap () const
 Interface requirement: Returns the value of the constant.
InterfaceType * substitute (const InterfaceType *e, const InterfaceType *repl) const
 Substitutes the constant with an expression 'repl' if it matches the expression 'e'. 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
 If any of the expressions in 'e' match the constant, the expression in 'repl' is returned. Otherwise, a copy of the constant 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 'other' points to a constant with the same value.
bool shallow_equal (const InterfaceType *other) const
 Returns true if 'other' is also a constant.
InterfaceType * diff (const InterfaceType *diff_var) const
 Returns the result of differentiating the constant with respect to a variable, i.e. zero.

Detailed Description

template<typename ScalarType, typename InterfaceType>
class viennamath::rt_constant< ScalarType, InterfaceType >

Representation of a constant within the expression setting of ViennaMath.

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_constant ( ScalarType  s_  )  [inline, explicit]

Member Function Documentation

InterfaceType* clone (  )  const [inline]

Returns a copy of the constant. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion.

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

Returns true if 'other' points to a constant with the same value.

std::string deep_str (  )  const [inline]

Returns a textual representation of the constant.

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

Returns the result of differentiating the constant with respect to a variable, i.e. zero.

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

(Trivially) Evaluates the constant.

numeric_type eval ( numeric_type  v  )  const [inline]

(Trivially) Evaluates the constant.

bool is_constant (  )  const [inline]

A constant is a constant :-).

operator ScalarType (  )  const [inline]

A ViennaMath constant is implicity convertible to its underlying scalar. Since the constructor is explicit, this operation is safe.

self_type operator() ( const VectorType &  p  )  const [inline]

Evaluates the constant by returning its value.

self_type operator() (  )  const [inline]

Evaluates the constant.

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

Returns true if 'other' is also a constant.

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

Substitutes the constant with an expression 'repl' if it matches the expression 'e'. 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]

If any of the expressions in 'e' match the constant, the expression in 'repl' is returned. Otherwise, a copy of the constant is returned. The object referred by the pointer is not automatically deleted, thus the caller needs to ensure deletion.

numeric_type unwrap (  )  const [inline]

Interface requirement: Returns the value of the constant.


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