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 Any_index;
25  }
27  return Empty;
28  }
29 
31  friend class MP_index_exp;
32  public:
33  private:
34  MP_index_constant(const Constant& c) : C(c) {}
35  int evaluate() const {
36  return int(C->evaluate());
37  }
38  MP_index* getIndex() const {
39  return 0;
40  }
41  virtual MP_domain getDomain(MP_set* s) const{
42  return MP_domain::getEmpty();
43  }
45  };
46 
48  friend class MP_index_exp;
49  private:
50  MP_index_subsetRef(const SUBSETREF& s) : S(&s) {}
51  int evaluate() const {
52  return int(S->evaluate());
53  }
54  MP_index* getIndex() const {
55  return S->getIndex();
56  }
57  virtual MP_domain getDomain(MP_set* s) const{
58  return MP_domain(S->getDomain(s));
59  }
60  const SUBSETREF* S;
61  };
62 
64  return new MP_index_sum(i,j);
65  }
66 
67  MP_index_exp operator+(MP_index& i,const int& j) {
68  return new MP_index_sum(i,Constant(j));
69  }
70 
72  return new MP_index_dif(i,j);
73  }
74 
75  MP_index_exp operator-(MP_index& i,const int& j) {
76  return new MP_index_dif(i,Constant(j));
77  }
78 
80  return new MP_index_mult(i,j);
81  }
82 
83 
84 } // End of namespace flopc
85 
86 using namespace flopc;
87 
88 
90  return new MP_domain_set(s,const_cast<MP_index*>(this)) ;
91 }
92 
94  return left->getDomain(s);
95 }
96 
98  return left->getDomain(s);
99 }
100 
102  return left->getDomain(s);
103 }
104 
107 
110 
113 
115  Handle<MP_index_base*>(&i) { operator->()->count++; }
116 
118  Handle<MP_index_base*>((const Handle<MP_index_base*> &)other) {}
119 
MP_index_exp left
Definition: MP_index.hpp:182
MP_index * getIndex() const
Definition: MP_index.cpp:54
virtual MP_domain getDomain(MP_set *s) const
Getter for domain over which this index is applied.
Definition: MP_index.cpp:89
static MP_index & Empty
Definition: MP_index.hpp:97
Internal representation of an index expression.
Definition: MP_index.hpp:170
Internal representation of an index expression.
Definition: MP_index.hpp:192
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_index.cpp:41
static MP_index & getEmpty()
returns a reference to the distinct "empty" index.
Definition: MP_index.cpp:20
friend class MP_domain_set
Definition: MP_index.hpp:54
MP_index_subsetRef(const SUBSETREF &s)
Definition: MP_index.cpp:50
const SUBSETREF * S
Definition: MP_index.cpp:60
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_index.cpp:93
static MP_index & Any_index
Definition: MP_index.hpp:98
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 "set".
Definition: MP_set.hpp:269
MP_index_exp left
Definition: MP_index.hpp:205
static MP_index & Any()
returns a reference to the distinct "wildcard" index.
Definition: MP_index.cpp:23
int evaluate() const
Definition: MP_set.hpp:277
virtual MP_index * getIndex() const
Definition: MP_set.hpp:271
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:215
Representation of an expression involving an index.This is one of the main public interface classes...
Definition: MP_index.hpp:141
MP_index_exp left
Definition: MP_index.hpp:228
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_index.cpp:97
static const MP_index_exp & getEmpty()
Return the unique empty expression.
Definition: MP_index.cpp:26
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
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_set.hpp:274
const MP_index_base *& operator->() const
int evaluate() const
Definition: MP_index.cpp:35
MP_index_constant(const Constant &c)
Definition: MP_index.cpp:34
MP_index * getIndex() const
Definition: MP_index.cpp:38
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 "empty" set.
Definition: MP_domain.cpp:48
MP_index_exp(MP_index_base *r)
For internal use.
Definition: MP_index.hpp:144
Representation of a set for indexing into some other construct.This is one of the main public interfa...
Definition: MP_set.hpp:79
Reference counted class for all "constant" types of data.
Definition: MP_constant.hpp:49
virtual MP_domain getDomain(MP_set *s) const
Definition: MP_index.cpp:57
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:101
Internal representation of a index.
Definition: MP_index.hpp:26
static MP_index_exp Empty
Definition: MP_index.hpp:161