MP_constant.hpp
Go to the documentation of this file.
1 // ******************** FlopCpp **********************************************
2 // File: MP_constant.hpp
3 // $Id$
4 // Author: Tim Helge Hultberg (thh@mat.ua.pt)
5 // Copyright (C) 2003 Tim Helge Hultberg
6 // All Rights Reserved.
7 // ****************************************************************************
8 
9 #ifndef _MP_constant_hpp_
10 #define _MP_constant_hpp_
11 
12 #include "MP_utilities.hpp"
13 
14 namespace flopc {
20  class Constant_base {
21  friend class Constant;
22  friend class Handle<Constant_base*>;
23  public:
24  virtual double evaluate() const = 0;
25  virtual int getStage() const {
26  return 0;
27  }
28  virtual int stage() const {
29  return 0;
30  }
31  protected:
32  Constant_base() : count(0) {}
33  virtual ~Constant_base() {}
34  int count;
35 
36  };
37 
38  class MP_index_exp;
39  class DataRef;
40  class MP_domain;
41 
48  class Constant : public Handle<Constant_base*> {
49  public:
51  Constant(const MP_index_exp& i);
52  Constant(const DataRef& d);
53  Constant(double d);
54  Constant(int d);
55  };
56 
63  Constant abs(const Constant& c);
73  Constant pos(const Constant& c);
82  Constant ceil(const Constant& c);
91  Constant floor(const Constant& c);
100  Constant minimum(const Constant& a, const Constant& b);
109  Constant maximum(const Constant& a, const Constant& b);
117  Constant operator+(const Constant& a, const Constant& b);
125  Constant operator-(const Constant& a, const Constant& b);
133  Constant operator*(const Constant& a, const Constant& b);
141  Constant operator/(const Constant& a, const Constant& b);
142 
149  Constant maximum(const MP_domain& i, const Constant& e);
156  Constant minimum(const MP_domain& i, const Constant& e);
163  Constant sum(const MP_domain& i, const Constant& e);
170  Constant product(const MP_domain& i, const Constant& e);
171 } // End of namespace flopc
172 #endif
Constant product(const MP_domain &i, const Constant &e)
Returns the sum of two constants.
Constant operator*(const Constant &a, const Constant &b)
Returns the product of two constants.
Constant maximum(const Constant &a, const Constant &b)
Returns the larger of two constants.
Constant sum(const MP_domain &i, const Constant &e)
Returns the sum of two constants.
virtual double evaluate() const =0
virtual int stage() const
Definition: MP_constant.hpp:28
Utility for doing reference counted pointers.
Constant minimum(const Constant &a, const Constant &b)
Returns the smaller of two constants.
Constant pos(const Constant &c)
for returning non-negative value of the constant.
Constant abs(const Constant &c)
for computing the absolute value of a constant value.
Reference to a set of data.
Definition: MP_data.hpp:29
Constant ceil(const Constant &c)
The ceiling integral value of the input constant.
Representation of an expression involving an index.
Definition: MP_index.hpp:145
Reference counted class for all &quot;constant&quot; types of data.
Definition: MP_constant.hpp:48
Constant operator+(const Constant &a, const Constant &b)
Returns the sum of two constants.
Base class for all &quot;constant&quot; types of data.
Definition: MP_constant.hpp:20
virtual int getStage() const
Definition: MP_constant.hpp:25
Range over which some other constuct is defined.
Definition: MP_domain.hpp:61
Constant operator/(const Constant &a, const Constant &b)
Returns the quotient of two constants.
Constant(Constant_base *r)
Definition: MP_constant.hpp:50
Constant operator-(const Constant &a, const Constant &b)
Returns the difference of two constants.
Constant floor(const Constant &c)
The floor integral value of the input constant.
virtual ~Constant_base()
Definition: MP_constant.hpp:33