Tpetra parallel linear algebra  Version of the Day
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 
52 
53 #include "Tpetra_ConfigDefs.hpp"
54 #include "Tpetra_Vector_fwd.hpp"
56 
57 namespace Tpetra {
58 namespace Classes {
59 
78 template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
80  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
82 class Vector : public MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
83 {
84 private:
86 
87 public:
89 
90 
93  typedef Scalar scalar_type;
105  typedef LocalOrdinal local_ordinal_type;
107  typedef GlobalOrdinal global_ordinal_type;
109  typedef typename Node::device_type device_type;
110 
112  typedef Node node_type;
113 
119  typedef typename base_type::dot_type dot_type;
120 
127  typedef typename base_type::mag_type mag_type;
128 
131 
133  typedef typename base_type::map_type map_type;
134 
136 
138 
140  Vector ();
141 
147  //
152  explicit Vector (const Teuchos::RCP<const map_type>& map,
153  const bool zeroOut = true);
154 
164 
177  const Teuchos::DataAccess copyOrView);
178 
180  Vector (const Teuchos::RCP<const map_type>& map,
181  const Teuchos::ArrayView<const Scalar>& A);
182 
195  Vector (const Teuchos::RCP<const map_type>& map,
196  const dual_view_type& view);
197 
212  Vector (const Teuchos::RCP<const map_type>& map,
213  const dual_view_type& view,
214  const dual_view_type& origView);
215 
222  const size_t j);
223 
225  virtual ~Vector ();
226 
228 
230 
236  template <class Node2>
237  Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node2> >
238  clone (const Teuchos::RCP<Node2>& node2);
239 
241 
243 
245 
247  void replaceGlobalValue (const GlobalOrdinal globalRow, const Scalar& value) const;
248 
268  void
269  sumIntoGlobalValue (const GlobalOrdinal globalRow,
270  const Scalar& value,
271  const bool atomic = base_type::useAtomicUpdatesByDefault) const;
272 
274 
276  void replaceLocalValue (const LocalOrdinal myRow, const Scalar& value) const;
277 
295  void
296  sumIntoLocalValue (const LocalOrdinal myRow,
297  const Scalar& value,
298  const bool atomic = base_type::useAtomicUpdatesByDefault) const;
299 
301 
303 
304 
307  void get1dCopy (const Teuchos::ArrayView<Scalar>& A) const;
308 
311  Teuchos::ArrayRCP<Scalar> getDataNonConst () {
312  return getDataNonConst (0);
313  }
314 
317  Teuchos::ArrayRCP<const Scalar> getData () const {
318  return getData (0);
319  }
320 
321  Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
322  offsetView (const Teuchos::RCP<const map_type>& subMap,
323  const size_t offset) const;
324 
325  Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
326  offsetViewNonConst (const Teuchos::RCP<const map_type>& subMap,
327  const size_t offset);
329 
331 
332  using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::dot; // overloading, not hiding
335 
336  using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm1; // overloading, not hiding
338  mag_type norm1() const;
339 
340  using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm2; // overloading, not hiding
342  mag_type norm2() const;
343 
346  mag_type normInf() const;
347 
352  mag_type TPETRA_DEPRECATED
354 
357  Scalar meanValue () const;
358 
360 
362 
364  virtual std::string description () const;
365 
387  virtual void
388  describe (Teuchos::FancyOStream& out,
389  const Teuchos::EVerbosityLevel verbLevel =
390  Teuchos::Describable::verbLevel_default) const;
392 }; // class Vector
393 } // namespace Classes
394 
397 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
398 Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
399 createCopy (const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& src);
400 
406 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
407 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
408 createVector (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& map)
409 {
411 }
412 
413 } // namespace Tpetra
414 
415 #endif // TPETRA_VECTOR_DECL_HPP
Tpetra::Classes::MultiVector::useAtomicUpdatesByDefault
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
Definition: Tpetra_MultiVector_decl.hpp:791
Tpetra_MultiVector_decl.hpp
Declaration of the Tpetra::MultiVector class.
Tpetra::Classes::Vector::sumIntoGlobalValue
void sumIntoGlobalValue(const GlobalOrdinal globalRow, const Scalar &value, const bool atomic=base_type::useAtomicUpdatesByDefault) const
Add value to existing value, using global (row) index.
Definition: Tpetra_Vector_def.hpp:132
Tpetra::Classes::Vector::sumIntoLocalValue
void sumIntoLocalValue(const LocalOrdinal myRow, const Scalar &value, const bool atomic=base_type::useAtomicUpdatesByDefault) const
Add value to existing value, using local (row) index.
Definition: Tpetra_Vector_def.hpp:149
Tpetra::Classes::Vector::getData
Teuchos::ArrayRCP< const Scalar > getData() const
Const view of the local values of this vector.
Definition: Tpetra_Vector_decl.hpp:317
Tpetra::Classes::Vector::norm2
mag_type norm2() const
Return the two-norm of this Vector.
Definition: Tpetra_Vector_def.hpp:197
Tpetra::Classes::Vector::get1dCopy
void get1dCopy(const Teuchos::ArrayView< Scalar > &A) const
Return multi-vector values in user-provided two-dimensional array (using Teuchos memory management cl...
Definition: Tpetra_Vector_def.hpp:159
Tpetra::Classes::Vector::describe
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.
Definition: Tpetra_Vector_def.hpp:281
Tpetra::Classes::Vector::impl_scalar_type
base_type::impl_scalar_type impl_scalar_type
The type used internally in place of Scalar.
Definition: Tpetra_Vector_decl.hpp:103
Tpetra::Details::DefaultTypes::node_type
::Kokkos::Compat::KokkosDeviceWrapperNode< execution_space > node_type
Default value of Node template parameter.
Definition: Tpetra_Details_DefaultTypes.hpp:105
Tpetra::Classes::Vector::meanValue
Scalar meanValue() const
Compute mean (average) value of this Vector.
Definition: Tpetra_Vector_def.hpp:177
Tpetra::Classes::Vector::replaceLocalValue
void replaceLocalValue(const LocalOrdinal myRow, const Scalar &value) const
Replace current value at the specified location with specified values.
Definition: Tpetra_Vector_def.hpp:142
Tpetra::Classes::Vector::getDataNonConst
Teuchos::ArrayRCP< Scalar > getDataNonConst()
View of the local values of this vector.
Definition: Tpetra_Vector_decl.hpp:311
Tpetra::Classes::Vector::normInf
mag_type normInf() const
Return the infinity-norm of this Vector.
Definition: Tpetra_Vector_def.hpp:207
Tpetra::Classes::Vector::global_ordinal_type
GlobalOrdinal global_ordinal_type
This class' third template parameter; the type of global indices.
Definition: Tpetra_Vector_decl.hpp:107
Tpetra::Classes::Vector::dot
dot_type dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &y) const
Return the dot product of this Vector and the input Vector x.
Definition: Tpetra_Vector_def.hpp:167
Tpetra::Classes::MultiVector::dual_view_type
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, typename execution_space::execution_space > dual_view_type
Kokkos::DualView specialization used by this class.
Definition: Tpetra_MultiVector_decl.hpp:476
Tpetra::Classes::Vector::description
virtual std::string description() const
Return a one-line description of this object.
Definition: Tpetra_Vector_def.hpp:274
Tpetra::Classes::Vector::normWeighted
mag_type TPETRA_DEPRECATED normWeighted(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights) const
Compute Weighted 2-norm (RMS Norm) of this Vector.
Definition: Tpetra_Vector_def.hpp:218
Tpetra::Classes::DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node >
Tpetra::Classes::MultiVector::mag_type
Kokkos::Details::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
Definition: Tpetra_MultiVector_decl.hpp:443
Tpetra::Classes::Vector::clone
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node2 > > clone(const Teuchos::RCP< Node2 > &node2)
Return a deep copy of *this with a different Node type (and therefore a different Device type).
Tpetra::Classes::Vector::~Vector
virtual ~Vector()
Destructor.
Definition: Tpetra_Vector_def.hpp:119
Tpetra::Classes::Vector::node_type
Node node_type
The Kokkos Node type.
Definition: Tpetra_Vector_decl.hpp:112
Tpetra::Classes::MultiVector
One or more distributed dense vectors.
Definition: Tpetra_MultiVector_decl.hpp:389
Tpetra::Details::DefaultTypes::local_ordinal_type
int local_ordinal_type
Default value of Scalar template parameter.
Definition: Tpetra_Details_DefaultTypes.hpp:72
Tpetra::Classes::Vector::dual_view_type
base_type::dual_view_type dual_view_type
Kokkos::DualView specialization used by this class.
Definition: Tpetra_Vector_decl.hpp:130
Tpetra::Classes::MultiVector::dot_type
Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
Definition: Tpetra_MultiVector_decl.hpp:435
Tpetra::createCopy
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &src)
Return a deep copy of the given MultiVector.
Definition: Tpetra_MultiVector_def.hpp:5086
Tpetra::Classes::Map
A parallel distribution of indices over processes.
Definition: Tpetra_Map_decl.hpp:247
Tpetra::Classes::MultiVector::impl_scalar_type
Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
Definition: Tpetra_MultiVector_decl.hpp:414
Tpetra_Vector_fwd.hpp
Forward declaration of Tpetra::Vector.
Tpetra::Classes::Vector::replaceGlobalValue
void replaceGlobalValue(const GlobalOrdinal globalRow, const Scalar &value) const
Replace current value at the specified location with specified value.
Definition: Tpetra_Vector_def.hpp:125
Tpetra::Classes::Vector::dot_type
base_type::dot_type dot_type
Type of an inner ("dot") product result.
Definition: Tpetra_Vector_decl.hpp:119
Tpetra::Classes::Vector::map_type
base_type::map_type map_type
The type of the Map specialization used by this class.
Definition: Tpetra_Vector_decl.hpp:133
Tpetra::Classes::Vector::scalar_type
Scalar scalar_type
This class' first template parameter; the type of each entry in the Vector.
Definition: Tpetra_Vector_decl.hpp:93
Tpetra
Namespace Tpetra contains the class and methods constituting the Tpetra library.
Tpetra::Classes::Vector::norm1
mag_type norm1() const
Return the one-norm of this Vector.
Definition: Tpetra_Vector_def.hpp:187
Tpetra::Classes::Vector::local_ordinal_type
LocalOrdinal local_ordinal_type
This class' second template parameter; the type of local indices.
Definition: Tpetra_Vector_decl.hpp:105
Tpetra::Classes::Vector::device_type
Node::device_type device_type
The Kokkos device type.
Definition: Tpetra_Vector_decl.hpp:109
Tpetra::Classes::Vector::Vector
Vector()
Default constructor: makes a Vector with no rows or columns.
Definition: Tpetra_Vector_def.hpp:64
Tpetra::createVector
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.
Definition: Tpetra_Vector_decl.hpp:408
Tpetra::Classes::Vector::mag_type
base_type::mag_type mag_type
Type of a norm result.
Definition: Tpetra_Vector_decl.hpp:127
Tpetra::Classes::Vector
A distributed dense vector.
Definition: Tpetra_Vector_decl.hpp:82