42#ifndef TPETRA_VECTOR_DEF_HPP
43#define TPETRA_VECTOR_DEF_HPP
48#include "Tpetra_MultiVector.hpp"
50#include "KokkosCompat_View.hpp"
51#include "KokkosBlas1_nrm2w_squared.hpp"
52#include "Teuchos_CommHelpers.hpp"
56 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
62 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 Vector (
const Teuchos::RCP<const map_type>&
map,
69 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
76 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 const Teuchos::RCP<const map_type>&
map,
84 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
86 Vector (
const Teuchos::RCP<const map_type>&
map,
87 const Teuchos::ArrayView<const Scalar>&
values)
91 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
93 Vector (
const Teuchos::RCP<const map_type>&
map,
98 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
100 Vector (
const Teuchos::RCP<const map_type>&
map,
106 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
113 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
117 this->base_type::replaceGlobalValue (
globalRow, 0, value);
120 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
127 this->base_type::sumIntoGlobalValue (
globalRow, 0, value, atomic);
130 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
134 this->base_type::replaceLocalValue (
myRow, 0, value);
137 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
144 this->base_type::sumIntoLocalValue (
globalRow, 0, value, atomic);
147 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
150 get1dCopy (
const Teuchos::ArrayView<Scalar>&
A)
const {
151 const size_t lda = this->getLocalLength ();
152 this->get1dCopy (
A,
lda);
155 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
161 this->dot (
y, Teuchos::arrayView (&
result, 1));
165 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
171 this->meanValue (Teuchos::arrayView (&
mean, 1));
175 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
181 this->norm1 (Teuchos::arrayView (&
norm, 1));
185 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
191 this->norm2 (Teuchos::arrayView (&
norm, 1));
195 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
201 this->normInf (Teuchos::arrayView (&
norm, 1));
206 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
210 return this->descriptionImpl (
"Tpetra::Vector");
213 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
216 const Teuchos::EVerbosityLevel
verbLevel)
const
221 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
222 Teuchos::RCP<const Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
225 const size_t offset)
const
228 using Kokkos::subview;
235 const int myRank = this->getMap ()->getComm ()->getRank ();
238 "Tpetra::Vector::offsetView(NonConst): Invalid input Map. The input "
240 "offset = " <<
offset <<
". Yet, the Vector contains only "
241 << this->getOrigNumLocalRows () <<
" rows on this process.");
244 const std::pair<size_t, size_t> offsetPair (offset, offset + newNumRows);
246 return rcp (
new V (subMap,
247 subview (this->view_, offsetPair, ALL ()),
251 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
252 Teuchos::RCP<Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
253 Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
254 offsetViewNonConst (
const Teuchos::RCP<const map_type>& subMap,
257 typedef Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node> V;
258 return Teuchos::rcp_const_cast<V> (this->offsetView (subMap, offset));
261 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
262 Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
268 vec_type dst (src, Teuchos::Copy);
286#define TPETRA_VECTOR_INSTANT(SCALAR,LO,GO,NODE) \
287 template class Vector< SCALAR , LO , GO , NODE >; \
288 template Vector< SCALAR , LO , GO , NODE > createCopy (const Vector< SCALAR , LO , GO , NODE >& src);
Declaration of a function that prints strings from each process.
Struct that holds views of the contents of a CrsMatrix.
One or more distributed dense vectors.
A distributed dense vector.
void replaceGlobalValue(const GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
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.
mag_type norm2() const
Return the two-norm of this Vector.
base_type::dot_type dot_type
Type of an inner ("dot") product result.
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.
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.
virtual std::string description() const
Return a one-line description of this object.
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.
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.
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.