Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
77 template <class Scalar,
78  class LocalOrdinal,
79  class GlobalOrdinal,
80  class Node>
81 class Vector : public MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
82 {
83 private:
85 
86 public:
88 
89 
92  typedef Scalar scalar_type;
104  typedef LocalOrdinal local_ordinal_type;
106  typedef GlobalOrdinal global_ordinal_type;
108  typedef typename Node::device_type device_type;
109 
111  typedef Node node_type;
112 
118  typedef typename base_type::dot_type dot_type;
119 
126  typedef typename base_type::mag_type mag_type;
127 
130 
132  typedef typename base_type::map_type map_type;
133 
135 
137 
139  Vector ();
140 
146  //
151  explicit Vector (const Teuchos::RCP<const map_type>& map,
152  const bool zeroOut = true);
153 
166  const Teuchos::DataAccess copyOrView);
167 
174  const Teuchos::RCP<const map_type>& map,
175  const local_ordinal_type rowOffset = 0);
176 
178  Vector (const Teuchos::RCP<const map_type>& map,
179  const Teuchos::ArrayView<const Scalar>& A);
180 
193  Vector (const Teuchos::RCP<const map_type>& map,
194  const dual_view_type& view);
195 
210  Vector (const Teuchos::RCP<const map_type>& map,
211  const dual_view_type& view,
212  const dual_view_type& origView);
213 
220  const size_t j);
221 
231 
234 
242 
246 
256  virtual ~Vector () = default;
258 
260 
261 
263 
265  void replaceGlobalValue (const GlobalOrdinal globalRow, const Scalar& value) const;
266 
286  void
287  sumIntoGlobalValue (const GlobalOrdinal globalRow,
288  const Scalar& value,
289  const bool atomic = base_type::useAtomicUpdatesByDefault) const;
290 
292 
294  void replaceLocalValue (const LocalOrdinal myRow, const Scalar& value) const;
295 
313  void
314  sumIntoLocalValue (const LocalOrdinal myRow,
315  const Scalar& value,
316  const bool atomic = base_type::useAtomicUpdatesByDefault) const;
317 
319 
321 
322 
325  void get1dCopy (const Teuchos::ArrayView<Scalar>& A) const;
326 
329  Teuchos::ArrayRCP<Scalar> getDataNonConst () {
330  return getDataNonConst (0);
331  }
332 
335  Teuchos::ArrayRCP<const Scalar> getData () const {
336  return getData (0);
337  }
338 
339  Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
340  offsetView (const Teuchos::RCP<const map_type>& subMap,
341  const size_t offset) const;
342 
343  Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
344  offsetViewNonConst (const Teuchos::RCP<const map_type>& subMap,
345  const size_t offset);
347 
349 
350  using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::dot; // overloading, not hiding
353 
354  using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm1; // overloading, not hiding
356  mag_type norm1() const;
357 
358  using MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::norm2; // overloading, not hiding
360  mag_type norm2() const;
361 
364  mag_type normInf() const;
365 
366 
369  Scalar meanValue () const;
370 
372 
374 
376  virtual std::string description () const;
377 
399  virtual void
400  describe (Teuchos::FancyOStream& out,
401  const Teuchos::EVerbosityLevel verbLevel =
402  Teuchos::Describable::verbLevel_default) const;
404 }; // class Vector
405 
408 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
409 Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
410 createCopy (const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& src);
411 
417 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
418 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
419 createVector (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& map)
420 {
422 }
423 
424 } // namespace Tpetra
425 
426 #endif // TPETRA_VECTOR_DECL_HPP
void sumIntoGlobalValue(const GlobalOrdinal globalRow, const Scalar &value, const bool atomic=base_type::useAtomicUpdatesByDefault) const
Add value to existing value, using global (row) index.
Vector()
Default constructor: makes a Vector with no rows or columns.
mag_type norm2() const
Return the two-norm of this Vector.
Teuchos::ArrayRCP< Scalar > getDataNonConst()
View of the local values of this vector.
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 & operator=(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &)=default
Copy assignment (shallow copy).
base_type::mag_type mag_type
Type of a norm result.
Node::device_type device_type
The Kokkos device type.
void replaceGlobalValue(const GlobalOrdinal globalRow, const Scalar &value) const
Replace current value at the specified location with specified value.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutLeft, execution_space > dual_view_type
Kokkos::DualView specialization used by this class.
base_type::impl_scalar_type impl_scalar_type
The type used internally in place of Scalar.
void get1dCopy(const Teuchos::ArrayView< Scalar > &A) const
Return multi-vector values in user-provided two-dimensional array (using Teuchos memory management cl...
One or more distributed dense vectors.
virtual std::string description() const
Return a one-line description of this object.
static const bool useAtomicUpdatesByDefault
Whether sumIntoLocalValue and sumIntoGlobalValue should use atomic updates by default.
MultiVector< ST, LO, GO, NT > createCopy(const MultiVector< ST, LO, GO, NT > &src)
Return a deep copy of the given MultiVector.
dot_type dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &y) const
Return the dot product of this Vector and the input Vector x.
GlobalOrdinal global_ordinal_type
This class&#39; third template parameter; the type of global indices.
Scalar scalar_type
This class&#39; first template parameter; the type of each entry in the Vector.
void sumIntoLocalValue(const LocalOrdinal myRow, const Scalar &value, const bool atomic=base_type::useAtomicUpdatesByDefault) const
Add value to existing value, using local (row) index.
Declaration of the Tpetra::MultiVector class.
Teuchos::ArrayRCP< const Scalar > getData() const
Const view of the local values of this vector.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > createVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Nonmember Vector &quot;constructor&quot;: Create a Vector from a given Map.
virtual ~Vector()=default
Destructor (virtual for memory safety of derived classes).
typename Kokkos::Details::InnerProductSpaceTraits< impl_scalar_type >::dot_type dot_type
Type of an inner (&quot;dot&quot;) product result.
LocalOrdinal local_ordinal_type
This class&#39; second template parameter; the type of local indices.
typename Kokkos::ArithTraits< impl_scalar_type >::mag_type mag_type
Type of a norm result.
Forward declaration of Tpetra::Vector.
typename Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
A parallel distribution of indices over processes.
Node node_type
The Kokkos Node type.
A distributed dense vector.
base_type::dual_view_type dual_view_type
Kokkos::DualView specialization used by this class.
typename map_type::local_ordinal_type local_ordinal_type
The type of local indices that this class uses.
Scalar meanValue() const
Compute mean (average) value of this Vector.
base_type::map_type map_type
The type of the Map specialization used by this class.
mag_type normInf() const
Return the infinity-norm of this Vector.
base_type::dot_type dot_type
Type of an inner (&quot;dot&quot;) product result.
Base class for distributed Tpetra objects that support data redistribution.
mag_type norm1() const
Return the one-norm of this Vector.
void replaceLocalValue(const LocalOrdinal myRow, const Scalar &value) const
Replace current value at the specified location with specified values.