All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Xpetra_EpetraIntVector.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jeremie Gaidamour (jngaida@sandia.gov)
40 // Jonathan Hu (jhu@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_EPETRAINTVECTOR_HPP
47 #define XPETRA_EPETRAINTVECTOR_HPP
48 
50 
51 #include "Xpetra_ConfigDefs.hpp"
52 #include "Xpetra_MultiVector.hpp"
53 #include "Xpetra_Vector.hpp"
54 #include "Xpetra_Exceptions.hpp"
55 
56 #include "Xpetra_EpetraMap.hpp"
58 #include "Epetra_IntVector.h"
59 
60 namespace Xpetra {
61 
63  : public Vector<int,int,int>
64  {
65 
66  typedef int Scalar;
67  typedef int LocalOrdinal;
68  typedef int GlobalOrdinal;
70 
71  public:
72 
74 
75 
77  explicit EpetraIntVector(const Teuchos::RCP<const Map<int,int> > &map, bool zeroOut=true)
78  {
79  XPETRA_RCP_DYNAMIC_CAST(const EpetraMap, map, eMap, "Xpetra::EpetraCrsMatrix constructors only accept Xpetra::EpetraMap as input arguments.");
80  vec_ = rcp(new Epetra_IntVector(eMap->getEpetra_BlockMap(), zeroOut));
81  }
82 
85 
87 
89 
90 
92  int dot(const Vector<int,int,int> &a) const;
93 
96 
99 
102 
105 
107  int meanValue() const;
108 
110  int maxValue() const;
111 
113 
115 
116 
118  void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value);
119 
121  void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value);
122 
124  void replaceLocalValue(LocalOrdinal myRow, const Scalar &value);
125 
127  void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value);
128 
130  void putScalar(const int &value) { vec_->PutValue(value); }
131 
133  void randomize(bool bUseXpetraImplementation = true);
134 
136 
137  void setSeed(unsigned int seed);
138 
140 
142 
143 
146 
149 
152  Teuchos::ArrayRCP<const int> getData(size_t j) const;
153 
157 
159 
161 
164 
167 
170 
172  void scale(const int &alpha);
173 
175  void update(const int &alpha, const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &A, const int &beta);
176 
178  void update(const int &alpha, const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &A, const int &beta, const MultiVector<int,int,int,Kokkos::DefaultNode::DefaultNodeType> &B, const int &gamma);
179 
182 
185 
188 
191 
193  void meanValue(const Teuchos::ArrayView<int> &means) const;
194 
196  void maxValue(const Teuchos::ArrayView<int> &maxs) const;
197 
200 
204 
206 
207 
209  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value);
210 
212  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value);
213 
215  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value);
216 
218  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value);
219 
221 
223 
224 
226  size_t getNumVectors() const;
227 
229  size_t getLocalLength() const { return vec_->MyLength(); }
230 
232  global_size_t getGlobalLength() const { return vec_->GlobalLength(); }
233 
235 
237 
238 
240  std::string description() const;
241 
244 
246 
248 
249  const RCP<const Comm<int> > getComm() const {
250  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO getComm Epetra MultiVector not implemented");
251  }
252 
253  // Implementing DistObject
255  RCP<const Epetra_BlockMap> map = rcp(new Epetra_BlockMap(vec_->Map()));
256  return rcp ( new Xpetra::EpetraMap(map) );
257  }
258 
259  void doImport(const DistObject<int, int, int> &source, const Import<int, int> &importer, CombineMode CM);
260 
261  void doExport(const DistObject<int, int, int> &dest, const Import<int, int>& importer, CombineMode CM);
262 
263  void doImport(const DistObject<int, int, int> &source, const Export<int, int>& exporter, CombineMode CM);
264 
265  void doExport(const DistObject<int, int, int> &dest, const Export<int, int>& exporter, CombineMode CM);
266 
267  void replaceMap(const RCP<const Map<int,int> >& map) {
268  // do nothing
269  }
270 
271  private:
273 
274  }; // class EpetraIntVector
275 
276 } // namespace Xpetra
277 
278 #endif // XPETRA_EPETRAINTVECTOR_HPP
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
void reciprocal(const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A)
Puts element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
void elementWiseMultiply(int scalarAB, const Vector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A, const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &B, int scalarThis)
Element-wise multiply of a Vector A with a EpetraMultiVector B.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
Teuchos::ScalarTraits< int >::magnitudeType normInf() const
Compute Inf-norm of this Vector.
void update(const int &alpha, const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A, const int &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
std::string description() const
Return a simple one-line description of this object.
Kokkos::DefaultNode::DefaultNodeType Node
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::ArrayRCP< const int > getData(size_t j) const
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
global_size_t getGlobalLength() const
Returns the global vector length of vectors in the multi-vector.
void doExport(const DistObject< int, int, int > &dest, const Import< int, int > &importer, CombineMode CM)
size_t getLocalLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const int &alpha, const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A, const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &B, const int &beta)
Matrix-Matrix multiplication, this = beta*this + alpha*op(A)*op(B).
void randomize(bool bUseXpetraImplementation=true)
Set multi-vector values to random numbers.
Teuchos::ScalarTraits< int >::magnitudeType norm2() const
Compute 2-norm of this Vector.
int dot(const Vector< int, int, int > &a) const
TODO missing comment.
void replaceMap(const RCP< const Map< int, int > > &map)
const RCP< const Comm< int > > getComm() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setSeed(unsigned int seed)
Set seed for Random function.
Teuchos::ScalarTraits< int >::magnitudeType norm1() const
Return 1-norm of this Vector.
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
void putScalar(const int &value)
Initialize all values in a multi-vector with specified value.
Exception throws when you call an unimplemented method of Xpetra.
size_t global_size_t
Global size_t object.
static const EVerbosityLevel verbLevel_default
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
#define XPETRA_RCP_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
void doImport(const DistObject< int, int, int > &source, const Import< int, int > &importer, CombineMode CM)
void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
int maxValue() const
Compute max value of this Vector.
void abs(const MultiVector< int, int, int, Kokkos::DefaultNode::DefaultNodeType > &A)
Puts element-wise absolute values of input Multi-vector in target: A = abs(this)
int meanValue() const
Compute mean (average) value of this Vector.
Teuchos::ArrayRCP< int > getDataNonConst(size_t j)
CombineMode
Xpetra::Combine Mode enumerable type.
Teuchos::ScalarTraits< int >::magnitudeType normWeighted(const Vector< int, int, int > &weights) const
Compute Weighted 2-norm (RMS Norm) of this Vector.
size_t getNumVectors() const
Returns the number of vectors in the multi-vector.
EpetraIntVector(const Teuchos::RCP< const Map< int, int > > &map, bool zeroOut=true)
Sets all vector entries to zero.
void scale(const int &alpha)
Scale the current values of a multi-vector, this = alpha*this.
RCP< Epetra_IntVector > vec_
const Teuchos::RCP< const Map< int, int > > getMap() const
The Map describing the parallel distribution of this object.
RCP< Epetra_IntVector > getEpetra_IntVector() const