46 #ifndef XPETRA_EPETRAMULTIVECTOR_HPP 47 #define XPETRA_EPETRAMULTIVECTOR_HPP 61 #include <Epetra_MultiVector.h> 66 const Epetra_MultiVector &
toEpetra(
const MultiVector<double,int,int> &);
68 Epetra_MultiVector &
toEpetra(MultiVector<double, int,int> &);
76 RCP<MultiVector<double, int, int> >
toXpetra(RCP<Epetra_MultiVector> vec);
98 :
vec_(Teuchos::rcp(new Epetra_MultiVector(
toEpetra(map), NumVectors, zeroOut))) { }
102 :
vec_(Teuchos::rcp(new Epetra_MultiVector(
toEpetra(source)))) { }
116 void replaceGlobalValue(GlobalOrdinal globalRow,
size_t vectorIndex,
const Scalar &value) {
XPETRA_MONITOR(
"EpetraMultiVector::replaceGlobalValue");
vec_->ReplaceGlobalValue(globalRow, vectorIndex, value); }
119 void sumIntoGlobalValue(GlobalOrdinal globalRow,
size_t vectorIndex,
const Scalar &value) {
XPETRA_MONITOR(
"EpetraMultiVector::sumIntoGlobalValue");
vec_->SumIntoGlobalValue(globalRow, vectorIndex, value); }
122 void replaceLocalValue(LocalOrdinal myRow,
size_t vectorIndex,
const Scalar &value) {
XPETRA_MONITOR(
"EpetraMultiVector::replaceLocalValue");
vec_->ReplaceMyValue(myRow, vectorIndex, value); }
125 void sumIntoLocalValue(LocalOrdinal myRow,
size_t vectorIndex,
const Scalar &value) {
XPETRA_MONITOR(
"EpetraMultiVector::sumIntoLocalValue");
vec_->SumIntoMyValue(myRow, vectorIndex, value); }
136 Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > >
getVector(
size_t j)
const;
139 Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > >
getVectorNonConst(
size_t j);
142 Teuchos::ArrayRCP< const Scalar >
getData(
size_t j)
const;
168 void update(
const Scalar &alpha,
const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A,
const Scalar &beta,
const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B,
const Scalar &gamma) {
XPETRA_MONITOR(
"EpetraMultiVector::update");
vec_->Update(alpha,
toEpetra(A), beta,
toEpetra(B), gamma); }
171 void norm1(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const;
174 void norm2(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const;
177 void normInf(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const;
183 void meanValue(
const Teuchos::ArrayView< Scalar > &means)
const;
186 void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB,
const Scalar &alpha,
const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A,
const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B,
const Scalar &beta) {
XPETRA_MONITOR(
"EpetraMultiVector::multiply");
vec_->Multiply(
toEpetra(transA),
toEpetra(transB), alpha,
toEpetra(A),
toEpetra(B), beta); }
189 void elementWiseMultiply(Scalar scalarAB,
const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A,
const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis) {
XPETRA_MONITOR(
"EpetraMultiVector::elementWiseMultiply");
vec_->Multiply(scalarAB,
toEpetra(A),
toEpetra(B), scalarThis); }
214 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const;
222 if(bUseXpetraImplementation)
264 Teuchos::ScalarTraits< Scalar >::seedrandom(seed);
272 RCP< Epetra_MultiVector >
vec_;
278 #endif // XPETRA_EPETRAMULTIVECTOR_HPP void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
RCP< const CrsGraph< int, int > > toXpetra(const Epetra_CrsGraph &g)
void setSeed(unsigned int seed)
Set seed for Random function.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
void randomize(bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
size_t getLocalLength() const
Local number of rows on the calling process.
virtual void Xpetra_randomize()
Set multi-vector values to random numbers. XPetra implementation.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis)
Element-wise multiply of a Vector A with a MultiVector B.
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
Get the underlying Epetra multivector.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, int > > &graph)
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &gamma)
Update multi-vector with scaled values of A and B, this = gamma*this + alpha*A + beta*B.
void meanValue(const Teuchos::ArrayView< Scalar > &means) const
Compute mean (average) value of each vector in multi-vector. The outcome of this routine is undefined...
void scale(const Scalar &alpha)
Scale the current values of a multi-vector, this = alpha*this.
Kokkos::DefaultNode::DefaultNodeType Node
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
EpetraMultiVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Basic MultiVector constuctor.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &beta)
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
EpetraMultiVector(const RCP< Epetra_MultiVector > &vec)
EpetraMultiVector constructor to wrap a Epetra_MultiVector object.
void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
size_t global_size_t
Global size_t object.
RCP< Epetra_MultiVector > vec_
virtual ~EpetraMultiVector()
MultiVector destructor.
size_t getNumVectors() const
Number of columns in the multivector.
EpetraMultiVector(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source)
MultiVector copy constructor.
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
CombineMode
Xpetra::Combine Mode enumerable type.
#define XPETRA_MONITOR(funcName)
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
void normWeighted(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights, const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
std::string description() const
A simple one-line description of this object.
void dot(const 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]).
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.
const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
void replaceMap(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Replace the map.
void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,j).