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