Xpetra Version of the Day
Loading...
Searching...
No Matches
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
14namespace Xpetra {
15
16template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
19 bool zeroOut)
20 : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut) {
21}
22
23template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
27 : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getLocalNumElements(), 1) {
28}
29
30template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
34
35template <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
42template <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
49template <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
56template <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
63template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
66 norm1() const {
67 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm1");
68 return getTpetra_Vector()->norm1();
69}
70
71template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
74 norm2() const {
75 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm2");
76 return getTpetra_Vector()->norm2();
77}
78
79template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
82 normInf() const {
83 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::normInf");
84 return getTpetra_Vector()->normInf();
85}
86
87template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
88Scalar
90 meanValue() const {
91 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::meanValue");
92 return getTpetra_Vector()->meanValue();
93}
94
95template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
96std::string
98 description() const {
99 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::description");
100 return getTpetra_Vector()->description();
101}
102
103template <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
110template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
111Scalar
114 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::dot");
115 return getTpetra_Vector()->dot(*toTpetra(a));
116}
117
118template <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
124template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
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
136template <class Scalar>
137class 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;
142
143#undef XPETRA_TPETRAMULTIVECTOR_SHORT
144#undef XPETRA_TPETRAVECTOR_SHORT
146#define XPETRA_TPETRAMULTIVECTOR_SHORT
147#define XPETRA_TPETRAVECTOR_SHORT
148
149 public:
150 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::dot; // overloading, not hiding
151 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm1; // overloading, not hiding
152 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm2; // overloading, not hiding
153 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::normInf; // overloading, not hiding
154 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::meanValue; // overloading, not hiding
155 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceGlobalValue; // overloading, not hiding
156 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoGlobalValue; // overloading, not hiding
157 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceLocalValue; // overloading, not hiding
158 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoLocalValue; // overloading, not hiding
159
161
162
171
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
203
208
213
216
218
220
221
223 std::string description() const { return std::string(""); }
224
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
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
261template <class Scalar>
262class 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;
267
268#undef XPETRA_TPETRAMULTIVECTOR_SHORT
269#undef XPETRA_TPETRAVECTOR_SHORT
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
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
335
340
345
348
350
352
353
355 std::string description() const { return std::string(""); }
356
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
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
#define XPETRA_MONITOR(funcName)
#define XPETRA_TPETRA_ETI_EXCEPTION(cl, obj, go, node)
static const EVerbosityLevel verbLevel_default
RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_MultiVector() const
Get the underlying Tpetra multivector.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this 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.
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-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.
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.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.
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< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &vec)
TpetraMultiVector constructor to wrap a Tpetra::MultiVector 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.
TpetraVector(const Teuchos::RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &vec)
TpetraMultiVector constructor to wrap a Tpetra::MultiVector object.
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< 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.
RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetra_Vector() const
Get the underlying Tpetra multivector.
void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
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.
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.
virtual ~TpetraVector()
Destructor.
TpetraVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true)
Sets all vector entries to zero.
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
static magnitudeType magnitude(T a)