Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Vector_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Tpetra: Templated Linear Algebra Services Package
5// Copyright (2008) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ************************************************************************
40// @HEADER
41
42#ifndef TPETRA_VECTOR_DECL_HPP
43#define TPETRA_VECTOR_DECL_HPP
44
47
48#include "Tpetra_ConfigDefs.hpp"
49#include "Tpetra_Vector_fwd.hpp"
51
52namespace Tpetra {
53
72template <class Scalar,
73 class LocalOrdinal,
74 class GlobalOrdinal,
75 class Node>
76class Vector : public MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
77{
78private:
80
81public:
83
84
87 typedef Scalar scalar_type;
99 typedef LocalOrdinal local_ordinal_type;
101 typedef GlobalOrdinal global_ordinal_type;
103 typedef typename Node::device_type device_type;
104
106 typedef Node node_type;
107
114
122
125
127 typedef typename base_type::wrapped_dual_view_type wrapped_dual_view_type;
128
131
133
135
137 Vector ();
138
144 //
149 explicit Vector (const Teuchos::RCP<const map_type>& map,
150 const bool zeroOut = true);
151
164 const Teuchos::DataAccess copyOrView);
165
172 const Teuchos::RCP<const map_type>& map,
173 const local_ordinal_type rowOffset = 0);
174
176 Vector (const Teuchos::RCP<const map_type>& map,
177 const Teuchos::ArrayView<const Scalar>& A);
178
191 Vector (const Teuchos::RCP<const map_type>& map,
192 const dual_view_type& view);
193
208 Vector (const Teuchos::RCP<const map_type>& map,
209 const dual_view_type& view,
210 const dual_view_type& origView);
211
220 Vector (const Teuchos::RCP<const map_type>& map,
221 const wrapped_dual_view_type& d_view);
222
229 const size_t j);
230
240
243
251
255
265 virtual ~Vector () = default;
267
269
270
272
274 void replaceGlobalValue (const GlobalOrdinal globalRow, const Scalar& value);
275
295 void
296 sumIntoGlobalValue (const GlobalOrdinal globalRow,
297 const Scalar& value,
298 const bool atomic = base_type::useAtomicUpdatesByDefault);
299
301
303 void replaceLocalValue (const LocalOrdinal myRow, const Scalar& value);
304
322 void
323 sumIntoLocalValue (const LocalOrdinal myRow,
324 const Scalar& value,
325 const bool atomic = base_type::useAtomicUpdatesByDefault);
326
328
330
331
332 using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::get1dCopy; // overloading, not hiding
334 void get1dCopy (const Teuchos::ArrayView<Scalar>& A) const;
335
336 using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::getDataNonConst; // overloading, not hiding
338 Teuchos::ArrayRCP<Scalar> getDataNonConst () {
339 return getDataNonConst (0);
340 }
341
342 using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::getData; // overloading, not hiding
344 Teuchos::ArrayRCP<const Scalar> getData () const {
345 return getData (0);
346 }
347
348 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
349 offsetView (const Teuchos::RCP<const map_type>& subMap,
350 const size_t offset) const;
351
352 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
353 offsetViewNonConst (const Teuchos::RCP<const map_type>& subMap,
354 const size_t offset);
356
358
359 using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::dot; // overloading, not hiding
362
363 using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm1; // overloading, not hiding
365 mag_type norm1() const;
366
367 using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm2; // overloading, not hiding
369 mag_type norm2() const;
370
371 using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::normInf; // overloading, not hiding
373 mag_type normInf() const;
374
375
376 using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::meanValue; // overloading, not hiding
378 Scalar meanValue () const;
379
381
383
385 virtual std::string description () const;
386
408 virtual void
409 describe (Teuchos::FancyOStream& out,
410 const Teuchos::EVerbosityLevel verbLevel =
411 Teuchos::Describable::verbLevel_default) const;
413}; // class Vector
414
417template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
418Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
419createCopy (const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& src);
420
426template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
427Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
429{
431}
432
433} // namespace Tpetra
434
435#endif // TPETRA_VECTOR_DECL_HPP
Declaration of the Tpetra::MultiVector class.
Forward declaration of Tpetra::Vector.
A parallel distribution of indices over processes.
One or more distributed dense vectors.
typename Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
typename Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, device_type > dual_view_type
Kokkos::DualView specialization used by this class.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
A distributed dense vector.
virtual ~Vector()=default
Destructor (virtual for memory safety of derived classes).
void replaceGlobalValue(const GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
base_type::impl_scalar_type impl_scalar_type
The type used internally in place of Scalar.
void sumIntoLocalValue(const LocalOrdinal myRow, const Scalar &value, const bool atomic=base_type::useAtomicUpdatesByDefault)
Add value to existing value, using local (row) index.
mag_type normInf() const
Return the infinity-norm of this Vector.
Scalar meanValue() const
Compute mean (average) value of this Vector.
base_type::mag_type mag_type
Type of a norm result.
void replaceLocalValue(const LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
GlobalOrdinal global_ordinal_type
This class' third template parameter; the type of global indices.
mag_type norm2() const
Return the two-norm of this Vector.
Scalar scalar_type
This class' first template parameter; the type of each entry in the Vector.
base_type::dot_type dot_type
Type of an inner ("dot") product result.
Vector & operator=(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assignment (shallow copy).
Node node_type
The Kokkos Node type.
LocalOrdinal local_ordinal_type
This class' second template parameter; the type of local indices.
void sumIntoGlobalValue(const GlobalOrdinal globalRow, const Scalar &value, const bool atomic=base_type::useAtomicUpdatesByDefault)
Add value to existing value, using global (row) index.
base_type::wrapped_dual_view_type wrapped_dual_view_type
WrappedDualView specialization used by this class.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Nonmember Vector "constructor": Create a Vector from a given Map.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Describe this object in a human-readable way to the given output stream.
Vector()
Default constructor: makes a Vector with no rows or columns.
Vector(Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &&)=default
Move constructor (shallow move).
Teuchos::ArrayRCP< const Scalar > getData() const
Const view of the local values of this vector.
virtual std::string description() const
Return a one-line description of this object.
Node::device_type device_type
The Kokkos device type.
Vector(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy constructor (shallow copy).
void get1dCopy(const Teuchos::ArrayView< Scalar > &A) const
Return multi-vector values in user-provided two-dimensional array (using Teuchos memory management cl...
base_type::dual_view_type dual_view_type
Kokkos::DualView specialization used by this class.
Teuchos::ArrayRCP< Scalar > getDataNonConst()
View of the local values of this vector.
dot_type dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &y) const
Return the dot product of this Vector and the input Vector x.
mag_type norm1() const
Return the one-norm of this Vector.
base_type::map_type map_type
The type of the Map specialization used by this class.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &src)
Return a deep copy of the given MultiVector.