queso-0.51.1
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,2009,2010,2011,2012,2013 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:
59 
61 
62 
64  DistArray();
65 
67  DistArray(const Map& inputMap,
68  const int inputRowSize);
69 
71  DistArray(const DistArray<T>& src);
72 
74  ~DistArray();
76 
78 
82 
84 
85 
87  T& operator ()(int localElementId, int colId);
88 
90  const T& operator ()(int localElementId, int colId) const;
91 
93  int GlobalLength() const;
94 
96  int MyLength () const;
97 
99  int RowSize () const;
100 
102 
104 
105  void print (std::ostream& os) const;
106  friend std::ostream & operator<<(std::ostream& os, const DistArray<T>& obj)
107  {
108  obj.print(os);
109 
110  return os;
111  }
113 
114 private:
116 
117  void copy (const DistArray<T>& src);
118 
120 #ifdef QUESO_HAS_TRILINOS
121  EpetraExt::DistArray<T>* m_epetraDistArray;
122 #else
123  unsigned int m_rowSize;
124  std::vector<std::vector<T> > m_elements;
125 #endif
126 };
127 
128 } // End namespace QUESO
129 
130 #endif // UQ_DIST_ARRAY_H
A class for partitioning vectors and matrices.
Definition: Map.h:49
~DistArray()
Destructor.
Definition: DistArray.C:82
void print(std::ostream &os) const
Definition: DistArray.C:178
int RowSize() const
Returns the row size, that is, the amount of data associated with each element.
Definition: DistArray.C:158
int MyLength() const
Returns the length of the locally owned array.
Definition: DistArray.C:147
void copy(const DistArray< T > &src)
Copies the array.
Definition: DistArray.C:170
T & operator()(int localElementId, int colId)
Returns a reference to the colId column component of the localElementId local element.
Definition: DistArray.C:114
unsigned int m_rowSize
Definition: DistArray.h:123
A class for partitioning vectors and matrices.
Definition: DistArray.h:56
DistArray< T > & operator=(const DistArray< T > &rhs)
Assignment operator.
Definition: DistArray.C:98
std::vector< std::vector< T > > m_elements
Definition: DistArray.h:124
DistArray()
Default constructor. Do not call this directly.
Definition: DistArray.C:36
int GlobalLength() const
Returns the global length of the array.
Definition: DistArray.C:136

Generated on Thu Apr 23 2015 19:26:15 for queso-0.51.1 by  doxygen 1.8.5