This file is indexed.

/usr/include/trilinos/EpetraExt_DistArray.h is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.

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
#ifndef EPETRAEXT_DISTARRAY_H
#define EPETRAEXT_DISTARRAY_H

#include "EpetraExt_ConfigDefs.h"
#include "EpetraExt_Exception.h"
#include "Epetra_Map.h"
#include "Epetra_DistObject.h"

namespace EpetraExt 
{
/*! 
\brief DistArray<T>: A class to store row-oriented multivectors of type T

Class DistArray allows the construction and usage of multivectors. These 
vectors contain element of type T, and the storage is row-oriented, and not
column-oriented as in class Epetra_MultiVector. As such, this class should
be used as a container for data, on which no BLAS-like operations are
performed. 

DistArray objects are indentified by an \c Epetra_Map and a \c RowSize. The 
map specifies the distribution of the elements across the processors and
therefore the number of local elements, while the RowSize gives the
total number of data assigned to each node. RowSize is constant for all
elements.

DistArray is derived from Epetra_DistObject, and it can therefore be
redistributed using Import/Export instructions.

The typical usage of this class is as follows:
\code
EpetraExt::DistArray<double> COO(VertexMap, NumDimensions);

// set the value of the j-th dimension of the i-th local node i:
COO(i, j) = 1.24
\endcode

\author Marzio Sala, ETHZ/D-INFK.

\date Last updated on Mar-06.
*/
  template<class T>
  class DistArray : public Epetra_DistObject
  {
    public:
      // @{ \name Constructors and Destructors

      //! Constructor for a given \c Map and \c RowSize.
      DistArray(const Epetra_Map& Map, const int RowSize) :
        Epetra_DistObject(Map)
      {
        // only Epetra_Map's with constant element size of 1 are allowed
        if (Map.MaxElementSize() != 1) 
          throw(Exception(__FILE__, __LINE__,
                          "Map.MaxElementSize() != 1"));
        if (!Map.ConstantElementSize()) 
          throw(Exception(__FILE__, __LINE__,
                          "Map.ConstantElementSize() != true"));

        MyLength_     = Map.NumMyElements();
        GlobalLength_ = Map.NumGlobalElements();
        RowSize_      = RowSize;
        count_        = 0;
        values_.resize(MyLength_ * RowSize_);
      }

      // @}
      // @{ \name Query methods

      //! Returns the length of the locally owned array.
      inline int MyLength() const
      {
        return(MyLength_);
      }

      //! Returns the global length of the array.
      inline int GlobalLength() const
      {
        return(GlobalLength_);
      }

      //! Returns the row size, that is, the amount of data associated with each element.
      inline int RowSize() const
      {
        return(RowSize_);
      }

      //! Returns a reference to the \c ID component of the \c LEID local element.
      inline T& operator()(const int LEID, const int ID)
      {
        assert (ID <= RowSize_);
        return(values_[LEID * RowSize_ + ID]);
      }

      inline T& operator()(const int GEID, const int ID, const bool isLocal)
      {
        int LEID = Map().LID(GEID);
        assert (LEID != -1);
        assert (ID <= RowSize_);
        return(values_[LEID * RowSize_ + ID]);
      }

      //! Prints the array on the specified stream.
      void Print(std::ostream& os) const
      {
        os << "DistArray object, label   = " << this->Label() << std::endl;
        os << "Number of local elements  = " << Map().NumMyElements() << std::endl;
        os << "Number of global elements = " << Map().NumGlobalElements() << std::endl;
        os << std::endl;

        for (int iproc=0; iproc < Comm().NumProc(); iproc++) 
        {
          if (iproc == 0)
          {
            os << "GEID\t";
            for (int i = 0; i < RowSize(); ++i) os << "V\t";
            os << std::endl;
          }

          if (Comm().MyPID() == iproc) 
          {
            for (int i = 0; i < Map().NumMyElements(); ++i)
            {
              os << Map().GID(i) << '\t';
              for (int j = 0; j < RowSize_; ++j)
                os << values_[i * RowSize_ + j] << '\t';
              os << std::endl;
            }
          }
        }
        os << std::endl;
      }

      int NextGID()
      {
        ++count_;
        if (count_ < Map().NumMyElements())
          return(Map().GID(count_));
        else
          return(-1);
      }

      int FirstGID()
      {
        count_ = 0;
        return(Map().GID(0));
      }

