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"
55 
56 namespace Tpetra {
57 
78 template <class Scalar = ::Tpetra::Details::DefaultTypes::scalar_type,
80  class GlobalOrdinal = ::Tpetra::Details::DefaultTypes::global_ordinal_type,
82  const bool classic = Node::classic>
83 class Vector :
84  public MultiVector<Scalar,
85  LocalOrdinal,
86  GlobalOrdinal,
87  Node,
88  classic>
89 {
90 private:
91  friend class MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic>;
93 
94 public:
96 
97 
100  typedef Scalar scalar_type;
112  typedef LocalOrdinal local_ordinal_type;
114  typedef GlobalOrdinal global_ordinal_type;
116  typedef typename Node::device_type device_type;
117 
119  typedef Node node_type;
120 
126  typedef typename base_type::dot_type dot_type;
127 
134  typedef typename base_type::mag_type mag_type;
135 
138 
140  typedef typename base_type::map_type map_type;
141 
143 
145 
151  //
156  explicit Vector (const Teuchos::RCP<const map_type>& map,
157  const bool zeroOut = true);
158 
168 
181  const Teuchos::DataAccess copyOrView);
182 
184  Vector (const Teuchos::RCP<const map_type>& map,
185  const Teuchos::ArrayView<const Scalar>& A);
186 
199  Vector (const Teuchos::RCP<const map_type>& map,
200  const dual_view_type& view);
201 
216  Vector (const Teuchos::RCP<const map_type>& map,
217  const dual_view_type& view,
218  const dual_view_type& origView);
219 
221  virtual ~Vector ();
222 
224 
226 
232  template <class Node2>
233  Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node2, Node2::classic> >
234  clone (const Teuchos::RCP<Node2>& node2);
235 
237 
239 
241 
243  void replaceGlobalValue (const GlobalOrdinal globalRow, const Scalar& value) const;
244 
264  void
265  sumIntoGlobalValue (const GlobalOrdinal globalRow,
266  const Scalar& value,
267  const bool atomic = base_type::useAtomicUpdatesByDefault) const;
268 
270 
272  void replaceLocalValue (const LocalOrdinal myRow, const Scalar& value) const;
273 
291  void
292  sumIntoLocalValue (const LocalOrdinal myRow,
293  const Scalar& value,
294  const bool atomic = base_type::useAtomicUpdatesByDefault) const;
295 
297 
299 
300 
303  void get1dCopy (const Teuchos::ArrayView<Scalar>& A) const;
304 
307  Teuchos::ArrayRCP<Scalar> getDataNonConst () {
308  return getDataNonConst (0);
309  }
310 
313  Teuchos::ArrayRCP<const Scalar> getData () const {
314  return getData (0);
315  }
316 
317  Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
318  offsetView (const Teuchos::RCP<const map_type>& subMap,
319  const size_t offset) const;
320 
321  Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
322  offsetViewNonConst (const Teuchos::RCP<const map_type>& subMap,
323  const size_t offset);
325 
327 
331 
334  mag_type norm1() const;
335 
338  mag_type norm2() const;
339 
342  mag_type normInf() const;
343 
348  mag_type TPETRA_DEPRECATED
350 
353  Scalar meanValue () const;
354 
356 
358 
360  virtual std::string description () const;
361 
383  virtual void
384  describe (Teuchos::FancyOStream& out,
385  const Teuchos::EVerbosityLevel verbLevel =
386  Teuchos::Describable::verbLevel_default) const;
388 }; // class Vector
389 
390 
393 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, const bool classic = Node::classic>
394 Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic>
395 createCopy (const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic>& src);
396 
402 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, const bool classic = Node::classic>
403 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
404 createVector (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& map)
405 {
407 }
408 
409 } // namespace Tpetra
410 
411 #endif // TPETRA_VECTOR_DECL_HPP
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node2, Node2::classic > > clone(const Teuchos::RCP< Node2 > &node2)
Return a deep copy of *this with a different Node type (and therefore a different Device type)...
Vector(const Teuchos::RCP< const map_type > &map, const bool zeroOut=true)
Basic constructor.
Namespace Tpetra contains the class and methods constituting the Tpetra library.
base_type::impl_scalar_type impl_scalar_type
The type used internally in place of Scalar.
MultiVector< ST, LO, GO, NT, classic > createCopy(const MultiVector< ST, LO, GO, NT, classic > &src)
Return a deep copy of the given MultiVector.
virtual std::string description() const
Return a one-line description of this object.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
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.
GlobalOrdinal global_ordinal_type
This class&#39; third template parameter; the type of global indices.
base_type::dot_type dot_type
Type of an inner ("dot") product result.
One or more distributed dense vectors.
Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner ("dot") product result.
int local_ordinal_type
Default value of LocalOrdinal template parameter.
base_type::mag_type mag_type
Type of a norm result.
mag_type normInf() const
Compute Inf-norm of this Vector.
Declaration of the Tpetra::MultiVector class.
mag_type norm1() const
Return 1-norm of this Vector.
Node node_type
The Kokkos Node type.
virtual ~Vector()
Destructor.
mag_type norm2() const
Compute 2-norm of this Vector.
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
base_type::map_type map_type
The type of the Map specialization used by this class.
Teuchos::ArrayRCP< const Scalar > getData() const
Const view of the local values of this vector.
Teuchos::ArrayRCP< Scalar > getDataNonConst()
View of the local values of this vector.
dot_type dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &y) const
Computes dot product of this Vector against input Vector x.
LocalOrdinal local_ordinal_type
This class&#39; second template parameter; the type of local indices.
double scalar_type
Default value of Scalar template parameter.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > > createVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Nonmember Vector "constructor": Create a Vector from a given Map.
void sumIntoLocalValue(const LocalOrdinal myRow, const Scalar &value, const bool atomic=base_type::useAtomicUpdatesByDefault) const
Add value to existing value, using local (row) index.
void get1dCopy(const Teuchos::ArrayView< Scalar > &A) const
Return multi-vector values in user-provided two-dimensional array (using Teuchos memory management cl...
void replaceGlobalValue(const GlobalOrdinal globalRow, const Scalar &value) const
Replace current value at the specified location with specified value.
Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
Scalar scalar_type
This class&#39; first template parameter; the type of each entry in the Vector.
Kokkos::Details::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
void replaceLocalValue(const LocalOrdinal myRow, const Scalar &value) const
Replace current value at the specified location with specified values.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, typename execution_space::execution_space > dual_view_type
Kokkos::DualView specialization used by this class.
Describes a parallel distribution of objects over processes.
void sumIntoGlobalValue(const GlobalOrdinal globalRow, const Scalar &value, const bool atomic=base_type::useAtomicUpdatesByDefault) const
Add value to existing value, using global (row) index.
A distributed dense vector.
base_type::dual_view_type dual_view_type
Kokkos::DualView specialization used by this class.
mag_type TPETRA_DEPRECATED normWeighted(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &weights) const
Compute Weighted 2-norm (RMS Norm) of this Vector.
Node::device_type device_type
The Kokkos device type.
Scalar meanValue() const
Compute mean (average) value of this Vector.