42 #ifndef TPETRA_VECTOR_DEF_HPP 43 #define TPETRA_VECTOR_DEF_HPP 45 #include <Kokkos_DefaultArithmetic.hpp> 46 #include <Kokkos_NodeTrace.hpp> 47 #include <Tpetra_MultiVector.hpp> 49 #ifdef DOXYGEN_USE_ONLY 50 #include "Tpetra_Vector_decl.hpp" 55 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
57 :
MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(map,1,zeroOut) {
60 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
62 :
MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(source) {
65 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
76 :
MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(map,view,view.size(),1,COMPUTE_VIEW_CONSTRUCTOR) {
79 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
81 :
MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>(map,values,values.size(),1) {
84 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
87 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
92 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
97 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
102 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
107 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
113 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
115 using Teuchos::outArg;
116 #ifdef HAVE_TPETRA_DEBUG 118 "Tpetra::Vector::dots(): Vectors do not have compatible Maps:" << std::endl
119 <<
"this->getMap(): " << std::endl << *this->
getMap()
120 <<
"a.getMap(): " << std::endl << *a.
getMap() << std::endl);
123 "Tpetra::Vector::dots(): Vectors do not have the same local length.");
128 Scalar lcldot = gbldot;
134 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
137 using Teuchos::outArg;
140 Scalar sum = MVT::Sum(this->
lclMV_);
148 return sum / as<typename SCT::magnitudeType> (this->
getGlobalLength ());
151 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
153 using Teuchos::outArg;
155 Mag norm = MVT::Norm1(this->
lclMV_);
163 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
166 using Teuchos::outArg;
168 Mag norm = MVT::Norm2Squared(this->
lclMV_);
176 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
178 using Teuchos::outArg;
180 Mag norm = MVT::NormInf(this->
lclMV_);
188 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
191 using Teuchos::outArg;
193 #ifdef HAVE_TPETRA_DEBUG 195 "Tpetra::Vector::normWeighted(): Vectors do not have compatible Maps:" << std::endl
196 <<
"this->getMap(): " << std::endl << *this->
getMap()
197 <<
"weights.getMap(): " << std::endl << *weights.
getMap() << std::endl);
200 "Tpetra::Vector::normWeighted(): Vectors do not have the same local length.");
202 Mag norm = MVT::WeightedNorm(this->
lclMV_,weights.
lclMV_);
210 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
212 std::ostringstream oss;
219 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
232 const int myImageID = comm->getRank(),
233 numImages = comm->getSize();
241 if (myImageID == 0) out << this->
description() << std::endl;
242 for (
int imageCtr = 0; imageCtr < numImages; ++imageCtr) {
243 if (myImageID == imageCtr) {
246 out <<
"node " << setw(width) << myImageID <<
": local length=" << this->
getLocalLength() << endl;
251 KOKKOS_NODE_TRACE(
"Vector::describe()")
254 MVT::getValues(this->
lclMV_) );
257 out << setw(width) << this->
getMap()->getGlobalElement(i)
259 << myview[i] << endl;
261 myview = Teuchos::null;
282 #define TPETRA_VECTOR_INSTANT(SCALAR,LO,GO,NODE) \ 284 template class Vector< SCALAR , LO , GO , NODE >; \ 287 #endif // TPETRA_VECTOR_DEF_HPP Namespace Tpetra contains the class and methods constituting the Tpetra library.
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.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
Teuchos::ScalarTraits< Scalar >::magnitudeType normWeighted(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights) const
Compute Weighted 2-norm (RMS Norm) of this Vector.
size_t getLocalLength() const
Local number of rows on the calling process.
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
One or more distributed dense vectors.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual std::string description() const
A simple one-line description of this object.
bool isDistributed() const
Whether this is a globally distributed object.
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm of this Vector.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
virtual ~Vector()
Destructor.
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
Scalar dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &a) const
Computes dot product of this Vector against input Vector x.
virtual std::string description() const
const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > & getMap() const
The Map describing the parallel distribution of this object.
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this Vector.
void get1dCopy(ArrayView< Scalar > A) const
Return multi-vector values in user-provided two-dimensional array (using Teuchos memory management cl...
KMV lclMV_
The Kokkos::MultiVector containing the compute buffer of data.
Describes a parallel distribution of objects over processes.
Vector(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true)
Sets all vector entries to zero.
void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
TypeTo as(const TypeFrom &t)
A distributed dense vector.
Scalar meanValue() const
Compute mean (average) value of this Vector.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.