This file is indexed.

/usr/include/coin/MP_set.hpp is in coinor-libflopc++-dev 1.0.6-3.1+b1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
// ******************** FlopCpp **********************************************
// File: MP_set.hpp
// $Id$
// Author: Tim Helge Hultberg (thh@mat.ua.pt)
// Copyright (C) 2003 Tim Helge Hultberg
// All Rights Reserved.
// ****************************************************************************

#ifndef _MP_set_hpp_
#define _MP_set_hpp_

#include <iostream>
#include <sstream>
using std::cout;
using std::endl;

#include <string>
using std::string;

#include "MP_domain.hpp"
#include "MP_index.hpp"
#include "MP_utilities.hpp"

namespace flopc {

/** @brief Internal representation of a "set" 
    @ingroup INTERNAL_USE
    @note FOR INTERNAL USE: This is not normally used directly by the calling code.
*/
  class MP_set_base : public MP_index , public Named {
  public:
    MP_set_base() : Cyclic(false) {}

    virtual int size() const = 0;
    virtual operator MP_domain() const = 0;
    virtual MP_domain operator()(const MP_index_exp& i) const = 0;
 
    int check(int i) const {
      if ((i>=0) && (i<size())) {
        return i;
      } else {
        if (Cyclic == true) {
          return mod(i,size());
        } else {
          return outOfBound;
        }
      }
    }
    int checkStage(int i) const {
      if ((i>=0) && (i<size())) {
        return i*isStage();
      } else {
        if (Cyclic == true) {
          return mod(i,size())*isStage();
        } else {
          return outOfBound;
        }
      }
    }
    ///
    virtual int isStage() const {
      return 0;
    }

    bool Cyclic;
  };

    
/** @brief Representation of a set for indexing into some other construct.
    @ingroup PublicInterface
    This is one of the main public interface classes.  One uses this when
    constructing MP_domains, and subsets.
    It is frequent that one would directly construct sets of indices, then
    use expressions to subset or slice the data.
    @note term: cardinality is the number of elements in the set.
    @note term: dimension is the number of indices used to reference into it.
    @note there is a distince 'empty' MP_set
*/
  class MP_set : public MP_set_base {
  public:
    /// constructs a set with specific cardinality.
    MP_set(int i = 0): cardinality(i) {}
    /** @brief Constructs an MP_domain on the stack given an index expression
        into the set.
        @todo is the internal use?
    */
    MP_domain operator()(const MP_index_exp& i) const {
      return i->getDomain(const_cast<MP_set*>(this));
    }
    /// @brief constructs an MP_domain from the MP_set.
    operator MP_domain() const {
      return new MP_domain_set(this,const_cast<MP_set*>(this));
    }
    /** @brief constructs  a domain by subsetting this MP_set where
        the MP_boolean evaluates to 'true'
    */
    MP_domain such_that(const MP_boolean& b) {
      return (MP_domain(new MP_domain_set(this,this))).such_that(b);
    }
    /** setter for 'cyclic' property
        @todo better explain the use of cyclic.
    */
    void cyclic() {
      Cyclic = true;
    }
    /// getter for the cardinality of this MP_set.
    virtual int size() const {
      return cardinality;
    }
    int last() {
      return cardinality-1;
    }
    /// gets the distinct 'empty' MP_set.
    static MP_set &getEmpty();
  private:
    static MP_set Empty;
    int cardinality;
  };
    
  class MP_stage : public MP_set {
  public:
    MP_stage(int i = 0): MP_set(i) {}
    virtual int isStage() const {
      return 1;
    }
  };

  template <int nbr> class MP_subset;

/** @brief Internal representation of a "set" 
    @ingroup INTERNAL_USE
    @note FOR INTERNAL USE: This is not normally used directly by the calling code.
*/

  template<int nbr> class InsertFunctor : public Functor {
  public:
    InsertFunctor( MP_subset<nbr>* s, vector<MP_index_exp> i) 
      : S(s), I(i) {}
    void operator()() const { 
      vector<int> elm(nbr);
      for (int i=0; i<nbr; i++) {
        elm[i] = I[i]->evaluate();
      }
      S->insert(elm);
    }
  private:
    MP_subset<nbr>* S;
    vector<MP_index_exp> I;
  };

  template <int nbr> class SubsetRef;

/** @brief Internal representation of a "set" 
    @ingroup INTERNAL_USE
    @note FOR INTERNAL USE: This is not normally used directly by the
    calling code.
    @note this is often implicitly created with many expressions which may
    subset a set.
*/

  template <int nbr>
  class MP_subset : public MP_set {
    friend class MP_domain_subset<nbr>;
    friend class SubsetRef<nbr>;
  public:
    MP_subset(const MP_set& s1, 
              const MP_set& s2=MP_set::getEmpty(), 
              const MP_set& s3=MP_set::getEmpty(), 
              const MP_set& s4=MP_set::getEmpty(), 
              const MP_set& s5=MP_set::getEmpty()) {
      S = makeVector<nbr,const MP_set*>(&s1,&s2,&s3,&s4,&s5);
    }

    void display(const std::string& s = "") const {
      std::map<std::vector<int>, int>::const_iterator i;
      cout<<s<<endl;
      for (i = elements.begin(); i != elements.end(); i++) {
        for (int j=0; j<nbr; j++) {
          cout<<(*i).first[j]<<"  ";
        }
        cout<<endl;
      }
    }

    MP_subset(vector<const MP_set*> s) : S(s) {}

    ~MP_subset() {}

