Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_TpetraVector_def.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Xpetra: A linear algebra interface package
4 //
5 // Copyright 2012 NTESS and the Xpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef XPETRA_TPETRAVECTOR_DEF_HPP
11 #define XPETRA_TPETRAVECTOR_DEF_HPP
13 
14 namespace Xpetra {
15 
16 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
19  bool zeroOut)
20  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut) {
21 }
22 
23 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
26  const Teuchos::ArrayView<const Scalar>& A)
27  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getLocalNumElements(), 1) {
28 }
29 
30 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
33 }
34 
35 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
37  replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {
38  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceGlobalValue");
39  getTpetra_Vector()->replaceGlobalValue(globalRow, value);
40 }
41 
42 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
44  sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {
45  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoGlobalValue");
46  getTpetra_Vector()->sumIntoGlobalValue(globalRow, value);
47 }
48 
49 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
51  replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {
52  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceLocalValue");
53  getTpetra_Vector()->replaceLocalValue(myRow, value);
54 }
55 
56 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
58  sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {
59  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoLocalValue");
60  getTpetra_Vector()->sumIntoLocalValue(myRow, value);
61 }
62 
63 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
64 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
66  norm1() const {
67  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm1");
68  return getTpetra_Vector()->norm1();
69 }
70 
71 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
72 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
74  norm2() const {
75  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm2");
76  return getTpetra_Vector()->norm2();
77 }
78 
79 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
80 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
82  normInf() const {
83  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::normInf");
84  return getTpetra_Vector()->normInf();
85 }
86 
87 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
88 Scalar
90  meanValue() const {
91  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::meanValue");
92  return getTpetra_Vector()->meanValue();
93 }
94 
95 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
96 std::string
98  description() const {
99  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::description");
100  return getTpetra_Vector()->description();
101 }
102 
103 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
105  describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel) const {
106  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::describe");
107  getTpetra_Vector()->describe(out, verbLevel);
108 }
109 
110 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
111 Scalar
114  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::dot");
115  return getTpetra_Vector()->dot(*toTpetra(a));
116 }
117 
118 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
120  TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec)
121  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(vec) {
122 }
123 
124 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
125 RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
129 }
130 
131 #ifdef HAVE_XPETRA_EPETRA
132 
133 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT))) || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
134 
135 // specialization of TpetraVector for GO=int and NO=SerialNode
136 template <class Scalar>
137 class TpetraVector<Scalar, int, int, EpetraNode>
138  : public virtual Vector<Scalar, int, int, EpetraNode>, public TpetraMultiVector<Scalar, int, int, EpetraNode> {
139  typedef int LocalOrdinal;
140  typedef int GlobalOrdinal;
141  typedef EpetraNode Node;
142 
143 #undef XPETRA_TPETRAMULTIVECTOR_SHORT
144 #undef XPETRA_TPETRAVECTOR_SHORT
145 #include "Xpetra_UseShortNames.hpp"
146 #define XPETRA_TPETRAMULTIVECTOR_SHORT
147 #define XPETRA_TPETRAVECTOR_SHORT
148 
149  public:
159 
161 
162 
164  TpetraVector(const Teuchos::RCP<const Map>& map, bool zeroOut = true)
165  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut) {
168  "int",
169  typeid(EpetraNode).name());
170  }
171 
173  TpetraVector(const Teuchos::RCP<const Map>& map, const Teuchos::ArrayView<const Scalar>& A)
174  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getLocalNumElements(), 1) {
177  "int",
178  typeid(EpetraNode).name());
179  }
180 
181  virtual ~TpetraVector() {}
182 
183  void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
184 
186  void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
187 
189  void replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {}
190 
192  void sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {}
193 
195 
197 
198 
200  typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm1() const {
201  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
202  }
203 
205  typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm2() const {
206  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
207  }
208 
210  typename Teuchos::ScalarTraits<Scalar>::magnitudeType normInf() const {
211  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
212  }
213 
215  Scalar meanValue() const { return Teuchos::ScalarTraits<Scalar>::zero(); }
216 
218 
220 
221 
223  std::string description() const { return std::string(""); }
224 
226  void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {}
227 
229 
231  Scalar dot(const Vector& a) const { return Teuchos::ScalarTraits<Scalar>::zero(); }
232 
234 
235 
237  TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec)
241  "int",
242  typeid(EpetraNode).name());
243  }
244 
246  RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
248  return Teuchos::null;
249  }
250 
252 
253 }; // TpetraVector class (specialization on GO=int, NO=EpetraNode)
254 
255 #endif // #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT)))
256  // || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
257 
258 #if ((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))) || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
259 
260 // specialization of TpetraVector for GO=int and NO=SerialNode
261 template <class Scalar>
262 class TpetraVector<Scalar, int, long long, EpetraNode>
263  : public virtual Vector<Scalar, int, long long, EpetraNode>, public TpetraMultiVector<Scalar, int, long long, EpetraNode> {
264  typedef int LocalOrdinal;
265  typedef long long GlobalOrdinal;
266  typedef EpetraNode Node;
267 
268 #undef XPETRA_TPETRAMULTIVECTOR_SHORT
269 #undef XPETRA_TPETRAVECTOR_SHORT
270 #include "Xpetra_UseShortNames.hpp"
271 #define XPETRA_TPETRAMULTIVECTOR_SHORT
272 #define XPETRA_TPETRAVECTOR_SHORT
273 
274  public:
275  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::dot; // overloading, not hiding
276  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm1; // overloading, not hiding
277  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm2; // overloading, not hiding
278  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::normInf; // overloading, not hiding
279  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::meanValue; // overloading, not hiding
280  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceGlobalValue; // overloading, not hiding
281  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoGlobalValue; // overloading, not hiding
282  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceLocalValue; // overloading, not hiding
283  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoLocalValue; // overloading, not hiding
284 
286 
287 
289  TpetraVector(const Teuchos::RCP<const Map>& map, bool zeroOut = true)
290  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut) {
293  "long long",
294  typeid(EpetraNode).name());
295  }
296 
298  TpetraVector(const Teuchos::RCP<const Map>& map, const Teuchos::ArrayView<const Scalar>& A)
299  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getLocalNumElements(), 1) {
302  "long long",
303  typeid(EpetraNode).name());
304  }
305 
307  virtual ~TpetraVector() {}
308 
310 
312 
313 
315  void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
316 
318  void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
319 
321  void replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {}
322 
324  void sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {}
325 
327 
329 
330 
332  typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm1() const {
333  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
334  }
335 
337  typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm2() const {
338  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
339  }
340 
342  typename Teuchos::ScalarTraits<Scalar>::magnitudeType normInf() const {
343  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
344  }
345 
347  Scalar meanValue() const { return Teuchos::ScalarTraits<Scalar>::zero(); }
348 
350 
352 
353 
355  std::string description() const { return std::string(""); }
356 
358  void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {}
359 
361 
363  Scalar dot(const Vector& a) const { return Teuchos::ScalarTraits<Scalar>::zero(); }
364 
366 
368 
369 
371  TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec) {
374  "long long",
375  typeid(EpetraNode).name());
376  }
377 
379  RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
381  return Teuchos::null;
382  }
383 
385 
386 }; // TpetraVector class (specialization on GO=long long, NO=EpetraNode)
387 
388 #endif // #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG)))
389  // || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
390 
391 #endif // HAVE_XPETRA_EPETRA
392 } // namespace Xpetra
393 
394 #endif
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.
std::string description() const
Return a simple one-line description of this object.
virtual ~TpetraVector()
Destructor.
void sumIntoLocalValue(LocalOrdinal myRow, 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 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 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.
Scalar meanValue() const
Compute mean (average) value of this Vector.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this Vector.
Scalar dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &a) const
Computes dot product of this Vector against input Vector x.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this Vector.
#define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node)
TpetraVector(const Teuchos::RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node >> &vec)
TpetraMultiVector constructor to wrap a Tpetra::MultiVector object.
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this Vector.
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
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 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.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.
void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
std::string description() const
Return a simple one-line description of this object.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.
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 sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
TpetraVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &map, bool zeroOut=true)
Sets all vector entries to zero.
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm of this Vector.
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.
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Vector() const
Get the underlying Tpetra multivector.
std::string description() const
Return a simple one-line description of this object.
RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_MultiVector() const
Get the underlying Tpetra multivector.
#define XPETRA_MONITOR(funcName)
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) ...
Scalar dot(const Vector &a) const
Computes dot product of this Vector against input Vector x.
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
Scalar dot(const Vector &a) const
Computes dot product of this Vector against input Vector x.
TpetraVector(const Teuchos::RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node >> &vec)
TpetraMultiVector constructor to wrap a Tpetra::MultiVector 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.
TpetraVector(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
Sets all vector entries to zero.
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, bool zeroOut=true)
Sets all vector entries to zero.