Xpetra  Version of the Day
Xpetra_TpetraVector_def.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 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_TPETRAVECTOR_DEF_HPP
47 #define XPETRA_TPETRAVECTOR_DEF_HPP
49 
50 
51 namespace Xpetra {
52 
53 
54 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
57  bool zeroOut)
58  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut)
59 {
60 }
61 
62 
63 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
67  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getNodeNumElements(), 1)
68 {
69 }
70 
71 
72 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
75 {
76 }
77 
78 
79 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
80 void
82 replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value)
83 {
84  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceGlobalValue");
85  getTpetra_Vector()->replaceGlobalValue(globalRow, value);
86 }
87 
88 
89 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
90 void
92 sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value)
93 {
94  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoGlobalValue");
95  getTpetra_Vector()->sumIntoGlobalValue(globalRow, value);
96 }
97 
98 
99 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
100 void
102 replaceLocalValue(LocalOrdinal myRow, const Scalar& value)
103 {
104  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceLocalValue");
105  getTpetra_Vector()->replaceLocalValue(myRow, value);
106 }
107 
108 
109 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
110 void
112 sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value)
113 {
114  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoLocalValue");
115  getTpetra_Vector()->sumIntoLocalValue(myRow, value);
116 }
117 
118 
119 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
122 norm1() const
123 {
124  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm1");
125  return getTpetra_Vector()->norm1();
126 }
127 
128 
129 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
132 norm2() const
133 {
134  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm2");
135  return getTpetra_Vector()->norm2();
136 }
137 
138 
139 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
142 normInf() const
143 {
144  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::normInf");
145  return getTpetra_Vector()->normInf();
146 }
147 
148 
149 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
150 Scalar
152 meanValue() const
153 {
154  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::meanValue");
155  return getTpetra_Vector()->meanValue();
156 }
157 
158 
159 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
160 std::string
162 description() const
163 {
164  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::description");
165  return getTpetra_Vector()->description();
166 }
167 
168 
169 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
170 void
172 describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel) const
173 {
174  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::describe");
175  getTpetra_Vector()->describe(out, verbLevel);
176 }
177 
178 
179 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
180 Scalar
183 {
184  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::dot");
185  return getTpetra_Vector()->dot(*toTpetra(a));
186 }
187 
188 
189 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
191 TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec)
192  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(vec)
193 {
194 }
195 
196 
197 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
200 getTpetra_Vector() const
201 {
203 }
204 
205 
206 #ifdef HAVE_XPETRA_EPETRA
207 
208 #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) \
209  || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
210 
211 // specialization of TpetraVector for GO=int and NO=SerialNode
212 template<class Scalar>
213 class TpetraVector<Scalar, int, int, EpetraNode>
214  : public virtual Vector<Scalar, int, int, EpetraNode>
215  , public TpetraMultiVector<Scalar, int, int, EpetraNode>
216 {
217  typedef int LocalOrdinal;
218  typedef int GlobalOrdinal;
219  typedef EpetraNode Node;
220 
221 #undef XPETRA_TPETRAMULTIVECTOR_SHORT
222 #undef XPETRA_TPETRAVECTOR_SHORT
223 #include "Xpetra_UseShortNames.hpp"
224 #define XPETRA_TPETRAMULTIVECTOR_SHORT
225 #define XPETRA_TPETRAVECTOR_SHORT
226 
227  public:
228 
238 
240 
241 
243  TpetraVector(const Teuchos::RCP<const Map>& map, bool zeroOut = true)
244  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut)
245  {
248  "int",
249  typeid(EpetraNode).name());
250  }
251 
252 
255  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getNodeNumElements(), 1)
256  {
259  "int",
260  typeid(EpetraNode).name());
261  }
262 
263 
264  virtual ~TpetraVector() {}
265 
266 
267  void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
268 
269 
271  void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
272 
273 
275  void replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {}
276 
277 
279  void sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {}
280 
281 
283 
285 
286 
287 
290  {
292  }
293 
294 
297  {
299  }
300 
301 
304  {
306  }
307 
308 
310  Scalar meanValue() const { return Teuchos::ScalarTraits<Scalar>::zero(); }
311 
313 
315 
316 
317 
319  std::string description() const { return std::string(""); }
320 
321 
324 
326 
327 
329  Scalar dot(const Vector& a) const { return Teuchos::ScalarTraits<Scalar>::zero(); }
330 
331 
332 
333 
335 
336 
338  TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec)
340  {
343  "int",
344  typeid(EpetraNode).name());
345  }
346 
347 
351  {
352  return Teuchos::null;
353  }
354 
356 
357 }; // TpetraVector class (specialization on GO=int, NO=EpetraNode)
358 
359 
360 #endif // #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT)))
361  // || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
362 
363 
364 
365 #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) \
366  || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
367 
368 // specialization of TpetraVector for GO=int and NO=SerialNode
369 template<class Scalar>
370 class TpetraVector<Scalar, int, long long, EpetraNode>
371  : public virtual Vector<Scalar, int, long long, EpetraNode>
372  , public TpetraMultiVector<Scalar, int, long long, EpetraNode>
373 {
374  typedef int LocalOrdinal;
375  typedef long long GlobalOrdinal;
376  typedef EpetraNode Node;
377 
378 #undef XPETRA_TPETRAMULTIVECTOR_SHORT
379 #undef XPETRA_TPETRAVECTOR_SHORT
380 #include "Xpetra_UseShortNames.hpp"
381 #define XPETRA_TPETRAMULTIVECTOR_SHORT
382 #define XPETRA_TPETRAVECTOR_SHORT
383 
384  public:
394 
396 
397 
399  TpetraVector(const Teuchos::RCP<const Map>& map, bool zeroOut = true)
400  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut)
401  {
404  "long long",
405  typeid(EpetraNode).name());
406  }
407 
410  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getNodeNumElements(), 1)
411  {
414  "long long",
415  typeid(EpetraNode).name());
416  }
417 
419  virtual ~TpetraVector() {}
420 
422 
424 
425 
427  void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
428 
430  void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
431 
433  void replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {}
434 
436  void sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {}
437 
439 
441 
442 
445  {
447  }
448 
451  {
453  }
454 
457  {
459  }
460 
462  Scalar meanValue() const { return Teuchos::ScalarTraits<Scalar>::zero(); }
463 
465 
467 
468 
470  std::string description() const { return std::string(""); }
471 
474 
476 
478  Scalar dot(const Vector& a) const { return Teuchos::ScalarTraits<Scalar>::zero(); }
479 
481 
483 
484 
485 
487  TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec)
488  {
491  "long long",
492  typeid(EpetraNode).name());
493  }
494 
495 
499  {
500  return Teuchos::null;
501  }
502 
504 
505 }; // TpetraVector class (specialization on GO=long long, NO=EpetraNode)
506 
507 
508 #endif // #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG)))
509  // || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
510 
511 
512 
513 #endif // HAVE_XPETRA_EPETRA
514 } // namespace Xpetra
515 
516 #endif
#define XPETRA_MONITOR(funcName)
#define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node)
static const EVerbosityLevel verbLevel_default
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
void meanValue(const Teuchos::ArrayView< Scalar > &means) const
Compute mean (average) value of each vector in multi-vector. The outcome of this routine is undefined...
void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
void norm2(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_MultiVector() const
Get the underlying Tpetra multivector.
void norm1(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
void normInf(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
std::string description() const
Return a simple one-line description of this object.
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm of this Vector.
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Scalar meanValue() const
Compute mean (average) value of this Vector.
TpetraVector(const Teuchos::RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node >> &vec)
TpetraMultiVector constructor to wrap a Tpetra::MultiVector object.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this Vector.
RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Vector() const
Get the underlying Tpetra multivector.
TpetraVector(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
Sets all vector entries to zero.
Scalar dot(const Vector &a) const
Computes dot product of this Vector against input Vector x.
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.
TpetraVector(const Teuchos::RCP< const Map > &map, const Teuchos::ArrayView< const Scalar > &A)
Set multi-vector values from an array using Teuchos memory management classes. (copy)
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this Vector.
Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm of this Vector.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
std::string description() const
Return a simple one-line description of this object.
TpetraVector(const Teuchos::RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node >> &vec)
TpetraMultiVector constructor to wrap a Tpetra::MultiVector object.
TpetraVector(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
Sets all vector entries to zero.
TpetraVector(const Teuchos::RCP< const Map > &map, const Teuchos::ArrayView< const Scalar > &A)
Set multi-vector values from an array using Teuchos memory management classes. (copy)
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 sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Vector() const
Get the underlying Tpetra multivector.
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Scalar meanValue() const
Compute mean (average) value of this Vector.
Scalar dot(const Vector &a) const
Computes dot product of this Vector against input Vector x.
void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Scalar dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &a) const
Computes dot product of this Vector against input Vector x.
Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm of this Vector.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this Vector.
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
std::string description() const
Return a simple one-line description of this object.
Scalar meanValue() const
Compute mean (average) value of this Vector.
RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Vector() const
Get the underlying Tpetra multivector.
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.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.
TpetraVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &map, bool zeroOut=true)
Sets all vector entries to zero.
virtual ~TpetraVector()
Destructor.
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Xpetra namespace
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
static magnitudeType magnitude(T a)