46 #ifndef XPETRA_EPETRAMULTIVECTOR_HPP
47 #define XPETRA_EPETRAMULTIVECTOR_HPP
51 #include <Kokkos_Core.hpp>
52 #include <Kokkos_DualView.hpp>
56 #include "Xpetra_MultiVector.hpp"
65 #include "Epetra_SerialComm.h"
67 #include <Epetra_MultiVector.h>
68 #include <Epetra_Vector.h>
70 #if defined(XPETRA_ENABLE_DEPRECATED_CODE)
72 #warning "The header file Trilinos/packages/xpetra/src/MultiVector/Xpetra_EpetraMultiVector.hpp is deprecated."
75 #error "The header file Trilinos/packages/xpetra/src/MultiVector/Xpetra_EpetraMultiVector.hpp is deprecated."
81 template <
class GlobalOrdinal,
class Node>
82 XPETRA_DEPRECATED
const Epetra_MultiVector &
toEpetra(
const MultiVector<double, int, GlobalOrdinal, Node> &);
83 template <
class GlobalOrdinal,
class Node>
84 XPETRA_DEPRECATED Epetra_MultiVector &
toEpetra(MultiVector<double, int, GlobalOrdinal, Node> &);
85 template <
class GlobalOrdinal,
class Node>
86 XPETRA_DEPRECATED RCP<MultiVector<double, int, GlobalOrdinal, Node> >
toXpetra(RCP<Epetra_MultiVector> vec);
89 #ifndef DOXYGEN_SHOULD_SKIP_THIS
90 template <
class GlobalOrdinal,
class Node>
94 template <
class EpetraGlobalOrdinal,
class Node>
96 :
public virtual MultiVector<double, int, EpetraGlobalOrdinal, Node> {
108 "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
114 "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
120 "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
152 Teuchos::RCP<const Vector<double, int, GlobalOrdinal, Node> >
getVector(
size_t j)
const {
153 return Teuchos::null;
158 return Teuchos::null;
162 Teuchos::ArrayRCP<const Scalar>
getData(
size_t j)
const {
163 return ArrayRCP<const Scalar>();
168 return ArrayRCP<Scalar>();
189 void scale(Teuchos::ArrayView<const Scalar> alpha) {}
195 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) {}
198 void norm1(
const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const {}
201 void norm2(
const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const {}
204 void normInf(
const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const {}
207 void meanValue(
const Teuchos::ArrayView<Scalar> &means)
const {}
210 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) {}
241 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default)
const {}
246 void randomize(
bool bUseXpetraImplementation =
false) {}
255 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getMap()
const {
return Teuchos::null; }
280 "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
300 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
303 :
public virtual MultiVector<double, int, int, EpetraNode> {
315 : vec_(Teuchos::rcp(new Epetra_MultiVector(
toEpetra<
GlobalOrdinal,
Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) {}
319 if (copyOrView == Teuchos::Copy)
320 vec_ = Teuchos::rcp(
new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(source)));
325 vec_ = Teuchos::rcp(
new Epetra_MultiVector(View, toEpetra<GlobalOrdinal, Node>(source), indices, source.
getNumVectors()));
334 const std::string tfecfFuncName(
"MultiVector(ArrayOfPtrs)");
335 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
336 ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
338 #ifdef HAVE_XPETRA_DEBUG
341 size_t localLength = map->getLocalNumElements();
342 for (
int j = 0; j < ArrayOfPtrs.size(); j++) {
343 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
344 ": ArrayOfPtrs[" << j <<
"].size() (== " << ArrayOfPtrs[j].size() <<
") is not equal to getLocalLength() (== " << localLength);
350 Array<const double *> arrayOfRawPtrs(ArrayOfPtrs.size());
351 for (
int i = 0; i < ArrayOfPtrs.size(); i++) {
352 arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
354 double **rawArrayOfRawPtrs =
const_cast<double **
>(arrayOfRawPtrs.getRawPtr());
356 vec_ = Teuchos::rcp(
new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal, Node>(map), rawArrayOfRawPtrs, static_cast<int>(NumVectors)));
370 vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
376 vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
382 vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
388 vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
394 vec_->PutScalar(value);
403 Teuchos::RCP<const Vector<double, int, int, EpetraNode> >
getVector(
size_t j)
const;
409 Teuchos::ArrayRCP<const Scalar>
getData(
size_t j)
const {
412 double **arrayOfPointers;
414 vec_->ExtractView(&arrayOfPointers);
416 double *data = arrayOfPointers[j];
417 int localLength = vec_->MyLength();
419 return ArrayRCP<double>(data, 0, localLength,
false);
426 double **arrayOfPointers;
428 vec_->ExtractView(&arrayOfPointers);
430 double *data = arrayOfPointers[j];
431 int localLength = vec_->MyLength();
433 return ArrayRCP<double>(data, 0, localLength,
false);
446 vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
452 vec_->Abs(toEpetra<GlobalOrdinal, Node>(A));
458 vec_->Reciprocal(toEpetra<GlobalOrdinal, Node>(A));
468 void scale(Teuchos::ArrayView<const Scalar> alpha) {
473 for (
size_t j = 0; j < numVecs; ++j) {
474 Epetra_Vector *v = (*vec_)(j);
482 vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta);
486 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) {
488 vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta, toEpetra<GlobalOrdinal, Node>(B), gamma);
492 void norm1(
const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const {
494 vec_->Norm1(norms.getRawPtr());
498 void norm2(
const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const {
500 vec_->Norm2(norms.getRawPtr());
504 void normInf(
const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const {
506 vec_->NormInf(norms.getRawPtr());
510 void meanValue(
const Teuchos::ArrayView<Scalar> &means)
const {
512 vec_->MeanValue(means.getRawPtr());
516 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) {
524 vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal, Node>(A), toEpetra<GlobalOrdinal, Node>(B), scalarThis);
535 return vec_->NumVectors();
541 return vec_->MyLength();
547 return vec_->GlobalLength64();
553 auto vv = toEpetra<GlobalOrdinal, Node>(vec);
554 return ((vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
566 TEUCHOS_UNREACHABLE_RETURN(
"TODO");
570 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel = Teuchos::Describable::verbLevel_default)
const {
581 if (bUseXpetraImplementation)
591 if (bUseXpetraImplementation)
596 for (
size_t i = 0; i < numVectors; i++) {
600 for (
size_t j = 0; j < myLength; j++) {
601 datai[j] = 0.5 * (maxVal - minVal) * datai[j] + 0.5 * (maxVal + minVal);
611 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getMap()
const {
613 return toXpetra<GlobalOrdinal, Node>(vec_->Map());
623 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
625 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra is " << err);
635 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
637 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
647 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
649 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
659 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
661 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
668 if (!map.is_null()) {
673 Epetra_SerialComm SComm;
677 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
696 Teuchos::ScalarTraits<Scalar>::seedrandom(seed);
711 typedef Kokkos::View<
typename dual_view_type::t_host::data_type,
713 typename dual_view_type::t_host::device_type,
714 Kokkos::MemoryUnmanaged>
720 vec_->ExtractView(&data, &myLDA);
721 int localLength = vec_->MyLength();
725 epetra_view_type test = epetra_view_type(data, localLength, numVectors);
726 typename dual_view_type::t_host_um ret = subview(test, Kokkos::ALL(), Kokkos::ALL());
741 const this_type *rhsPtr =
dynamic_cast<const this_type *
>(&rhs);
742 TEUCHOS_TEST_FOR_EXCEPTION(
743 rhsPtr == NULL, std::invalid_argument,
744 "Xpetra::MultiVector::operator=: "
745 "The left-hand side (LHS) of the assignment has a different type than "
746 "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
747 "(which means it wraps an Epetra_MultiVector), but the RHS has some "
748 "other type. This probably means that the RHS wraps a Tpetra::Multi"
749 "Vector. Xpetra::MultiVector does not currently implement assignment "
750 "from a Tpetra object to an Epetra object, though this could be added "
751 "with sufficient interest.");
753 RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector();
756 TEUCHOS_TEST_FOR_EXCEPTION(
757 rhsImpl.is_null(), std::logic_error,
758 "Xpetra::MultiVector::operator= "
759 "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
760 "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
761 "report this bug to the Xpetra developers.");
762 TEUCHOS_TEST_FOR_EXCEPTION(
763 lhsImpl.is_null(), std::logic_error,
764 "Xpetra::MultiVector::operator= "
765 "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
766 "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
767 "this bug to the Xpetra developers.");
781 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
784 :
public virtual MultiVector<double, int, long long, EpetraNode> {
796 : vec_(Teuchos::rcp(new Epetra_MultiVector(
toEpetra<
GlobalOrdinal,
Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) {}
806 const std::string tfecfFuncName(
"MultiVector(ArrayOfPtrs)");
807 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
808 ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
810 #ifdef HAVE_XPETRA_DEBUG
813 size_t localLength = map->getLocalNumElements();
814 for (
int j = 0; j < ArrayOfPtrs.size(); j++) {
815 TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
816 ": ArrayOfPtrs[" << j <<
"].size() (== " << ArrayOfPtrs[j].size() <<
") is not equal to getLocalLength() (== " << localLength);
822 Array<const double *> arrayOfRawPtrs(ArrayOfPtrs.size());
823 for (
int i = 0; i < ArrayOfPtrs.size(); i++) {
824 arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
826 double **rawArrayOfRawPtrs =
const_cast<double **
>(arrayOfRawPtrs.getRawPtr());
828 vec_ = Teuchos::rcp(
new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal, Node>(map), rawArrayOfRawPtrs, NumVectors));
842 vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
848 vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
854 vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
860 vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
866 vec_->PutScalar(value);
875 Teuchos::RCP<const Vector<double, int, long long, EpetraNode> >
getVector(
size_t j)
const;
878 Teuchos::RCP<Vector<double, int, long long, EpetraNode> >
getVectorNonConst(
size_t j);
881 Teuchos::ArrayRCP<const Scalar>
getData(
size_t j)
const {
884 double **arrayOfPointers;
886 vec_->ExtractView(&arrayOfPointers);
888 double *data = arrayOfPointers[j];
889 int localLength = vec_->MyLength();
891 return ArrayRCP<double>(data, 0, localLength,
false);
898 double **arrayOfPointers;
900 vec_->ExtractView(&arrayOfPointers);
902 double *data = arrayOfPointers[j];
903 int localLength = vec_->MyLength();
905 return ArrayRCP<double>(data, 0, localLength,
false);
918 vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
924 vec_->Abs(toEpetra<GlobalOrdinal, Node>(A));
930 vec_->Reciprocal(toEpetra<GlobalOrdinal, Node>(A));
940 void scale(Teuchos::ArrayView<const Scalar> alpha) {
945 for (
size_t j = 0; j < numVecs; ++j) {
946 Epetra_Vector *v = (*vec_)(j);
954 vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta);
958 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) {
960 vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta, toEpetra<GlobalOrdinal, Node>(B), gamma);
964 void norm1(
const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const {
966 vec_->Norm1(norms.getRawPtr());
970 void norm2(
const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const {
972 vec_->Norm2(norms.getRawPtr());
976 void normInf(
const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms)
const {
978 vec_->NormInf(norms.getRawPtr());
982 void meanValue(
const Teuchos::ArrayView<Scalar> &means)
const {
984 vec_->MeanValue(means.getRawPtr());
988 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) {
996 vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal, Node>(A), toEpetra<GlobalOrdinal, Node>(B), scalarThis);
1007 return vec_->NumVectors();
1013 return vec_->MyLength();
1019 return vec_->GlobalLength64();
1025 auto vv = toEpetra<GlobalOrdinal, Node>(vec);
1026 return ((vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
1042 void describe(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel = Teuchos::Describable::verbLevel_default)
const {
1053 if (bUseXpetraImplementation)
1063 if (bUseXpetraImplementation)
1068 for (
size_t i = 0; i < numVectors; i++) {
1072 for (
size_t j = 0; j < myLength; j++) {
1073 datai[j] = 0.5 * (maxVal - minVal) * datai[j] + 0.5 * (maxVal + minVal);
1083 Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> >
getMap()
const {
1085 return toXpetra<GlobalOrdinal, Node>(vec_->Map());
1095 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
1097 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra is " << err);
1107 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
1109 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1119 RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
1121 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1131 RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
1133 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1140 if (!map.is_null()) {
1145 Epetra_SerialComm SComm;
1149 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error,
"Catch error code returned by Epetra.");
1168 Teuchos::ScalarTraits<Scalar>::seedrandom(seed);
1169 vec_->SetSeed(seed);
1180 const this_type *rhsPtr =
dynamic_cast<const this_type *
>(&rhs);
1181 TEUCHOS_TEST_FOR_EXCEPTION(
1182 rhsPtr == NULL, std::invalid_argument,
1183 "Xpetra::MultiVector::operator=: "
1184 "The left-hand side (LHS) of the assignment has a different type than "
1185 "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
1186 "(which means it wraps an Epetra_MultiVector), but the RHS has some "
1187 "other type. This probably means that the RHS wraps a Tpetra::Multi"
1188 "Vector. Xpetra::MultiVector does not currently implement assignment "
1189 "from a Tpetra object to an Epetra object, though this could be added "
1190 "with sufficient interest.");
1192 RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector();
1195 TEUCHOS_TEST_FOR_EXCEPTION(
1196 rhsImpl.is_null(), std::logic_error,
1197 "Xpetra::MultiVector::operator= "
1198 "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
1199 "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
1200 "report this bug to the Xpetra developers.");
1201 TEUCHOS_TEST_FOR_EXCEPTION(
1202 lhsImpl.is_null(), std::logic_error,
1203 "Xpetra::MultiVector::operator= "
1204 "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
1205 "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
1206 "this bug to the Xpetra developers.");
1209 *lhsImpl = *rhsImpl;
1223 #endif // XPETRA_EPETRAMULTIVECTOR_HPP
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.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this 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.
dual_view_type::t_dev_um getDeviceLocalView(Access::ReadWriteStruct) const override
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).
size_t getNumVectors() const
Number of columns in the multivector.
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.
dual_view_type::t_dev_um getDeviceLocalView(Access::OverwriteAllStruct) const override
std::string description() const
A simple one-line description of this object.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
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, 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.
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 update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
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.
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
size_t getLocalLength() const
Local number of rows on the calling process.
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...
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.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
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 doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export (using an Importer).
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.
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.
EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Basic MultiVector constuctor.
Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::dual_view_type dual_view_type
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const 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 describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
void scale(Teuchos::ArrayView< const Scalar > alpha)
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
Get the underlying Epetra multivector.
void randomize(bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
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 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.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
size_t getLocalLength() const
Local number of rows on the calling process.
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 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.
RCP< Epetra_MultiVector > vec_
The Epetra_MultiVector which this class wraps.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
dual_view_type::t_dev_const_um getDeviceLocalView(Access::ReadOnlyStruct) const override
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
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
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
Get the underlying Epetra multivector.
global_size_t getGlobalLength() const
Global number of rows in the multivector.
EpetraMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::DataAccess copyOrView=Teuchos::Copy)
MultiVector copy constructor.
void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
RCP< Epetra_MultiVector > vec_
The Epetra_MultiVector which this class wraps.
void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
std::string description() const
A simple one-line description of this object.
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.
size_t getNumVectors() const
Number of columns in the multivector.
void setSeed(unsigned int seed)
Set seed for Random function.
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
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.
dual_view_type::t_host_um getHostLocalView(Access::OverwriteAllStruct) const override
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 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 doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< LocalOrdinal, GlobalOrdinal, Node > &exporter, CombineMode CM)
Import (using an Exporter).
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 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).
global_size_t getGlobalLength() const
Global number of rows in the multivector.
Exception throws when you call an unimplemented method of Xpetra.
#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).
dual_view_type::t_host_um getHostLocalView(Access::ReadWriteStruct) const override
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.
size_t getLocalLength() const
Local number of rows on the calling process.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutStride, typename node_type::device_type, Kokkos::MemoryUnmanaged > dual_view_type
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
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 sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
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).
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
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 normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
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 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 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.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
virtual ~EpetraMultiVectorT()
MultiVector destructor.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
bool isSameSize(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &vec) const
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 replaceMap(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Replace the underlying Map in place.
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
Get the underlying Epetra multivector.
CombineMode
Xpetra::Combine Mode enumerable type.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
constexpr struct ReadWriteStruct ReadWrite
#define XPETRA_MONITOR(funcName)
void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
virtual dual_view_type::t_host_const_um getHostLocalView(Access::ReadOnlyStruct) const
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).
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 randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
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.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
Teuchos::RCP< Vector< double, int, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
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 norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
dual_view_type::t_host_const_um getHostLocalView(Access::ReadOnlyStruct) const override