00001 #ifndef VIENNAMATH_RUNTIME_EXPRESSION_INTERFACE_HPP 00002 #define VIENNAMATH_RUNTIME_EXPRESSION_INTERFACE_HPP 00003 00004 /* ======================================================================= 00005 Copyright (c) 2012, Institute for Microelectronics, 00006 Institute for Analysis and Scientific Computing, 00007 TU Wien. 00008 ----------------- 00009 ViennaMath - Symbolic and Numerical Math in C++ 00010 ----------------- 00011 00012 Author: Karl Rupp rupp@iue.tuwien.ac.at 00013 00014 License: MIT (X11), see file LICENSE in the ViennaMath base directory 00015 ======================================================================= */ 00016 00017 00018 00019 00020 #include <vector> 00021 #include "viennamath/forwards.h" 00022 #include "viennamath/runtime/functor_wrapper.hpp" 00023 00028 namespace viennamath 00029 { 00030 00031 //class rt_expression_interface; 00032 //interface for runtime dispatches: 00034 template <typename NumericT> 00035 class rt_expression_interface 00036 { 00037 public: 00039 typedef NumericT numeric_type; 00041 typedef rt_expression_interface<NumericT> interface_type; 00042 00043 virtual ~rt_expression_interface() {} 00044 00046 virtual interface_type * clone() const = 0; //receiver owns pointer! 00047 00049 virtual std::string deep_str() const = 0; 00050 00052 virtual std::string shallow_str() const { return this->deep_str(); } 00054 virtual NumericT eval(std::vector<NumericT> const & v) const = 0; 00055 00057 virtual NumericT eval(NumericT val) const = 0; 00058 00060 virtual bool is_unary() const { return true; } 00061 00063 virtual bool is_constant() const { return false; } 00064 00066 virtual NumericT unwrap() const = 0; 00067 00069 virtual bool shallow_equal(const interface_type * other) const = 0; 00070 00072 virtual bool deep_equal(const interface_type * other) const = 0; 00073 00075 virtual interface_type * recursive_manipulation(rt_manipulation_wrapper<interface_type> const & fw) const { return fw(this); } 00077 virtual void recursive_traversal(rt_traversal_wrapper<interface_type> const & fw) const { fw(this); } 00078 00080 00082 virtual interface_type * substitute(const interface_type * e, 00083 const interface_type * repl) const = 0; //receiver owns pointer! Function parameters must not be manipulated! 00084 00086 virtual interface_type * substitute(std::vector<const interface_type *> const & e, 00087 std::vector<const interface_type *> const & repl) const = 0; //receiver owns pointer! Function parameters must not be manipulated! 00088 00090 virtual interface_type * simplify() const { return clone(); } //receiver owns pointer! 00092 virtual bool can_simplify() const { return false; } 00094 virtual interface_type * diff(const interface_type * diff_var) const = 0; //receiver owns pointer! Function parameter diff_var not be manipulated! 00095 00096 00097 }; 00098 00099 00100 00101 00102 } 00103 00104 #endif