00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef XPETRA_EPETRAMULTIVECTOR_HPP
00047 #define XPETRA_EPETRAMULTIVECTOR_HPP
00048
00049
00050
00051 #include "Xpetra_EpetraConfigDefs.hpp"
00052
00053 #include "Xpetra_MultiVector.hpp"
00054 #include "Xpetra_Vector.hpp"
00055
00056 #include "Xpetra_EpetraMap.hpp"
00057 #include "Xpetra_EpetraExport.hpp"
00058 #include "Xpetra_Utils.hpp"
00059 #include "Xpetra_EpetraUtils.hpp"
00060
00061 #include <Epetra_MultiVector.h>
00062
00063 namespace Xpetra {
00064
00065
00066 const Epetra_MultiVector & toEpetra(const MultiVector<double,int,int> &);
00067
00068 Epetra_MultiVector & toEpetra(MultiVector<double, int,int> &);
00069
00070
00071
00072
00073
00074
00075
00076 class EpetraMultiVector
00077 : public virtual MultiVector<double, int, int>
00078 {
00079
00080 typedef double Scalar;
00081 typedef int LocalOrdinal;
00082 typedef int GlobalOrdinal;
00083 typedef Kokkos::DefaultNode::DefaultNodeType Node;
00084
00085 public:
00086
00088
00089
00091 EpetraMultiVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
00092 : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra(map), NumVectors, zeroOut))) { }
00093
00095 EpetraMultiVector(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source)
00096 : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra(source)))) { }
00097
00099 EpetraMultiVector(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &ArrayOfPtrs, size_t NumVectors);
00100
00102 virtual ~EpetraMultiVector() { }
00103
00105
00107
00108
00110 void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVector::replaceGlobalValue"); vec_->ReplaceGlobalValue(globalRow, vectorIndex, value); }
00111
00113 void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVector::sumIntoGlobalValue"); vec_->SumIntoGlobalValue(globalRow, vectorIndex, value); }
00114
00116 void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVector::replaceLocalValue"); vec_->ReplaceMyValue(myRow, vectorIndex, value); }
00117
00119 void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVector::sumIntoLocalValue"); vec_->SumIntoMyValue(myRow, vectorIndex, value); }
00120
00122 void putScalar(const Scalar &value) { XPETRA_MONITOR("EpetraMultiVector::putScalar"); vec_->PutScalar(value); }
00123
00125
00127
00128
00130 Teuchos::ArrayRCP< const Scalar > getData(size_t j) const;
00131
00133 Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j);
00134
00136
00138
00139
00141 void dot(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const;
00142
00144 void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVector::abs"); vec_->Abs(toEpetra(A)); }
00145
00147 void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVector::reciprocal"); vec_->Reciprocal(toEpetra(A)); }
00148
00150 void scale(const Scalar &alpha) { XPETRA_MONITOR("EpetraMultiVector::scale"); vec_->Scale(alpha); }
00151
00153 void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta) { XPETRA_MONITOR("EpetraMultiVector::update"); vec_->Update(alpha, toEpetra(A), beta); }
00154
00156 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); }
00157
00159 void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const;
00160
00162 void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const;
00163
00165 void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const;
00166
00168 void normWeighted(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights, const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const;
00169
00171 void meanValue(const Teuchos::ArrayView< Scalar > &means) const;
00172
00174 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); }
00175
00177 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); }
00178
00180
00182
00183
00185 size_t getNumVectors() const { XPETRA_MONITOR("EpetraMultiVector::getNumVectors"); return vec_->NumVectors(); }
00186
00188 size_t getLocalLength() const { XPETRA_MONITOR("EpetraMultiVector::getLocalLength"); return vec_->MyLength(); }
00189
00191 global_size_t getGlobalLength() const { XPETRA_MONITOR("EpetraMultiVector::getGlobalLength"); return vec_->GlobalLength(); }
00192
00194
00196
00197
00199 std::string description() const;
00200
00202 void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const;
00203
00205
00207 void randomize(bool bUseXpetraImplementation = false) {
00208 XPETRA_MONITOR("EpetraMultiVector::randomize");
00209
00210 if(bUseXpetraImplementation)
00211 Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::Xpetra_randomize();
00212 else
00213 vec_->Random();
00214 }
00215
00217
00218
00220 const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const { XPETRA_MONITOR("EpetraMultiVector::getMap"); return toXpetra(vec_->Map()); }
00221
00223 void doImport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM);
00224
00226 void doExport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> &dest, const Import< LocalOrdinal, GlobalOrdinal, Node >& importer, CombineMode CM);
00227
00229 void doImport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM);
00230
00232 void doExport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node> &dest, const Export< LocalOrdinal, GlobalOrdinal, Node >& exporter, CombineMode CM);
00233
00235
00237
00238
00240 EpetraMultiVector(const RCP<Epetra_MultiVector> &vec) : vec_(vec) { }
00241
00243 RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return vec_; }
00244
00246 void setSeed(unsigned int seed) {
00247 XPETRA_MONITOR("EpetraMultiVector::seedrandom");
00248
00249 Teuchos::ScalarTraits< Scalar >::seedrandom(seed);
00250 vec_->SetSeed(seed);
00251 }
00252
00254
00255 private:
00256
00257 RCP< Epetra_MultiVector > vec_;
00258
00259 };
00260
00261 }
00262
00263 #endif // XPETRA_EPETRAMULTIVECTOR_HPP