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 = Details::DefaultTypes::scalar_type,
79  class LocalOrdinal = Details::DefaultTypes::local_ordinal_type,
80  class GlobalOrdinal = 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 Node node_type;
117 
123  typedef typename base_type::dot_type dot_type;
124 
131  typedef typename base_type::mag_type mag_type;
132 
135 
137  typedef typename base_type::map_type map_type;
138 
140 
142 
148  //
153  explicit Vector (const Teuchos::RCP<const map_type>& map,
154  const bool zeroOut = true);
155 
165 
178  const Teuchos::DataAccess copyOrView);
179 
181  Vector (const Teuchos::RCP<const map_type>& map,
182  const Teuchos::ArrayView<const Scalar>& A);
183 
196  Vector (const Teuchos::RCP<const map_type>& map,
197  const dual_view_type& view);
198 
213  Vector (const Teuchos::RCP<const map_type>& map,
214  const dual_view_type& view,
215  const dual_view_type& origView);
216 
218  virtual ~Vector ();
219 
221 
223 
229  template <class Node2>
230  Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node2, Node2::classic> >
231  clone (const Teuchos::RCP<Node2>& node2);
232 
234 
236 
238 
240  void replaceGlobalValue (GlobalOrdinal globalRow, const Scalar& value);
241 
243 
245  void sumIntoGlobalValue (GlobalOrdinal globalRow, const Scalar& value);
246 
248 
250  void replaceLocalValue (LocalOrdinal myRow, const Scalar& value);
251 
253 
255  void sumIntoLocalValue (LocalOrdinal myRow, const Scalar& value);
256 
258 
260 
261 
264  void get1dCopy (const Teuchos::ArrayView<Scalar>& A) const;
265 
268  Teuchos::ArrayRCP<Scalar> getDataNonConst () {
269  return getDataNonConst (0);
270  }
271 
274  Teuchos::ArrayRCP<const Scalar> getData () const {
275  return getData (0);
276  }
277 
278  Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
279  offsetView (const Teuchos::RCP<const map_type>& subMap,
280  const size_t offset) const;
281 
282  Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
283  offsetViewNonConst (const Teuchos::RCP<const map_type>& subMap,
284  const size_t offset);
286 
288 
292 
295  mag_type norm1() const;
296 
299  mag_type norm2() const;
300 
303  mag_type normInf() const;
304 
307  mag_type
309 
312  Scalar meanValue () const;
313 
315 
317 
319  virtual std::string description() const;
320 
322  virtual void
323  describe (Teuchos::FancyOStream& out,
324  const Teuchos::EVerbosityLevel verbLevel =
325  Teuchos::Describable::verbLevel_default) const;
327 }; // class Vector
328 
329 
332 template<class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, const bool classic = Node::classic>
335 
341 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, const bool classic = Node::classic>
342 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node, classic> >
343 createVector (const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >& map)
344 {
346 }
347 
348 } // namespace Tpetra
349 
350 #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.
Teuchos::ArrayRCP< const Scalar > getData() const
Const view of the local values of this vector.
Scalar meanValue() const
Compute mean (average) value of this Vector.
base_type::impl_scalar_type impl_scalar_type
The type used internally in place of Scalar.
KokkosClassic::DefaultNode::DefaultNodeType node_type
Default value of Node template parameter.
mag_type normWeighted(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &weights) const
Compute Weighted 2-norm (RMS Norm) of this Vector.
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.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to a FancyOStream.
One or more distributed dense vectors.
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.
mag_type norm2() const
Compute 2-norm of this Vector.
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.
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
base_type::mag_type mag_type
Type of a norm result.
Declaration of the Tpetra::MultiVector class.
Node node_type
The Kokkos Node type.
dot_type dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &y) const
Computes dot product of this Vector against input Vector x.
virtual ~Vector()
Destructor.
base_type::map_type map_type
The type of the Map specialization used by this class.
Teuchos::ArrayRCP< Scalar > getDataNonConst()
View of the local values of this vector.
LocalOrdinal local_ordinal_type
This class&#39; second template parameter; the type of local indices.
double scalar_type
Default value of Scalar template parameter.
void get1dCopy(const Teuchos::ArrayView< Scalar > &A) const
Return multi-vector values in user-provided two-dimensional array (using Teuchos memory management cl...
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Kokkos::Details::ArithTraits< Scalar >::val_type impl_scalar_type
The type used internally in place of Scalar.
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
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.
mag_type normInf() const
Compute Inf-norm of this Vector.
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 sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > createCopy(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node, classic > &src)
Return a deep copy of the given Vector.
A distributed dense vector.
base_type::dual_view_type dual_view_type
Kokkos::DualView specialization used by this class.
virtual std::string description() const
A simple one-line description of this object.
mag_type norm1() const
Return 1-norm of this Vector.