• Main Page
  • Namespaces
  • Data Structures
  • Files
  • File List

/export/development/ViennaMath/viennamath/runtime/op_interface.hpp

Go to the documentation of this file.
00001 #ifndef VIENNAMATH_RUNTIME_OP_INTERFACE_HPP
00002 #define VIENNAMATH_RUNTIME_OP_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 <exception>
00022 #include "viennamath/forwards.h"
00023 #include "viennamath/exception.hpp"
00024 
00029 namespace viennamath
00030 {
00031   
00032   
00037   template <typename InterfaceType>
00038   class op_interface
00039   {
00040     public:
00041       typedef typename InterfaceType::numeric_type       numeric_type;
00042       
00043       virtual ~op_interface() {}
00044       
00046       virtual op_interface * clone() const = 0;
00047       
00049       virtual std::string    str() const = 0;
00050 
00052       virtual numeric_type   apply(numeric_type value) const { throw no_rhs_provided_exception(); }                   
00053       
00055       virtual numeric_type   apply(numeric_type lhs,
00056                                    numeric_type rhs) const { throw rhs_provided_for_unary_operation_exception(); }
00057 
00059       virtual bool                   is_unary() const { return true; }
00060 
00061       //unary diff:
00063       virtual InterfaceType * diff(const InterfaceType * e,
00064                                    const InterfaceType * diff_var) const { throw no_rhs_provided_exception(); }
00065 
00066       //binary diff:                                   
00068       virtual InterfaceType * diff(const InterfaceType * lhs,
00069                                    const InterfaceType * rhs,
00070                                    const InterfaceType * diff_var) const { throw rhs_provided_for_unary_operation_exception(); }
00071                                    
00072       //optimization for binary operators:
00074       virtual InterfaceType * simplify(const InterfaceType * lhs,
00075                                        const InterfaceType * rhs) const = 0; //{ throw ex_rhs_provided_for_unary_operator(); }
00076 
00077       //optimization for unary operators:
00078 
00080       virtual bool can_simplify() const = 0;
00082       virtual bool can_simplify(const InterfaceType * lhs,
00083                                 const InterfaceType * rhs) const { return false; }    
00084 
00086       virtual bool equal(const op_interface * other) const = 0;
00087   };
00088   
00089   
00090 
00091   
00092 }
00093 
00094 #endif

Generated on Wed Feb 29 2012 21:50:43 for ViennaMath by  doxygen 1.7.1