    int operator()(int i1, int i2=0, int i3=0, int i4=0, int i5=0) {
      std::map<vector<int>, int>::const_iterator pos;
      pos = elements.find(makeVector<nbr>(i1, i2, i3, i4, i5));
      if (pos==elements.end()) {
        return outOfBound;
      } else {
        return pos->second;
      }
    }

    SubsetRef<nbr>& operator()(const MP_index_exp& i1, 
                               const MP_index_exp& i2=MP_index::getEmpty(),  
                               const MP_index_exp& i3=MP_index::getEmpty(),
                               const MP_index_exp& i4=MP_index::getEmpty(),
                               const MP_index_exp& i5=MP_index::getEmpty()) {
      return *new SubsetRef<nbr>(this,i1,i2,i3,i4,i5);
    }

    MP_domain& operator()(const SUBSETREF& s) {
      return MP_domain(s);
    }

    int evaluate(const vector<MP_index*>& I) const {
      vector<int> vi;
      for (int k=0; k<nbr; k++) {
        int temp = I[k]->evaluate();
        vi.push_back(temp);
      }
      std::map<vector<int>, int>::const_iterator pos;
      pos = elements.find(vi);
      if (pos==elements.end()) {
        return outOfBound;
      } else {
        return pos->second;
      }
    }
    
    void insert(const vector<int> &args) {
      bool isOk = true;
      for (int i=0; i<nbr; i++) {
        if ( S[i]->check(args[i]) == outOfBound ) {
          isOk = false;
        }
      }
      if (isOk == true) {
        std::map<vector<int>, int>::const_iterator pos;
        pos = elements.find(args);
        if (pos==elements.end()) {  // insert if not existent
          const int v = elements.size();
          elements[args] = v;
        }
      }
    }
    void insert(int i1, int i2=0, int i3=0, int i4=0, int i5=0) {
      insert(makeVector<nbr>(i1, i2, i3, i4, i5));
    }
    const InsertFunctor<nbr>& insert(MP_index_exp i1, 
                                     MP_index_exp i2=MP_index_exp::getEmpty(), 
                                     MP_index_exp i3=MP_index_exp::getEmpty(), 
                                     MP_index_exp i4=MP_index_exp::getEmpty(), 
                                     MP_index_exp i5=MP_index_exp::getEmpty()) {
      return *new InsertFunctor<nbr>(this,makeVector<nbr>(i1, i2, i3, i4, i5));
    }
    virtual int size() const {
      return elements.size();
    }

  private:
    vector<const MP_set*> S; 
    std::map<std::vector<int>, int> elements;
  };

/** @brief Internal representation of a "set" 
    @ingroup INTERNAL_USE
    @note FOR INTERNAL USE: This is not normally used directly by the
    calling code.
    @note this is often implicitly created with many expressions which may
    subset a set.
*/

  class SUBSETREF : public MP_index_base {
  public:
    virtual MP_index* getIndex() const {
      return 0;
    }
    virtual MP_domain getDomain(MP_set* s) const {
      return MP_domain::getEmpty();
    }
    int evaluate() const {
      return 0;
    }
  };

/** @brief Internal representation of a "set" 
    @ingroup INTERNAL_USE
    @note FOR INTERNAL USE: This is not normally used directly by the
    calling code.
    @note this is often implicitly created with many expressions which may
    subset a set.
*/
  template <int nbr>
  class SubsetRef : public SUBSETREF {
  public:
    SubsetRef(MP_subset<nbr>* s, 
              const MP_index_exp& i1,
              const MP_index_exp& i2,
              const MP_index_exp& i3,
              const MP_index_exp& i4,
              const MP_index_exp& i5) : 
      S(s),I1(i1),I2(i2),I3(i3),I4(i4),I5(i5) {} 
    
    operator MP_domain() const {
// 	    MP_domain_base* base;
// 	    base = new MP_domain_subset<nbr>(S,
// 		makeVector<nbr>(I1->getIndex(), I2->getIndex(), 
// 				I3->getIndex(), I4->getIndex(), 
// 				I5->getIndex()) );
// 	    base->such_that(B);
// 	    return base; 
      return new MP_domain_subset<nbr>(S,
                                       makeVector<nbr>(I1->getIndex(), I2->getIndex(), 
                                                       I3->getIndex(), I4->getIndex(), 
                                                       I5->getIndex()) );
    }
    
    virtual MP_domain getDomain(MP_set* s) const {
      return new MP_domain_subset<nbr>(S,
                                       makeVector<nbr>(I1->getIndex(), I2->getIndex(), 
                                                       I3->getIndex(), I4->getIndex(), 
                                                       I5->getIndex()) );
    }

//     const MP_domain& such_that(const MP_boolean& b) {
//       return MP_domain().such_that(b);
//     }

    SubsetRef& such_that(const MP_boolean& b) {
      B = b;
      return *this;
    }

    int evaluate() const {
      vector<MP_index_exp> I = makeVector<nbr>(I1,I2,I3,I4,I5);
      vector<int> vi;
      for (int k=0; k<nbr; k++) {
        int temp = I[k]->evaluate();
        vi.push_back(temp);
      }
      std::map<vector<int>, int>::const_iterator pos;
      pos = S->elements.find(vi);
      if (pos==S->elements.end()) {
        return outOfBound;
      } else {
        return pos->second;
      }

    }
    MP_index* getIndex() const {
      return S;
    }
    MP_boolean B;
    MP_subset<nbr>* S;
    MP_index_exp I1,I2,I3,I4,I5;
  };

} // End of namespace flopc
#endif