queso-0.53.0
DistArray.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2015 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #ifndef UQ_DIST_ARRAY_H
26 #define UQ_DIST_ARRAY_H
27 
28 #include <queso/Defines.h>
29 #include <queso/Map.h>
30 #ifdef QUESO_HAS_TRILINOS
31 #include <EpetraExt_DistArray.h>
32 #endif
33 #include <ostream>
34 
35 namespace QUESO {
36 
55 template <typename T>
56 class DistArray
57 {
58 public:
60 
61 
63  DistArray(const Map& inputMap,
64  const int inputRowSize);
65 
67  DistArray(const DistArray<T>& src);
68 
70  ~DistArray();
72 
74 
78 
80 
81 
83  T& operator ()(int localElementId, int colId);
84 
86  const T& operator ()(int localElementId, int colId) const;
87 
89  int GlobalLength() const;
90 
92  int MyLength () const;
93 
95  int RowSize () const;
96 
98 
100 
101  void print (std::ostream& os) const;
102  friend std::ostream & operator<<(std::ostream& os, const DistArray<T>& obj)
103  {
104  obj.print(os);
105 
106  return os;
107  }
109 
110 private:
112  DistArray();
113 
115  void copy (const DistArray<T>& src);
116 
118 #ifdef QUESO_HAS_TRILINOS
119  EpetraExt::DistArray<T>* m_epetraDistArray;
120 #else
121  unsigned int m_rowSize;
122  std::vector<std::vector<T> > m_elements;
123 #endif
124 };
125 
126 } // End namespace QUESO
127 
128 #endif // UQ_DIST_ARRAY_H
int GlobalLength() const
Returns the global length of the array.
Definition: DistArray.C:126
DistArray< T > & operator=(const DistArray< T > &rhs)
Assignment operator.
Definition: DistArray.C:88
~DistArray()
Destructor.
Definition: DistArray.C:72
DistArray()
Default constructor. Do not call this directly.
unsigned int m_rowSize
Definition: DistArray.h:121
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:122
void copy(const DistArray< T > &src)
Copies the array.
Definition: DistArray.C:160
int MyLength() const
Returns the length of the locally owned array.
Definition: DistArray.C:137
int RowSize() const
Returns the row size, that is, the amount of data associated with each element.
Definition: DistArray.C:148
A class for partitioning vectors and matrices.
Definition: DistArray.h:56
T & operator()(int localElementId, int colId)
Returns a reference to the colId column component of the localElementId local element.
Definition: DistArray.C:104
A class for partitioning vectors and matrices.
Definition: Map.h:49
void print(std::ostream &os) const
Definition: DistArray.C:168

Generated on Thu Jun 11 2015 13:52:31 for queso-0.53.0 by  doxygen 1.8.5