Public Types | Public Member Functions

rt_vector_expr< InterfaceType > Class Template Reference

An tweaked auto_ptr for run time rt_expr types. More...

#include <vector_expr.hpp>

Public Types

typedef InterfaceType::numeric_type numeric_type
typedef InterfaceType interface_type
typedef BaseType::size_type size_type

Public Member Functions

 rt_vector_expr (size_type num)
 Constructor for initializing the vector expression with the supplied number of elements. Similar to the C++ STL, all-zero entries are created by default.
self_type operator+ (self_type const &other) const
 Operator overload for adding a vector expression from another vector expression.
self_type operator- (self_type const &other) const
 Operator overload for subtracting a vector expression from another vector expression.
InterfaceType * clone () const
 Returns a copy of the vector expression. The returned pointer is not automatically deleted, thus the caller needs to ensure deletion.
std::string deep_str () const
 Returns a detailed string describing objects of this type. Acts recursively on the expression.
std::string shallow_str () const
 Returns a short string describing objects of this type. Does not act recursively.
numeric_type eval (std::vector< double > const &v) const
 Interface function for evaluating the expression. Since an rt_vector_expr cannot be evaluated, an expression_not_evaluable_exception is thrown.
numeric_type eval (numeric_type val) const
 Interface function for evaluating the expression. Since an rt_vector_expr cannot be evaluated, an expression_not_evaluable_exception is thrown.
numeric_type unwrap () const
 Unwraps the expression, i.e. returns the numerical value represented by the expression. Throws an expression_not_unwrappable_exception, since rt_vector_expr cannot be reduced to a constant.
bool deep_equal (const InterfaceType *other) const
 Returns 'true' if 'other' is strictly the same as this class. Also checks for identical IDs, etc.
bool shallow_equal (const InterfaceType *other) const
 Returns 'true' if 'other' is of the same type as this class. Does not perform a 'deep' inspection including a check for IDs and the like.
InterfaceType * substitute (const InterfaceType *e, const InterfaceType *repl) const
 Recursively substititues the expression 'e' by 'repl'. Returns a copy of the expression if 'e' is not found.
InterfaceType * substitute (std::vector< const InterfaceType * > const &e, std::vector< const InterfaceType * > const &repl) const
 Recursively substititues any of the expressions from 'e' by the corresponding replacement in 'repl'.
InterfaceType * optimize () const
 Returns the optimized expression (constants collected, trivial operations removed, etc.).
bool optimizable () const
 Returns true if the expression can be simplified by collecting constants, removing trivial operations, etc.
InterfaceType * diff (const InterfaceType *diff_var) const
 Returns the differentiated expression. Note that the returned pointer is not automatically deleted, thus the caller is responsible for proper deletion.

Detailed Description

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

An tweaked auto_ptr for run time rt_expr types.

Additionally provides the basic user-interface for evaluation using operator().

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

Member Typedef Documentation

typedef InterfaceType interface_type
typedef InterfaceType::numeric_type numeric_type
typedef BaseType::size_type size_type

Constructor & Destructor Documentation

rt_vector_expr ( size_type  num  )  [inline, explicit]

Constructor for initializing the vector expression with the supplied number of elements. Similar to the C++ STL, all-zero entries are created by default.


Member Function Documentation

InterfaceType* clone (  )  const [inline]

Returns a copy of the vector expression. 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 'other' is strictly the same as this class. Also checks for identical IDs, etc.

std::string deep_str (  )  const [inline]

Returns a detailed string describing objects of this type. Acts recursively on the expression.

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

Returns the differentiated expression. Note that the returned pointer is not automatically deleted, thus the caller is responsible for proper deletion.

numeric_type eval ( numeric_type  val  )  const [inline]

Interface function for evaluating the expression. Since an rt_vector_expr cannot be evaluated, an expression_not_evaluable_exception is thrown.

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

Interface function for evaluating the expression. Since an rt_vector_expr cannot be evaluated, an expression_not_evaluable_exception is thrown.

self_type operator+ ( self_type const &  other  )  const [inline]

Operator overload for adding a vector expression from another vector expression.

self_type operator- ( self_type const &  other  )  const [inline]

Operator overload for subtracting a vector expression from another vector expression.

bool optimizable (  )  const [inline]

Returns true if the expression can be simplified by collecting constants, removing trivial operations, etc.

InterfaceType* optimize (  )  const [inline]

Returns the optimized expression (constants collected, trivial operations removed, etc.).

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

Returns 'true' if 'other' is of the same type as this class. Does not perform a 'deep' inspection including a check for IDs and the like.

std::string shallow_str (  )  const [inline]

Returns a short string describing objects of this type. Does not act recursively.

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

Recursively substititues any of the expressions from 'e' by the corresponding replacement in 'repl'.

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

Recursively substititues the expression 'e' by 'repl'. Returns a copy of the expression if 'e' is not found.

numeric_type unwrap (  )  const [inline]

Unwraps the expression, i.e. returns the numerical value represented by the expression. Throws an expression_not_unwrappable_exception, since rt_vector_expr cannot be reduced to a constant.


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