00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _MP_constant_hpp_
00010 #define _MP_constant_hpp_
00011
00012 #include "MP_utilities.hpp"
00013
00014 namespace flopc {
00020 class Constant_base {
00021 friend class Constant;
00022 friend class Handle<Constant_base*>;
00023 public:
00024 virtual double evaluate() const = 0;
00025 virtual int getStage() const {
00026 return 0;
00027 }
00028 virtual int stage() const {
00029 return 0;
00030 }
00031 protected:
00032 Constant_base() : count(0) {}
00033 virtual ~Constant_base() {}
00034 int count;
00035
00036 };
00037
00038 class MP_index_exp;
00039 class DataRef;
00040 class MP_domain;
00041
00049 class Constant : public Handle<Constant_base*> {
00050 public:
00051 Constant(const MP_index_exp& i);
00052 Constant(const DataRef& d);
00053 Constant(double d);
00054 Constant(int d);
00055
00056
00057 Constant(Constant_base* r) : Handle<Constant_base*>(r) {}
00058 };
00059
00060 Constant operator-(const Constant& a);
00061
00068 Constant abs(const Constant& c);
00078 Constant pos(const Constant& c);
00087 Constant ceil(const Constant& c);
00096 Constant floor(const Constant& c);
00105 Constant minimum(const Constant& a, const Constant& b);
00114 Constant maximum(const Constant& a, const Constant& b);
00122 Constant operator+(const Constant& a, const Constant& b);
00130 Constant operator-(const Constant& a, const Constant& b);
00138 Constant operator*(const Constant& a, const Constant& b);
00146 Constant operator/(const Constant& a, const Constant& b);
00147
00148 class MP_boolean;
00149 Constant mpif(const MP_boolean& c, const Constant& a, const Constant& b);
00150
00157 Constant maximum(const MP_domain& i, const Constant& e);
00164 Constant minimum(const MP_domain& i, const Constant& e);
00171 Constant sum(const MP_domain& i, const Constant& e);
00178 Constant product(const MP_domain& i, const Constant& e);
00179 }
00180 #endif