10 #ifndef XPETRA_BLOCKEDVECTOR_DEF_HPP
11 #define XPETRA_BLOCKEDVECTOR_DEF_HPP
15 #include "Xpetra_BlockedMultiVector.hpp"
20 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
23 : Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(map, 1, zeroOut) {}
25 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
26 BlockedVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>::
31 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
35 : Xpetra::
BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>(mapExtractor, v) {}
37 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
41 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
49 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
55 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
73 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
85 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
91 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
97 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
103 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
104 Teuchos::RCP<const Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
110 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
111 Teuchos::RCP<Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
117 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
118 Teuchos::ArrayRCP<const Scalar>
124 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
125 Teuchos::ArrayRCP<Scalar>
131 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
138 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
142 Teuchos::Array<Scalar> dots = Teuchos::Array<Scalar>(1);
147 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
154 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
161 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
168 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
170 scale(Teuchos::ArrayView<const Scalar> alpha) {
175 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
179 const Scalar& beta) {
184 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
190 const Scalar& gamma) {
195 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
196 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
199 using Array = Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>;
200 Array norm = Array(1);
205 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
206 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
209 Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType> norm =
210 Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>(1);
215 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
216 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
219 Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>
220 norm = Teuchos::Array<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>(1);
225 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
227 norm1(
const Teuchos::ArrayView<
typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& norms)
const {
231 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
233 norm2(
const Teuchos::ArrayView<
typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& norms)
const {
237 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
239 normInf(
const Teuchos::ArrayView<
typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& norms)
const {
243 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
249 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
256 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
267 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
278 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
287 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
295 "BlockedVector::elementWiseMultipy: B must have same blocked map than this.");
296 TEUCHOS_TEST_FOR_EXCEPTION(A.
getMap()->getLocalNumElements() != B.
getMap()->getLocalNumElements(),
298 "BlockedVector::elementWiseMultipy: A has "
299 << A.
getMap()->getLocalNumElements() <<
" elements, B has " << B.
getMap()->getLocalNumElements()
301 TEUCHOS_TEST_FOR_EXCEPTION(A.
getMap()->getGlobalNumElements() != B.
getMap()->getGlobalNumElements(),
303 "BlockedVector::elementWiseMultipy: A has " << A.
getMap()->getGlobalNumElements()
304 <<
" elements, B has "
305 << B.
getMap()->getGlobalNumElements() <<
".");
307 RCP<const BlockedMap> bmap = this->getBlockedMap();
308 RCP<const Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> rcpA = Teuchos::rcpFromRef(A);
309 RCP<const Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>> bmvec = Teuchos::rcpFromRef(B);
310 RCP<const BlockedVector> bbmvec = Teuchos::rcp_dynamic_cast<
const BlockedVector>(bmvec);
311 TEUCHOS_TEST_FOR_EXCEPTION(bbmvec.is_null() ==
true,
313 "BlockedVector::elementWiseMultipy: B must be a BlockedVector.");
328 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
335 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
340 "BlockedVector::getLocalLength: routine not implemented. It has no value as one must iterate on the partial vectors.");
341 TEUCHOS_UNREACHABLE_RETURN(0);
344 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
348 return this->getBlockedMap()->getFullMap()->getGlobalNumElements();
351 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
355 "BlockedVector::isSameSize: routine not implemented. It has no value as one must iterate on the partial vectors.");
356 TEUCHOS_UNREACHABLE_RETURN(0);
359 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
363 return std::string(
"BlockedVector");
366 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
368 describe(Teuchos::FancyOStream& out,
const Teuchos::EVerbosityLevel verbLevel)
const {
369 out << description() << std::endl;
370 for (
size_t r = 0; r < this->getBlockedMap()->getNumMaps(); r++) {
371 getMultiVector(r)->describe(out, verbLevel);
375 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
381 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
389 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
397 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
405 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
413 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
416 for (
size_t r = 0; r < this->getBlockedMap()->getNumMaps(); ++r) {
417 getMultiVector(r)->setSeed(seed);
421 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
424 for (
size_t r = 0; r < this->getBlockedMap()->getNumMaps(); ++r) {
425 getMultiVector(r)->randomize(bUseXpetraImplementation);
429 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
431 randomize(
const Scalar& minVal,
const Scalar& maxVal,
bool bUseXpetraImplementation) {
432 for (
size_t r = 0; r < this->getBlockedMap()->getNumMaps(); ++r) {
433 getMultiVector(r)->randomize(minVal, maxVal, bUseXpetraImplementation);
437 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
445 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
453 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
454 Teuchos::RCP<const Xpetra::Map<LocalOrdinal, GlobalOrdinal, Node>>
458 return this->getBlockedMap();
461 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
462 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
468 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
469 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
475 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
484 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
485 Teuchos::RCP<Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
491 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
506 #endif // XPETRA_BLOCKEDVECTOR_DEF_HPP
virtual Teuchos::RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
virtual void reciprocal(const MultiVector &)
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).
virtual Scalar meanValue() const
Compute mean (average) value of this Vector.
void setMultiVector(size_t r, Teuchos::RCP< const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node >> v, bool bThyraMode)
set partial Vector associated with block row r
virtual void setSeed(unsigned int seed)
Set seed for Random function.
virtual void multiply(Teuchos::ETransp, Teuchos::ETransp, const Scalar &, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Scalar &)
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
virtual void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
virtual void update(const Scalar &alpha, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
virtual Teuchos::RCP< const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
virtual void sumIntoGlobalValue(GlobalOrdinal, size_t, const Scalar &)
Add value to existing value, using global (row) index.
virtual Teuchos::RCP< const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
virtual void elementWiseMultiply(Scalar, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, Scalar)
Element-wise multiply of a Vector A with a MultiVector B.
virtual void scale(const Scalar &alpha)
Scale the current values of a vector, this = alpha*this.
virtual void replaceMap(const RCP< const Map > &map)
virtual size_t getNumVectors() const
Number of columns in the Vector.
virtual Teuchos::RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
virtual void replaceGlobalValue(GlobalOrdinal, size_t, const Scalar &)
Replace value, using global (row) index.
virtual std::string description() const
A simple one-line description of this object.
Exception throws to report errors in the internal logical of the program.
virtual void Xpetra_randomize()
Set multi-vector values to random numbers. XPetra implementation.
virtual void abs(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input vector in target: A = abs(this).
virtual void sumIntoLocalValue(LocalOrdinal, size_t, const Scalar &)
Add value to existing value, using local (row) index.
virtual void dot(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
virtual void update(const Scalar &alpha, const MultiVector &A, const Scalar &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
virtual void replaceLocalValue(LocalOrdinal, size_t, const Scalar &)
Replace value, using local (row) index.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
Teuchos::RCP< MultiVector > Merge() const
merge BlockedMultiVector blocks to a single MultiVector
virtual void reciprocal(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise reciprocal values of input vector in target, this(i,j) = 1/A(i,j).
virtual void norm2(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
virtual bool isSameSize(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &) const
Local number of rows on the calling process.
virtual void assign(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
virtual void replaceMap(const RCP< const Map > &map)
Teuchos::RCP< const Map > getMap() const
Access function for the underlying Map this DistObject was constructed with.
virtual size_t getLocalLength() const
Local number of rows on the calling process.
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const =0
The Map describing the parallel distribution of this object.
virtual void randomize(bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
virtual void scale(const Scalar &alpha)
Scale the current values of a multi-vector, this = alpha*this.
virtual ~BlockedVector()
Destructor.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of vector.
void setMultiVector(size_t r, Teuchos::RCP< const MultiVector > v, bool bThyraMode)
set partial multivector associated with block row r
virtual void norm1(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
virtual void normInf(const Teuchos::ArrayView< typename Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
size_t global_size_t
Global size_t object.
virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
virtual void abs(const MultiVector &)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
BlockedVector(const Teuchos::RCP< const BlockedMap > &map, bool zeroOut=true)
Constructor.
virtual void dot(const MultiVector &, const Teuchos::ArrayView< Scalar > &) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
Teuchos::RCP< MultiVector > getMultiVector(size_t r) const
return partial multivector associated with block row r
virtual void assign(const MultiVector &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Merge() const
merge BlockedVector blocks to a single Vector
virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this vector.
#define XPETRA_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Compute 1-norm of vector.
virtual void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this vector.
virtual global_size_t getGlobalLength() const
Global number of rows in the Vector.
virtual void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
BlockedVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Assignment operator: Does a deep copy.
CombineMode
Xpetra::Combine Mode enumerable type.
#define XPETRA_MONITOR(funcName)
virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm in vector.
virtual void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Import &, CombineMode)
Import.
virtual void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Import &, CombineMode)
Export.
virtual void putScalar(const Scalar &value)
Set all values in the vector with the given value.
virtual void Xpetra_randomize()
Set vector values to random numbers. XPetra implementation.
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getMultiVector(size_t r) const
return partial Vector associated with block row r
virtual void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.