46 #ifndef XPETRA_EPETRAMULTIVECTOR_HPP 47 #define XPETRA_EPETRAMULTIVECTOR_HPP 51 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 52 #include <Kokkos_Core.hpp> 53 #include <Kokkos_DualView.hpp> 59 #include "Xpetra_MultiVector.hpp" 68 #include "Epetra_SerialComm.h" 70 #include <Epetra_MultiVector.h> 71 #include <Epetra_Vector.h> 76 template<
class GlobalOrdinal,
class Node>
77 const Epetra_MultiVector &
toEpetra(
const MultiVector<double,int,GlobalOrdinal,Node> &);
78 template<
class GlobalOrdinal,
class Node>
79 Epetra_MultiVector &
toEpetra(MultiVector<double, int,GlobalOrdinal,Node> &);
80 template<
class GlobalOrdinal,
class Node>
81 RCP<MultiVector<double, int, GlobalOrdinal, Node> >
toXpetra(RCP<Epetra_MultiVector> vec);
84 #ifndef DOXYGEN_SHOULD_SKIP_THIS 85 template<
class GlobalOrdinal,
class Node>
class EpetraVectorT;
88 template<
class EpetraGlobalOrdinal,
class Node>
90 :
public virtual MultiVector<double, int, EpetraGlobalOrdinal, Node>
104 "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
110 "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
116 "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
148 Teuchos::RCP< const Vector< double, int, GlobalOrdinal, Node > >
getVector(
size_t j)
const {
149 return Teuchos::null;
154 return Teuchos::null;
158 Teuchos::ArrayRCP< const Scalar >
getData(
size_t j)
const {
159 return ArrayRCP<const Scalar>();
164 return ArrayRCP<Scalar>();
185 void scale (Teuchos::ArrayView< const Scalar > alpha) { }
191 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) { }
194 void norm1(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const { }
197 void norm2(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const { }
200 void normInf(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const { }
203 void meanValue(
const Teuchos::ArrayView< Scalar > &means)
const { }
206 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) { }
237 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default)
const { }
242 void randomize(
bool bUseXpetraImplementation =
false) { }
248 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getMap()
const {
return Teuchos::null; }
273 "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
293 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES 296 :
public virtual MultiVector<double, int, int, EpetraNode>
310 : vec_(Teuchos::rcp(new Epetra_MultiVector(
toEpetra<
GlobalOrdinal,
Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) { }
314 if (copyOrView == Teuchos::Copy)
315 vec_ = Teuchos::rcp(
new Epetra_MultiVector(toEpetra<GlobalOrdinal,Node>(source)));
320 vec_ = Teuchos::rcp(
new Epetra_MultiVector(View, toEpetra<GlobalOrdinal,Node>(source), indices, source.
getNumVectors()));
329 const std::string tfecfFuncName(
"MultiVector(ArrayOfPtrs)");
330 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
331 ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
333 #ifdef HAVE_XPETRA_DEBUG 336 size_t localLength = map->getNodeNumElements();
337 for(
int j=0; j<ArrayOfPtrs.size(); j++) {
338 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
339 ": ArrayOfPtrs[" << j <<
"].size() (== " << ArrayOfPtrs[j].size() <<
340 ") is not equal to getLocalLength() (== " << localLength);
347 Array<const double*> arrayOfRawPtrs(ArrayOfPtrs.size());
348 for(
int i=0; i<ArrayOfPtrs.size(); i++) {
349 arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
351 double** rawArrayOfRawPtrs =
const_cast<double**
>(arrayOfRawPtrs.getRawPtr());
353 vec_ = Teuchos::rcp(
new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal,Node>(map), rawArrayOfRawPtrs, static_cast<int>(NumVectors)));
385 Teuchos::RCP< const Vector< double, int, int, EpetraNode > >
getVector(
size_t j)
const;
388 Teuchos::RCP< Vector< double, int, int, EpetraNode > >
getVectorNonConst(
size_t j);
391 Teuchos::ArrayRCP< const Scalar >
getData(
size_t j)
const {
394 double ** arrayOfPointers;
396 vec_->ExtractView(&arrayOfPointers);
398 double * data = arrayOfPointers[j];
399 int localLength = vec_->MyLength();
401 return ArrayRCP<double>(data, 0, localLength,
false);
408 double ** arrayOfPointers;
410 vec_->ExtractView(&arrayOfPointers);
412 double * data = arrayOfPointers[j];
413 int localLength = vec_->MyLength();
415 return ArrayRCP<double>(data, 0, localLength,
false);
428 vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
441 void scale (Teuchos::ArrayView< const Scalar > alpha) {
446 for (
size_t j = 0; j < numVecs; ++j) {
447 Epetra_Vector *v = (*vec_)(j);
456 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(
"EpetraMultiVectorT::update"); vec_->Update(alpha, toEpetra<GlobalOrdinal,Node>(A), beta, toEpetra<GlobalOrdinal,Node>(B), gamma); }
459 void norm1(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::norm1"); vec_->Norm1(norms.getRawPtr()); }
462 void norm2(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::norm2"); vec_->Norm2(norms.getRawPtr()); }
465 void normInf(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::normInf"); vec_->NormInf(norms.getRawPtr()); }
468 void meanValue(
const Teuchos::ArrayView< Scalar > &means)
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::meanValue"); vec_->MeanValue(means.getRawPtr()); }
471 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(
"EpetraMultiVectorT::multiply"); vec_->Multiply(
toEpetra(transA),
toEpetra(transB), alpha,
toEpetra(A),
toEpetra(B), beta); }
474 void elementWiseMultiply(
Scalar scalarAB,
const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A,
const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B,
Scalar scalarThis) {
XPETRA_MONITOR(
"EpetraMultiVectorT::elementWiseMultiply"); vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal,Node>(A), toEpetra<GlobalOrdinal,Node>(B), scalarThis); }
493 auto vv = toEpetra<GlobalOrdinal,Node>(vec);
494 return ( (vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
506 TEUCHOS_UNREACHABLE_RETURN(
"TODO");
510 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel =Teuchos::Describable::verbLevel_default)
const {
521 if (bUseXpetraImplementation)
531 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getMap()
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::getMap");
return toXpetra<GlobalOrdinal,Node>(vec_->Map()); }
540 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
542 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra is " << err);
552 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
554 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
564 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
566 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
576 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
578 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
585 if (!map.is_null()) {
590 Epetra_SerialComm SComm;
594 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
612 Teuchos::ScalarTraits< Scalar >::seedrandom(seed);
616 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR 622 typename dual_view_type::t_dev_const_um getDeviceLocalView(Access::ReadOnlyStruct)
const override {
return getDeviceLocalView(
Access::ReadWrite);}
624 typename dual_view_type::t_host_um getHostLocalView (Access::OverwriteAllStruct)
const override {
return getHostLocalView(
Access::ReadWrite);}
626 typename dual_view_type::t_dev_um getDeviceLocalView(Access::OverwriteAllStruct)
const override {
return getDeviceLocalView(
Access::ReadWrite);}
628 typename dual_view_type::t_host_um getHostLocalView (Access::ReadWriteStruct)
const override {
629 typedef Kokkos::View<
typename dual_view_type::t_host::data_type ,
631 typename dual_view_type::t_host::device_type ,
632 Kokkos::MemoryUnmanaged> epetra_view_type;
637 vec_->ExtractView(&data, &myLDA);
638 int localLength = vec_->MyLength();
642 epetra_view_type test = epetra_view_type(data, localLength, numVectors);
643 typename dual_view_type::t_host_um ret = subview(test, Kokkos::ALL(), Kokkos::ALL());
648 typename dual_view_type::t_dev_um getDeviceLocalView(Access::ReadWriteStruct)
const override {
649 throw std::runtime_error(
"Epetra does not support device views! in "+std::string(__FILE__)+
":"+std::to_string(__LINE__));
650 #ifndef __NVCC__ //prevent nvcc warning 651 typename dual_view_type::t_dev_um ret;
653 TEUCHOS_UNREACHABLE_RETURN(ret);
666 const this_type* rhsPtr =
dynamic_cast<const this_type*
> (&rhs);
667 TEUCHOS_TEST_FOR_EXCEPTION(
668 rhsPtr == NULL, std::invalid_argument,
"Xpetra::MultiVector::operator=: " 669 "The left-hand side (LHS) of the assignment has a different type than " 670 "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT " 671 "(which means it wraps an Epetra_MultiVector), but the RHS has some " 672 "other type. This probably means that the RHS wraps a Tpetra::Multi" 673 "Vector. Xpetra::MultiVector does not currently implement assignment " 674 "from a Tpetra object to an Epetra object, though this could be added " 675 "with sufficient interest.");
677 RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector ();
680 TEUCHOS_TEST_FOR_EXCEPTION(
681 rhsImpl.is_null (), std::logic_error,
"Xpetra::MultiVector::operator= " 682 "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of " 683 "the assignment) has a null RCP<Epetra_MultiVector> inside. Please " 684 "report this bug to the Xpetra developers.");
685 TEUCHOS_TEST_FOR_EXCEPTION(
686 lhsImpl.is_null (), std::logic_error,
"Xpetra::MultiVector::operator= " 687 "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the " 688 "assignment has a null RCP<Epetra_MultiVector> inside. Please report " 689 "this bug to the Xpetra developers.");
697 RCP< Epetra_MultiVector >
vec_;
703 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES 706 :
public virtual MultiVector<double, int, long long, EpetraNode>
720 : vec_(Teuchos::rcp(new Epetra_MultiVector(
toEpetra<
GlobalOrdinal,
Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) { }
730 const std::string tfecfFuncName(
"MultiVector(ArrayOfPtrs)");
731 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
732 ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
734 #ifdef HAVE_XPETRA_DEBUG 737 size_t localLength = map->getNodeNumElements();
738 for(
int j=0; j<ArrayOfPtrs.size(); j++) {
739 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
740 ": ArrayOfPtrs[" << j <<
"].size() (== " << ArrayOfPtrs[j].size() <<
741 ") is not equal to getLocalLength() (== " << localLength);
748 Array<const double*> arrayOfRawPtrs(ArrayOfPtrs.size());
749 for(
int i=0; i<ArrayOfPtrs.size(); i++) {
750 arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
752 double** rawArrayOfRawPtrs =
const_cast<double**
>(arrayOfRawPtrs.getRawPtr());
754 vec_ = Teuchos::rcp(
new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal,Node>(map), rawArrayOfRawPtrs, NumVectors));
786 Teuchos::RCP< const Vector< double, int, long long, EpetraNode > >
getVector(
size_t j)
const;
789 Teuchos::RCP< Vector< double, int, long long, EpetraNode > >
getVectorNonConst(
size_t j);
792 Teuchos::ArrayRCP< const Scalar >
getData(
size_t j)
const {
795 double ** arrayOfPointers;
797 vec_->ExtractView(&arrayOfPointers);
799 double * data = arrayOfPointers[j];
800 int localLength = vec_->MyLength();
802 return ArrayRCP<double>(data, 0, localLength,
false);
809 double ** arrayOfPointers;
811 vec_->ExtractView(&arrayOfPointers);
813 double * data = arrayOfPointers[j];
814 int localLength = vec_->MyLength();
816 return ArrayRCP<double>(data, 0, localLength,
false);
829 vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
842 void scale (Teuchos::ArrayView< const Scalar > alpha) {
847 for (
size_t j = 0; j < numVecs; ++j) {
848 Epetra_Vector *v = (*vec_)(j);
857 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(
"EpetraMultiVectorT::update"); vec_->Update(alpha, toEpetra<GlobalOrdinal,Node>(A), beta, toEpetra<GlobalOrdinal,Node>(B), gamma); }
860 void norm1(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::norm1"); vec_->Norm1(norms.getRawPtr()); }
863 void norm2(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::norm2"); vec_->Norm2(norms.getRawPtr()); }
866 void normInf(
const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms)
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::normInf"); vec_->NormInf(norms.getRawPtr()); }
869 void meanValue(
const Teuchos::ArrayView< Scalar > &means)
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::meanValue"); vec_->MeanValue(means.getRawPtr()); }
872 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(
"EpetraMultiVectorT::multiply"); vec_->Multiply(
toEpetra(transA),
toEpetra(transB), alpha,
toEpetra(A),
toEpetra(B), beta); }
875 void elementWiseMultiply(
Scalar scalarAB,
const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A,
const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B,
Scalar scalarThis) {
XPETRA_MONITOR(
"EpetraMultiVectorT::elementWiseMultiply"); vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal,Node>(A), toEpetra<GlobalOrdinal,Node>(B), scalarThis); }
894 auto vv = toEpetra<GlobalOrdinal,Node>(vec);
895 return ( (vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
911 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel =Teuchos::Describable::verbLevel_default)
const {
922 if (bUseXpetraImplementation)
932 Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > >
getMap()
const {
XPETRA_MONITOR(
"EpetraMultiVectorT::getMap");
return toXpetra<GlobalOrdinal,Node>(vec_->Map()); }
941 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
943 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra is " << err);
953 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
955 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
965 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
967 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
977 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
979 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
986 if (!map.is_null()) {
991 Epetra_SerialComm SComm;
995 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1013 Teuchos::ScalarTraits< Scalar >::seedrandom(seed);
1014 vec_->SetSeed(seed);
1025 const this_type* rhsPtr =
dynamic_cast<const this_type*
> (&rhs);
1026 TEUCHOS_TEST_FOR_EXCEPTION(
1027 rhsPtr == NULL, std::invalid_argument,
"Xpetra::MultiVector::operator=: " 1028 "The left-hand side (LHS) of the assignment has a different type than " 1029 "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT " 1030 "(which means it wraps an Epetra_MultiVector), but the RHS has some " 1031 "other type. This probably means that the RHS wraps a Tpetra::Multi" 1032 "Vector. Xpetra::MultiVector does not currently implement assignment " 1033 "from a Tpetra object to an Epetra object, though this could be added " 1034 "with sufficient interest.");
1036 RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector ();
1039 TEUCHOS_TEST_FOR_EXCEPTION(
1040 rhsImpl.is_null (), std::logic_error,
"Xpetra::MultiVector::operator= " 1041 "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of " 1042 "the assignment) has a null RCP<Epetra_MultiVector> inside. Please " 1043 "report this bug to the Xpetra developers.");
1044 TEUCHOS_TEST_FOR_EXCEPTION(
1045 lhsImpl.is_null (), std::logic_error,
"Xpetra::MultiVector::operator= " 1046 "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the " 1047 "assignment has a null RCP<Epetra_MultiVector> inside. Please report " 1048 "this bug to the Xpetra developers.");
1051 *lhsImpl = *rhsImpl;
1065 #endif // XPETRA_EPETRAMULTIVECTOR_HPP 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: this = gamma*this + alpha*A + beta*B.
EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &ArrayOfPtrs, size_t NumVectors)
Set multi-vector values from array of pointers using Teuchos memory management classes. (copy).
virtual void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
Get the underlying Epetra multivector.
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: this = gamma*this + alpha*A + beta*B.
EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &ArrayOfPtrs, size_t NumVectors)
Set multi-vector values from array of pointers using Teuchos memory management classes. (copy).
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: this = gamma*this + alpha*A + beta*B.
size_t getNumVectors() const
Number of columns in the multivector.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
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 in place: this = alpha*this.
void scale(const Scalar &alpha)
Scale in place: this = alpha*this.
void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute the dot product of each corresponding pair of vectors (columns) in A and B.
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
virtual ~EpetraMultiVectorT()
MultiVector destructor.
void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
virtual void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
void randomize(bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
RCP< Epetra_MultiVector > vec_
The Epetra_MultiVector which this class wraps.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
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...
size_t getLocalLength() const
Local number of rows on the calling process.
virtual void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Basic MultiVector constuctor.
EpetraMultiVectorT(const RCP< Epetra_MultiVector > &vec)
EpetraMultiVectorT constructor to wrap a Epetra_MultiVector object.
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
Checks to see if the local length, number of vectors and size of Scalar type match.
void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute the dot product of each corresponding pair of vectors (columns) in A and B.
void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute the dot product of each corresponding pair of vectors (columns) in A and B.
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.
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Basic MultiVector constuctor.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
void scale(Teuchos::ArrayView< const Scalar > alpha)
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
void randomize(bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
Get the underlying Epetra multivector.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis)
Multiply a Vector A elementwise by a MultiVector B.
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).
size_t getNumVectors() const
Number of columns in the multivector.
void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
void replaceMap(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Replace the underlying Map in place.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
EpetraMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source)
MultiVector copy constructor.
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
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.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis)
Multiply a Vector A elementwise by a MultiVector B.
EpetraGlobalOrdinal GlobalOrdinal
std::string description() const
A simple one-line description of this object.
EpetraMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::DataAccess copyOrView=Teuchos::Copy)
MultiVector copy constructor.
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
Get the underlying Epetra multivector.
void setSeed(unsigned int seed)
Set seed for Random function.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
size_t getLocalLength() const
Local number of rows on the calling process.
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 abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
std::string description() const
A simple one-line description of this object.
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
Checks to see if the local length, number of vectors and size of Scalar type match.
void randomize(bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
EpetraMultiVectorT(const RCP< Epetra_MultiVector > &vec)
EpetraMultiVectorT constructor to wrap a Epetra_MultiVector object.
virtual ~EpetraMultiVectorT()
MultiVector destructor.
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &ArrayOfPtrs, size_t NumVectors)
Set multi-vector values from array of pointers using Teuchos memory management classes. (copy).
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Basic MultiVector constuctor.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
void replaceMap(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Replace the underlying Map in place.
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 normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
Exception throws when you call an unimplemented method of Xpetra.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
size_t global_size_t
Global size_t object.
void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
size_t getNumVectors() const
Number of columns in the multivector.
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (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.
void setSeed(unsigned int seed)
Set seed for Random function.
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).
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
void scale(Teuchos::ArrayView< const Scalar > alpha)
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
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).
EpetraMultiVectorT(const RCP< Epetra_MultiVector > &vec)
EpetraMultiVectorT constructor to wrap a Epetra_MultiVector object.
void putScalar(const Scalar &value)
Set all values in the multivector with the given value.
void scale(Teuchos::ArrayView< const Scalar > alpha)
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
EpetraMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::DataAccess copyOrView=Teuchos::Copy)
MultiVector copy constructor.
void setSeed(unsigned int seed)
Set seed for Random function.
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
void scale(const Scalar &alpha)
Scale in place: this = alpha*this.
void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
RCP< Epetra_MultiVector > vec_
The Epetra_MultiVector which this class wraps.
virtual ~EpetraMultiVectorT()
MultiVector destructor.
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
size_t getLocalLength() const
Local number of rows on the calling process.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
Teuchos::RCP< const Vector< double, int, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
void replaceMap(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Replace the underlying Map in place.
CombineMode
Xpetra::Combine Mode enumerable type.
constexpr struct ReadWriteStruct ReadWrite
#define XPETRA_MONITOR(funcName)
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis)
Multiply a Vector A elementwise by a MultiVector B.
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).
std::string description() const
A simple one-line description of this object.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
virtual size_t getNumVectors() const =0
Number of columns in the multivector.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
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).
Teuchos::RCP< Vector< double, int, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.