FLOPC++
MP_index.cpp
Go to the documentation of this file.
1 // ******************** FlopCpp **********************************************
2 // File: MP_index.cpp
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 #include "MP_index.hpp"
10 #include "MP_domain.hpp"
11 #include "MP_set.hpp"
12 #include "MP_model.hpp"
13 
14 namespace flopc {
15  // Initialization of static member data
19 
21  return Empty;
22  }
24  return Empty;
25  }
26 
27  void MP_index_base::display()const {
29  }
30 
32  friend class MP_index_exp;
33  public:
34  void display()const {
36  }
37  private:
38  MP_index_constant(const Constant& c) : C(c) {}
39  int evaluate() const {
40  return int(C->evaluate());
41  }
42  MP_index* getIndex() const {
43  return 0;
44  }
45  virtual MP_domain getDomain(MP_set* s) const{
46  return MP_domain::getEmpty();
47  }
49  };
50 
52  friend class MP_index_exp;
53  public:
54  void display()const {
56  }
57  private:
58  MP_index_subsetRef(const SUBSETREF& s) : S(&s) {}
59  int evaluate() const {
60  return int(S->evaluate());
61  }
62  MP_index* getIndex() const {
63  return S->getIndex();
64  }
65  virtual MP_domain getDomain(MP_set* s) const{
66  return MP_domain(S->getDomain(s));
67  }
68  const SUBSETREF* S;
69  };
70 
72  return new MP_index_sum(i,j);
73  }
74 
75  MP_index_exp operator+(MP_index& i,const int& j) {
76  return new MP_index_sum(i,Constant(j));
77  }
78 
80  return new MP_index_dif(i,j);
81  }
82 
83  MP_index_exp operator-(MP_index& i,const int& j) {
84  return new MP_index_dif(i,Constant(j));
85  }
86 
88  return new MP_index_mult(i,j);
89  }
90 
91 
92 } // End of namespace flopc
93 
94 using namespace flopc;
95 
96 
98  return new MP_domain_set(s,const_cast<MP_index*>(this)) ;
99 }
100 
102  return left->getDomain(s);
103 }
104 
106  return left->getDomain(s);
107 }
108 
110  return left->getDomain(s);
111 }
112 
115 
118 
121 
123  Handle<MP_index_base*>(&i) { operator->()->count++; }
124 
126  Handle<MP_index_base*>((const Handle<MP_index_base*> &)other) {}
127 
MP_index_exp left
Definition: MP_index.hpp:186
MP_index * getIndex() const
Definition: MP_index.cpp:62
virtual MP_domain getDomain(MP_set *s) const
Getter for domain over which this index is applied.
Definition: MP_index.cpp:97
static MP_index & Empty
Definition: MP_index.hpp:102
Internal representation of an index expression.
Definition: MP_index.hpp:174
Internal representation of an index expression.
Definition: MP_index.hpp:196
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_index.cpp:45
static MP_index & getEmpty()
returns a reference to the distinct &quot;empty&quot; index.
Definition: MP_index.cpp:20
MP_index_subsetRef(const SUBSETREF &s)
Definition: MP_index.cpp:58
void display() const
Definition: MP_index.cpp:54
const SUBSETREF * S
Definition: MP_index.cpp:68
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_index.cpp:101
Representation of an index.This is one of the main public interface classes. It is used to iterate th...
Definition: MP_index.hpp:53
Internal representation of a &quot;set&quot;.
Definition: MP_set.hpp:273
MP_index_exp left
Definition: MP_index.hpp:209
int evaluate() const
Definition: MP_set.hpp:281
virtual MP_index * getIndex() const
Definition: MP_set.hpp:275
Utility for doing reference counted pointers.
Constant operator+(const Constant &a, const Constant &b)
Returns the sum of two constants.This is used in the formation of an expression.
Internal representation of an index expression.
Definition: MP_index.hpp:219
Representation of an expression involving an index.This is one of the main public interface classes...
Definition: MP_index.hpp:145
MP_index_exp left
Definition: MP_index.hpp:232
Range over which some other constuct is defined.This is one of the main public interface classes...
Definition: MP_domain.hpp:110
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_index.cpp:105
static const MP_index_exp & getEmpty()
Return the unique empty expression.
Definition: MP_index.cpp:23
static MP_index & Any
Definition: MP_index.hpp:97
void display() const
Definition: MP_index.cpp:34
Constant operator-(const Constant &a, const Constant &b)
Returns the difference of two constants.This is used in the formation of an expression.
virtual void display() const
Definition: MP_index.cpp:27
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_set.hpp:278
const MP_index_base *& operator->() const
int evaluate() const
Definition: MP_index.cpp:39
MP_index_constant(const Constant &c)
Definition: MP_index.cpp:38
MP_index * getIndex() const
Definition: MP_index.cpp:42
Range over which some other constuct is defined.This is one of the main public interface classes...
Definition: MP_domain.hpp:61
static const MP_domain & getEmpty()
returns a reference to the &quot;empty&quot; set.
Definition: MP_domain.cpp:48
MP_index_exp(MP_index_base *r)
For internal use.
Definition: MP_index.hpp:148
Representation of a set for indexing into some other construct.This is one of the main public interfa...
Definition: MP_set.hpp:78
Reference counted class for all &quot;constant&quot; types of data.
Definition: MP_constant.hpp:48
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_index.cpp:65
Constant operator*(const Constant &a, const Constant &b)
Returns the product of two constants.This is used in the formation of an expression.
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_index.cpp:109
Internal representation of a index.
Definition: MP_index.hpp:26
static MP_index_exp Empty
Definition: MP_index.hpp:165