Xpetra Version of the Day
Loading...
Searching...
No Matches
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
51namespace Xpetra {
52
53
54template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
57 bool zeroOut)
58 : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut)
59{
60}
61
62
63template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
67 : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getLocalNumElements(), 1)
68{
69}
70
71
72template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
75{
76}
77
78
79template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
80void
82replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value)
83{
84 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceGlobalValue");
85 getTpetra_Vector()->replaceGlobalValue(globalRow, value);
86}
87
88
89template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
90void
92sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value)
93{
94 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoGlobalValue");
95 getTpetra_Vector()->sumIntoGlobalValue(globalRow, value);
96}
97
98
99template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
100void
102replaceLocalValue(LocalOrdinal myRow, const Scalar& value)
103{
104 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceLocalValue");
105 getTpetra_Vector()->replaceLocalValue(myRow, value);
106}
107
108
109template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
110void
112sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value)
113{
114 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoLocalValue");
115 getTpetra_Vector()->sumIntoLocalValue(myRow, value);
116}
117
118
119template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
122norm1() const
123{
124 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm1");
125 return getTpetra_Vector()->norm1();
126}
127
128
129template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
132norm2() const
133{
134 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm2");
135 return getTpetra_Vector()->norm2();
136}
137
138
139template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
142normInf() const
143{
144 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::normInf");
145 return getTpetra_Vector()->normInf();
146}
147
148
149template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
150Scalar
152meanValue() const
153{
154 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::meanValue");
155 return getTpetra_Vector()->meanValue();
156}
157
158
159template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
160std::string
162description() const
163{
164 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::description");
165 return getTpetra_Vector()->description();
166}
167
168
169template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
170void
173{
174 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::describe");
175 getTpetra_Vector()->describe(out, verbLevel);
176}
177
178
179template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
180Scalar
183{
184 XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::dot");
185 return getTpetra_Vector()->dot(*toTpetra(a));
186}
187
188
189template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
191TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec)
192 : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(vec)
193{
194}
195
196
197template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
200getTpetra_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
212template<class Scalar>
213class 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;
220
221#undef XPETRA_TPETRAMULTIVECTOR_SHORT
222#undef XPETRA_TPETRAVECTOR_SHORT
224#define XPETRA_TPETRAMULTIVECTOR_SHORT
225#define XPETRA_TPETRAVECTOR_SHORT
226
227 public:
228
229 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::dot; // overloading, not hiding
230 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm1; // overloading, not hiding
231 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm2; // overloading, not hiding
232 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::normInf; // overloading, not hiding
233 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::meanValue; // overloading, not hiding
234 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceGlobalValue; // overloading, not hiding
235 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoGlobalValue; // overloading, not hiding
236 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceLocalValue; // overloading, not hiding
237 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoLocalValue; // overloading, not hiding
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->getLocalNumElements(), 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
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
369template<class Scalar>
370class 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;
377
378#undef XPETRA_TPETRAMULTIVECTOR_SHORT
379#undef XPETRA_TPETRAVECTOR_SHORT
381#define XPETRA_TPETRAMULTIVECTOR_SHORT
382#define XPETRA_TPETRAVECTOR_SHORT
383
384 public:
385 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::dot; // overloading, not hiding
386 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm1; // overloading, not hiding
387 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm2; // overloading, not hiding
388 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::normInf; // overloading, not hiding
389 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::meanValue; // overloading, not hiding
390 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceGlobalValue; // overloading, not hiding
391 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoGlobalValue; // overloading, not hiding
392 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceLocalValue; // overloading, not hiding
393 using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoLocalValue; // overloading, not hiding
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->getLocalNumElements(), 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
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
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.
Xpetra namespace
RCP< const Tpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > toTpetra(const RCP< const CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > &graph)
static magnitudeType magnitude(T a)