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 // ***********************************************************************
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 namespace Xpetra {
51 
52 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
55  bool zeroOut)
56  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut) {
57 }
58 
59 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
62  const Teuchos::ArrayView<const Scalar>& A)
63  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getLocalNumElements(), 1) {
64 }
65 
66 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
69 }
70 
71 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
73  replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {
74  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceGlobalValue");
75  getTpetra_Vector()->replaceGlobalValue(globalRow, value);
76 }
77 
78 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
80  sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {
81  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoGlobalValue");
82  getTpetra_Vector()->sumIntoGlobalValue(globalRow, value);
83 }
84 
85 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
87  replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {
88  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::replaceLocalValue");
89  getTpetra_Vector()->replaceLocalValue(myRow, value);
90 }
91 
92 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
94  sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {
95  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::sumIntoLocalValue");
96  getTpetra_Vector()->sumIntoLocalValue(myRow, value);
97 }
98 
99 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
100 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
102  norm1() const {
103  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm1");
104  return getTpetra_Vector()->norm1();
105 }
106 
107 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
108 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
110  norm2() const {
111  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::norm2");
112  return getTpetra_Vector()->norm2();
113 }
114 
115 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
116 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
118  normInf() const {
119  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::normInf");
120  return getTpetra_Vector()->normInf();
121 }
122 
123 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
124 Scalar
126  meanValue() const {
127  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::meanValue");
128  return getTpetra_Vector()->meanValue();
129 }
130 
131 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
132 std::string
134  description() const {
135  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::description");
136  return getTpetra_Vector()->description();
137 }
138 
139 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
141  describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel) const {
142  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::describe");
143  getTpetra_Vector()->describe(out, verbLevel);
144 }
145 
146 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
147 Scalar
150  XPETRA_MONITOR("TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::dot");
151  return getTpetra_Vector()->dot(*toTpetra(a));
152 }
153 
154 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
156  TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec)
157  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(vec) {
158 }
159 
160 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
161 RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
165 }
166 
167 #ifdef HAVE_XPETRA_EPETRA
168 
169 #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))))
170 
171 // specialization of TpetraVector for GO=int and NO=SerialNode
172 template <class Scalar>
173 class TpetraVector<Scalar, int, int, EpetraNode>
174  : public virtual Vector<Scalar, int, int, EpetraNode>, public TpetraMultiVector<Scalar, int, int, EpetraNode> {
175  typedef int LocalOrdinal;
176  typedef int GlobalOrdinal;
177  typedef EpetraNode Node;
178 
179 #undef XPETRA_TPETRAMULTIVECTOR_SHORT
180 #undef XPETRA_TPETRAVECTOR_SHORT
181 #include "Xpetra_UseShortNames.hpp"
182 #define XPETRA_TPETRAMULTIVECTOR_SHORT
183 #define XPETRA_TPETRAVECTOR_SHORT
184 
185  public:
195 
197 
198 
200  TpetraVector(const Teuchos::RCP<const Map>& map, bool zeroOut = true)
201  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut) {
204  "int",
205  typeid(EpetraNode).name());
206  }
207 
209  TpetraVector(const Teuchos::RCP<const Map>& map, const Teuchos::ArrayView<const Scalar>& A)
210  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getLocalNumElements(), 1) {
213  "int",
214  typeid(EpetraNode).name());
215  }
216 
217  virtual ~TpetraVector() {}
218 
219  void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
220 
222  void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
223 
225  void replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {}
226 
228  void sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {}
229 
231 
233 
234 
236  typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm1() const {
237  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
238  }
239 
241  typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm2() const {
242  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
243  }
244 
246  typename Teuchos::ScalarTraits<Scalar>::magnitudeType normInf() const {
247  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
248  }
249 
251  Scalar meanValue() const { return Teuchos::ScalarTraits<Scalar>::zero(); }
252 
254 
256 
257 
259  std::string description() const { return std::string(""); }
260 
262  void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {}
263 
265 
267  Scalar dot(const Vector& a) const { return Teuchos::ScalarTraits<Scalar>::zero(); }
268 
270 
271 
273  TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec)
277  "int",
278  typeid(EpetraNode).name());
279  }
280 
282  RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
284  return Teuchos::null;
285  }
286 
288 
289 }; // TpetraVector class (specialization on GO=int, NO=EpetraNode)
290 
291 #endif // #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_INT)))
292  // || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_INT))))
293 
294 #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))))
295 
296 // specialization of TpetraVector for GO=int and NO=SerialNode
297 template <class Scalar>
298 class TpetraVector<Scalar, int, long long, EpetraNode>
299  : public virtual Vector<Scalar, int, long long, EpetraNode>, public TpetraMultiVector<Scalar, int, long long, EpetraNode> {
300  typedef int LocalOrdinal;
301  typedef long long GlobalOrdinal;
302  typedef EpetraNode Node;
303 
304 #undef XPETRA_TPETRAMULTIVECTOR_SHORT
305 #undef XPETRA_TPETRAVECTOR_SHORT
306 #include "Xpetra_UseShortNames.hpp"
307 #define XPETRA_TPETRAMULTIVECTOR_SHORT
308 #define XPETRA_TPETRAVECTOR_SHORT
309 
310  public:
311  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::dot; // overloading, not hiding
312  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm1; // overloading, not hiding
313  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm2; // overloading, not hiding
314  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::normInf; // overloading, not hiding
315  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::meanValue; // overloading, not hiding
316  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceGlobalValue; // overloading, not hiding
317  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoGlobalValue; // overloading, not hiding
318  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::replaceLocalValue; // overloading, not hiding
319  using TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::sumIntoLocalValue; // overloading, not hiding
320 
322 
323 
325  TpetraVector(const Teuchos::RCP<const Map>& map, bool zeroOut = true)
326  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut) {
329  "long long",
330  typeid(EpetraNode).name());
331  }
332 
334  TpetraVector(const Teuchos::RCP<const Map>& map, const Teuchos::ArrayView<const Scalar>& A)
335  : TpetraMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, A, map->getLocalNumElements(), 1) {
338  "long long",
339  typeid(EpetraNode).name());
340  }
341 
343  virtual ~TpetraVector() {}
344 
346 
348 
349 
351  void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
352 
354  void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value) {}
355 
357  void replaceLocalValue(LocalOrdinal myRow, const Scalar& value) {}
358 
360  void sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value) {}
361 
363 
365 
366 
368  typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm1() const {
369  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
370  }
371 
373  typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm2() const {
374  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
375  }
376 
378  typename Teuchos::ScalarTraits<Scalar>::magnitudeType normInf() const {
379  return Teuchos::ScalarTraits<Scalar>::magnitude(Teuchos::ScalarTraits<Scalar>::zero());
380  }
381 
383  Scalar meanValue() const { return Teuchos::ScalarTraits<Scalar>::zero(); }
384 
386 
388 
389 
391  std::string description() const { return std::string(""); }
392 
394  void describe(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {}
395 
397 
399  Scalar dot(const Vector& a) const { return Teuchos::ScalarTraits<Scalar>::zero(); }
400 
402 
404 
405 
407  TpetraVector(const Teuchos::RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>& vec) {
410  "long long",
411  typeid(EpetraNode).name());
412  }
413 
415  RCP<Tpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
417  return Teuchos::null;
418  }
419 
421 
422 }; // TpetraVector class (specialization on GO=long long, NO=EpetraNode)
423 
424 #endif // #if((defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_OPENMP) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG)))
425  // || (!defined(EPETRA_HAVE_OMP) && (!defined(HAVE_TPETRA_INST_SERIAL) || !defined(HAVE_TPETRA_INST_INT_LONG_LONG))))
426 
427 #endif // HAVE_XPETRA_EPETRA
428 } // namespace Xpetra
429 
430 #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.