FLOPC++
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 
49  class Constant : public Handle<Constant_base*> {
50  public:
51  Constant(const MP_index_exp& i);
52  Constant(const DataRef& d);
53  Constant(double d);
54  Constant(int d);
55  // operator-();
56  // private:
58  };
59 
60  Constant operator-(const Constant& a);
61 
68  Constant abs(const Constant& c);
78  Constant pos(const Constant& c);
87  Constant ceil(const Constant& c);
96  Constant floor(const Constant& c);
105  Constant minimum(const Constant& a, const Constant& b);
114  Constant maximum(const Constant& a, const Constant& b);
122  Constant operator+(const Constant& a, const Constant& b);
130  Constant operator-(const Constant& a, const Constant& b);
138  Constant operator*(const Constant& a, const Constant& b);
146  Constant operator/(const Constant& a, const Constant& b);
147 
148  class MP_boolean;
149  Constant mpif(const MP_boolean& c, const Constant& a, const Constant& b);
150 
157  Constant maximum(const MP_domain& i, const Constant& e);
164  Constant minimum(const MP_domain& i, const Constant& e);
171  Constant sum(const MP_domain& i, const Constant& e);
178  Constant product(const MP_domain& i, const Constant& e);
179 } // End of namespace flopc
180 #endif
Constant maximum(const Constant &a, const Constant &b)
Returns the larger of two constants.This is used in the formation of an expression.
virtual double evaluate() const =0
Constant abs(const Constant &c)
for computing the absolute value of a constant value.This is used in the normal formation of an expre...
Definition: MP_constant.cpp:48
Constant operator/(const Constant &a, const Constant &b)
Returns the quotient of two constants.This is used in the formation of an expression.
Constant product(const MP_domain &i, const Constant &e)
Returns the sum of two constants.
Utility for doing reference counted pointers.
Constant ceil(const Constant &c)
The ceiling integral value of the input constant.This is used in the formation of an expression...
Definition: MP_constant.cpp:79
Constant floor(const Constant &c)
The floor integral value of the input constant.This is used in the formation of an expression...
Definition: MP_constant.cpp:92
Constant operator+(const Constant &a, const Constant &b)
Returns the sum of two constants.This is used in the formation of an expression.
Constant mpif(const MP_boolean &c, const Constant &a, const Constant &b)
Representation of an expression involving an index.This is one of the main public interface classes...
Definition: MP_index.hpp:141
Base class for all "constant" types of data.
Definition: MP_constant.hpp:20
friend class Constant
Definition: MP_constant.hpp:21
Reference to a set of data.
Definition: MP_data.hpp:27
Constant operator-(const Constant &a, const Constant &b)
Returns the difference of two constants.This is used in the formation of an expression.
All flopc++ code is contained within the flopc namespace.
Definition: flopc.cpp:11
Constant(Constant_base *r)
Definition: MP_constant.hpp:57
Constant minimum(const Constant &a, const Constant &b)
Returns the smaller of two constants.This is used in the formation of an expression.
Reference counted class for all "boolean" types of data.This contains counters to ConstantBase pointe...
Definition: MP_boolean.hpp:40
Range over which some other constuct is defined.This is one of the main public interface classes...
Definition: MP_domain.hpp:61
virtual int getStage() const
Definition: MP_constant.hpp:25
virtual int stage() const
Definition: MP_constant.hpp:28
Constant pos(const Constant &c)
for returning non-negative value of the constant.This is used in the formation of an expression...
Definition: MP_constant.cpp:66
Reference counted class for all "constant" types of data.
Definition: MP_constant.hpp:49
Constant operator*(const Constant &a, const Constant &b)
Returns the product of two constants.This is used in the formation of an expression.
virtual ~Constant_base()
Definition: MP_constant.hpp:33
Constant sum(const MP_domain &i, const Constant &e)
Returns the sum of two constants.