      //! Extracts a view of the array.
      const std::vector<T>& ExtractView() const
      {
        return(values_);
      }

      //! Returns a pointer to the internally stored data (non-const version).
      T* Values() 
      {
        return(&values_[0]);
      }

      //! Returns a pointer to the internally stored data (const version).
      const T* Values() const
      {
        return(&values_[0]);
      }

      // @}
    private:
      // @{ \name Epetra_DistObject methods

      virtual int CheckSizes(const Epetra_SrcDistObject& Source)
      {
        return(0);
      }

      virtual int CopyAndPermute(const Epetra_SrcDistObject& Source,
                                 int NumSameIDs,
                                 int NumPermuteIDs,
                                 int * PermuteToLIDs,
                                 int * PermuteFromLIDs,
                                 const Epetra_OffsetIndex * Indexor)
      {
        const DistArray& S = dynamic_cast<const DistArray&>(Source);
        const std::vector<T>& From = S.ExtractView();

        std::vector<T>& To = values_;

        //int * ToFirstPointInElementList = 0;
        //int * FromFirstPointInElementList = 0;
        //int * FromElementSizeList = 0;

        int j;

        int NumSameEntries;

        NumSameEntries = NumSameIDs;

        // Short circuit for the case where the source and target std::vector is the same.
        if (To==From) NumSameEntries = 0;

        // Do copy first
        if (NumSameIDs>0)
          if (To!=From) {
            for (j=0; j<NumSameEntries * RowSize_; j++)
            {
              To[j] = From[j];
            }
          }

        // Do local permutation next
        if (NumPermuteIDs>0) {

          for (j=0; j<NumPermuteIDs * RowSize_; j++) 
            To[PermuteToLIDs[j]] = From[PermuteFromLIDs[j]];
          // constant element size case
        }

        return(0);
      }

      virtual int PackAndPrepare(const Epetra_SrcDistObject& Source,
                                 int NumExportIDs,
                                 int* ExportLIDs,
                                 int& LenExports,
                                 char*& Exports,
                                 int& SizeOfPacket,
                                 int* Sizes,
                                 bool & VarSizes,
                                 Epetra_Distributor& Distor)
      {
        const DistArray& S = dynamic_cast<const DistArray&>(Source);
        const std::vector<T>& From = S.ExtractView();

        std::vector<T> To = values_;

        //int * FromFirstPointInElementList = 0;
        //int * FromElementSizeList = 0;

        SizeOfPacket = RowSize_ * sizeof(T); 

        if(NumExportIDs*SizeOfPacket>LenExports) {
          if (LenExports>0) delete [] Exports;
          LenExports = NumExportIDs*SizeOfPacket;
          Exports = new char[LenExports];
        }

        T* ptr;

        if (NumExportIDs>0) {
          ptr = (T*) Exports;

          // Point entry case
          for (int j=0; j<NumExportIDs; j++) 
            for (int k = 0; k < RowSize_ ; ++k)
              *ptr++ = From[ExportLIDs[j] * RowSize_ + k];
        }

        return(0);
      }

      virtual int UnpackAndCombine(const Epetra_SrcDistObject& Source,
                                   int NumImportIDs,
                                   int* ImportLIDs,
                                   int LenImports,
                                   char* Imports,
                                   int& SizeOfPacket,
                                   Epetra_Distributor& Distor,
                                   Epetra_CombineMode CombineMode,
                                   const Epetra_OffsetIndex * Indexor)
      {
        int j;

        if (CombineMode != Insert)
          EPETRA_CHK_ERR(-1); //Unsupported CombinedMode, will default to Zero

        std::cout << NumImportIDs << std::endl;
        if (NumImportIDs<=0) return(0);

        T* To = &values_[0];
        //int * ToFirstPointInElementList = 0;
        //int * ToElementSizeList = 0;

        T* ptr;
        // Unpack it...

        ptr = (T*) Imports;

        for (j=0; j<NumImportIDs; j++) 
          for (int k = 0; k < RowSize_ ; ++k)
            To[ImportLIDs[j] * RowSize_ + k] = *ptr++;

        return(0);
      }

      // @}
      // @{ \name Private data
      
      //! Container of local data
      std::vector<T> values_;
      //! Length of the locally owned array.
      int MyLength_;
      //! Length of the global array.
      int GlobalLength_;
      //! Amount of data associated with each element.
      int RowSize_;
      int count_;
      int last_;
      // @}
  };

} // namespace EpetraExt

#endif