Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_EpetraMultiVector.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Xpetra: A linear algebra interface package
4 //
5 // Copyright 2012 NTESS and the Xpetra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef XPETRA_EPETRAMULTIVECTOR_HPP
11 #define XPETRA_EPETRAMULTIVECTOR_HPP
12 
13 /* this file is automatically generated - do not edit (see script/epetra.py) */
14 
15 #include <Kokkos_Core.hpp>
16 #include <Kokkos_DualView.hpp>
17 
19 
20 #include "Xpetra_MultiVector.hpp"
21 #include "Xpetra_Vector.hpp"
22 
23 #include "Xpetra_EpetraMap.hpp"
24 #include "Xpetra_EpetraExport.hpp"
25 #include "Xpetra_Utils.hpp"
26 #include "Xpetra_EpetraUtils.hpp"
27 #include "Xpetra_EpetraImport.hpp"
28 #include "Xpetra_Exceptions.hpp"
29 #include "Epetra_SerialComm.h"
30 
31 #include <Epetra_MultiVector.h>
32 #include <Epetra_Vector.h>
33 
34 #if defined(XPETRA_ENABLE_DEPRECATED_CODE)
35 #ifdef __GNUC__
36 #if defined(Xpetra_SHOW_DEPRECATED_WARNINGS)
37 #warning "The header file Trilinos/packages/xpetra/src/MultiVector/Xpetra_EpetraMultiVector.hpp is deprecated."
38 #endif
39 #endif
40 #else
41 #error "The header file Trilinos/packages/xpetra/src/MultiVector/Xpetra_EpetraMultiVector.hpp is deprecated."
42 #endif
43 
44 namespace Xpetra {
45 
46 // TODO: move that elsewhere
47 template <class GlobalOrdinal, class Node>
48 XPETRA_DEPRECATED const Epetra_MultiVector &toEpetra(const MultiVector<double, int, GlobalOrdinal, Node> &);
49 template <class GlobalOrdinal, class Node>
50 XPETRA_DEPRECATED Epetra_MultiVector &toEpetra(MultiVector<double, int, GlobalOrdinal, Node> &);
51 template <class GlobalOrdinal, class Node>
52 XPETRA_DEPRECATED RCP<MultiVector<double, int, GlobalOrdinal, Node> > toXpetra(RCP<Epetra_MultiVector> vec);
53 
54 // we need this forward declaration
55 #ifndef DOXYGEN_SHOULD_SKIP_THIS
56 template <class GlobalOrdinal, class Node>
57 class EpetraVectorT;
58 #endif
59 
60 template <class EpetraGlobalOrdinal, class Node>
61 class XPETRA_DEPRECATED EpetraMultiVectorT
62  : public virtual MultiVector<double, int, EpetraGlobalOrdinal, Node> {
63  typedef double Scalar;
64  typedef int LocalOrdinal;
65  typedef EpetraGlobalOrdinal GlobalOrdinal;
66 
67  public:
69 
70 
72  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut = true) {
73  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
74  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
75  }
76 
78  EpetraMultiVectorT(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Teuchos::DataAccess copyOrView = Teuchos::Copy) {
79  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
80  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
81  }
82 
84  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &ArrayOfPtrs, size_t NumVectors) {
85  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
86  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
87  }
88 
90  virtual ~EpetraMultiVectorT() {}
91 
93 
95 
96 
98  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {}
99 
101  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {}
102 
104  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {}
105 
107  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {}
108 
110  void putScalar(const Scalar &value) {}
111 
113 
115 
116 
118  Teuchos::RCP<const Vector<double, int, GlobalOrdinal, Node> > getVector(size_t j) const {
119  return Teuchos::null;
120  }
121 
123  Teuchos::RCP<Vector<double, int, GlobalOrdinal, Node> > getVectorNonConst(size_t j) {
124  return Teuchos::null;
125  }
126 
128  Teuchos::ArrayRCP<const Scalar> getData(size_t j) const {
129  return ArrayRCP<const Scalar>();
130  }
131 
133  Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j) {
134  return ArrayRCP<Scalar>();
135  }
136 
138 
140 
141 
143  void dot(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {}
144 
147 
150 
152  void scale(const Scalar &alpha) {}
153 
155  void scale(Teuchos::ArrayView<const Scalar> alpha) {}
156 
158  void update(const Scalar &alpha, const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Scalar &beta) {}
159 
162 
164  void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {}
165 
167  void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {}
168 
170  void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {}
171 
173  void meanValue(const Teuchos::ArrayView<Scalar> &means) const {}
174 
176  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) {}
177 
180 
182 
184 
185 
187  size_t getNumVectors() const { return 0; }
188 
190  size_t getLocalLength() const { return 0; }
191 
193  global_size_t getGlobalLength() const { return 0; }
194 
195  // \brief Checks to see if the local length, number of vectors and size of Scalar type match
197 
199 
201 
202 
204  std::string description() const { return std::string(""); }
205 
207  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {}
208 
210 
212  void randomize(bool bUseXpetraImplementation = false) {}
213 
215  void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation = false) {}
216 
218  //{@
219 
221  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const { return Teuchos::null; }
222 
225 
228 
231 
234 
236  void replaceMap(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {}
237 
239 
241 
242 
244  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec) { // TODO removed const
245  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
246  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
247  }
248 
250  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return Teuchos::null; }
251 
253  void setSeed(unsigned int seed) {}
254 
256 
257  protected:
260  virtual void
262 
263 }; // EpetraMultiVectorT class
264 
265 // specialization on GO=int and Node=EpetraNode
266 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
267 template <>
269  : public virtual MultiVector<double, int, int, EpetraNode> {
270  typedef double Scalar;
271  typedef int LocalOrdinal;
272  typedef int GlobalOrdinal;
273  typedef EpetraNode Node;
274 
275  public:
277 
278 
280  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut = true)
281  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) {}
282 
284  EpetraMultiVectorT(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Teuchos::DataAccess copyOrView = Teuchos::Copy) {
285  if (copyOrView == Teuchos::Copy)
286  vec_ = Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(source)));
287  else {
288  int *indices = new int[source.getNumVectors()];
289  for (size_t i = 0; i < source.getNumVectors(); i++)
290  indices[i] = i;
291  vec_ = Teuchos::rcp(new Epetra_MultiVector(View, toEpetra<GlobalOrdinal, Node>(source), indices, source.getNumVectors()));
292  delete[] indices;
293  }
294  }
295 
297  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &ArrayOfPtrs, size_t NumVectors) {
298  // TODO: input argument 'NumVectors' is not necessary in both Xpetra and Tpetra interface. Should it be removed?
299 
300  const std::string tfecfFuncName("MultiVector(ArrayOfPtrs)");
301  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
302  ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
303 
304 #ifdef HAVE_XPETRA_DEBUG
305  // This cannot be tested by Epetra itself
306  {
307  size_t localLength = map->getLocalNumElements();
308  for (int j = 0; j < ArrayOfPtrs.size(); j++) {
309  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
310  ": ArrayOfPtrs[" << j << "].size() (== " << ArrayOfPtrs[j].size() << ") is not equal to getLocalLength() (== " << localLength);
311  }
312  }
313 #endif
314 
315  // Convert Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > to double**
316  Array<const double *> arrayOfRawPtrs(ArrayOfPtrs.size());
317  for (int i = 0; i < ArrayOfPtrs.size(); i++) {
318  arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
319  }
320  double **rawArrayOfRawPtrs = const_cast<double **>(arrayOfRawPtrs.getRawPtr()); // This const_cast should be fine, because Epetra_DataAccess=Copy.
321 
322  vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal, Node>(map), rawArrayOfRawPtrs, static_cast<int>(NumVectors)));
323  }
324 
326  virtual ~EpetraMultiVectorT() {}
327 
329 
331 
332 
334  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
335  XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue");
336  vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
337  }
338 
340  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
341  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue");
342  vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
343  }
344 
346  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
347  XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue");
348  vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
349  }
350 
352  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
353  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue");
354  vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
355  }
356 
358  void putScalar(const Scalar &value) {
359  XPETRA_MONITOR("EpetraMultiVectorT::putScalar");
360  vec_->PutScalar(value);
361  }
362 
364 
366 
367 
369  Teuchos::RCP<const Vector<double, int, int, EpetraNode> > getVector(size_t j) const;
370 
372  Teuchos::RCP<Vector<double, int, int, EpetraNode> > getVectorNonConst(size_t j);
373 
375  Teuchos::ArrayRCP<const Scalar> getData(size_t j) const {
376  XPETRA_MONITOR("EpetraMultiVectorT::getData");
377 
378  double **arrayOfPointers;
379 
380  vec_->ExtractView(&arrayOfPointers);
381 
382  double *data = arrayOfPointers[j];
383  int localLength = vec_->MyLength();
384 
385  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
386  }
387 
389  Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j) {
390  XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
391 
392  double **arrayOfPointers;
393 
394  vec_->ExtractView(&arrayOfPointers);
395 
396  double *data = arrayOfPointers[j];
397  int localLength = vec_->MyLength();
398 
399  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
400  }
401 
403 
405 
406 
408  void dot(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {
409  XPETRA_MONITOR("EpetraMultiVectorT::dot");
410 
411  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
412  vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
413  }
414 
417  XPETRA_MONITOR("EpetraMultiVectorT::abs");
418  vec_->Abs(toEpetra<GlobalOrdinal, Node>(A));
419  }
420 
423  XPETRA_MONITOR("EpetraMultiVectorT::reciprocal");
424  vec_->Reciprocal(toEpetra<GlobalOrdinal, Node>(A));
425  }
426 
428  void scale(const Scalar &alpha) {
429  XPETRA_MONITOR("EpetraMultiVectorT::scale");
430  vec_->Scale(alpha);
431  }
432 
434  void scale(Teuchos::ArrayView<const Scalar> alpha) {
435  XPETRA_MONITOR("EpetraMultiVectorT::scale");
436  // Epetra, unlike Tpetra, doesn't implement this version of
437  // scale(). Deal with this by scaling one column at a time.
438  const size_t numVecs = this->getNumVectors();
439  for (size_t j = 0; j < numVecs; ++j) {
440  Epetra_Vector *v = (*vec_)(j);
441  v->Scale(alpha[j]);
442  }
443  }
444 
447  XPETRA_MONITOR("EpetraMultiVectorT::update");
448  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta);
449  }
450 
453  XPETRA_MONITOR("EpetraMultiVectorT::update");
454  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta, toEpetra<GlobalOrdinal, Node>(B), gamma);
455  }
456 
458  void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
459  XPETRA_MONITOR("EpetraMultiVectorT::norm1");
460  vec_->Norm1(norms.getRawPtr());
461  }
462 
464  void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
465  XPETRA_MONITOR("EpetraMultiVectorT::norm2");
466  vec_->Norm2(norms.getRawPtr());
467  }
468 
470  void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
471  XPETRA_MONITOR("EpetraMultiVectorT::normInf");
472  vec_->NormInf(norms.getRawPtr());
473  }
474 
476  void meanValue(const Teuchos::ArrayView<Scalar> &means) const {
477  XPETRA_MONITOR("EpetraMultiVectorT::meanValue");
478  vec_->MeanValue(means.getRawPtr());
479  } // TODO: modify ArrayView size ??
480 
482  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) {
483  XPETRA_MONITOR("EpetraMultiVectorT::multiply");
484  vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta);
485  }
486 
489  XPETRA_MONITOR("EpetraMultiVectorT::elementWiseMultiply");
490  vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal, Node>(A), toEpetra<GlobalOrdinal, Node>(B), scalarThis);
491  }
492 
494 
496 
497 
499  size_t getNumVectors() const {
500  XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors");
501  return vec_->NumVectors();
502  }
503 
505  size_t getLocalLength() const {
506  XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength");
507  return vec_->MyLength();
508  }
509 
512  XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength");
513  return vec_->GlobalLength64();
514  }
515 
518  XPETRA_MONITOR("EpetraMultiVectorT::isSameSize");
519  auto vv = toEpetra<GlobalOrdinal, Node>(vec);
520  return ((vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
521  }
522 
524 
526 
527 
529  std::string description() const {
530  XPETRA_MONITOR("EpetraMultiVectorT::description");
531  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO");
532  TEUCHOS_UNREACHABLE_RETURN("TODO");
533  }
534 
536  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel /* verbLevel */ = Teuchos::Describable::verbLevel_default) const {
537  XPETRA_MONITOR("EpetraMultiVectorT::describe");
538  vec_->Print(out);
539  }
540 
542 
544  void randomize(bool bUseXpetraImplementation = false) {
545  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
546 
547  if (bUseXpetraImplementation)
549  else
550  vec_->Random();
551  }
552 
554  void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation = false) {
555  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
556 
557  if (bUseXpetraImplementation)
559  else {
560  vec_->Random();
561  const size_t numVectors = getNumVectors();
562  for (size_t i = 0; i < numVectors; i++) {
563  Teuchos::ArrayRCP<Scalar> datai = getDataNonConst(i);
564 
565  const size_t myLength = getLocalLength();
566  for (size_t j = 0; j < myLength; j++) {
567  datai[j] = 0.5 * (maxVal - minVal) * datai[j] + 0.5 * (maxVal + minVal);
568  }
569  }
570  }
571  }
572 
574  //{@
575 
577  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const {
578  XPETRA_MONITOR("EpetraMultiVectorT::getMap");
579  return toXpetra<GlobalOrdinal, Node>(vec_->Map());
580  }
581 
584  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
585 
586  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
587  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
588 
589  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
590  int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
591  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra is " << err);
592  }
593 
596  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
597 
598  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
599  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
600 
601  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
602  int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
603  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
604  }
605 
608  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
609 
610  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
611  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
612 
613  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
614  int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
615  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
616  }
617 
620  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
621 
622  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
623  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
624 
625  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
626  int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
627  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
628  }
629 
631  void replaceMap(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
632  XPETRA_MONITOR("EpetraMultiVectorT::replaceMap");
633  int err = 0;
634  if (!map.is_null()) {
635  err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra<GlobalOrdinal, Node>(map));
636 
637  } else {
638  // Replace map with a dummy map to avoid potential hangs later
639  Epetra_SerialComm SComm;
640  Epetra_Map NewMap((GlobalOrdinal)vec_->MyLength(), (GlobalOrdinal)vec_->Map().IndexBase64(), SComm);
641  err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
642  }
643  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
644  }
645 
647 
649 
650 
652  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec)
653  : vec_(vec) {} // TODO removed const
654 
656  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return vec_; }
657 
659  void setSeed(unsigned int seed) {
660  XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
661 
662  Teuchos::ScalarTraits<Scalar>::seedrandom(seed);
663  vec_->SetSeed(seed);
664  }
665 
667 
668  typename dual_view_type::t_host_const_um getHostLocalView(Access::ReadOnlyStruct) const override { return getHostLocalView(Access::ReadWrite); }
669 
670  typename dual_view_type::t_dev_const_um getDeviceLocalView(Access::ReadOnlyStruct) const override { return getDeviceLocalView(Access::ReadWrite); }
671 
672  typename dual_view_type::t_host_um getHostLocalView(Access::OverwriteAllStruct) const override { return getHostLocalView(Access::ReadWrite); }
673 
674  typename dual_view_type::t_dev_um getDeviceLocalView(Access::OverwriteAllStruct) const override { return getDeviceLocalView(Access::ReadWrite); }
675 
676  typename dual_view_type::t_host_um getHostLocalView(Access::ReadWriteStruct) const override {
677  typedef Kokkos::View<typename dual_view_type::t_host::data_type,
678  Kokkos::LayoutLeft,
679  typename dual_view_type::t_host::device_type,
680  Kokkos::MemoryUnmanaged>
681  epetra_view_type;
682 
683  // access Epetra multivector data
684  double *data = NULL;
685  int myLDA;
686  vec_->ExtractView(&data, &myLDA);
687  int localLength = vec_->MyLength();
688  int numVectors = getNumVectors();
689 
690  // create view
691  epetra_view_type test = epetra_view_type(data, localLength, numVectors);
692  typename dual_view_type::t_host_um ret = subview(test, Kokkos::ALL(), Kokkos::ALL());
693 
694  return ret;
695  }
696 
697  typename dual_view_type::t_dev_um getDeviceLocalView(Access::ReadWriteStruct) const override { return getHostLocalView(Access::ReadWrite); }
698 
700 
701  protected:
704  virtual void
706  typedef EpetraMultiVectorT this_type;
707  const this_type *rhsPtr = dynamic_cast<const this_type *>(&rhs);
708  TEUCHOS_TEST_FOR_EXCEPTION(
709  rhsPtr == NULL, std::invalid_argument,
710  "Xpetra::MultiVector::operator=: "
711  "The left-hand side (LHS) of the assignment has a different type than "
712  "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
713  "(which means it wraps an Epetra_MultiVector), but the RHS has some "
714  "other type. This probably means that the RHS wraps a Tpetra::Multi"
715  "Vector. Xpetra::MultiVector does not currently implement assignment "
716  "from a Tpetra object to an Epetra object, though this could be added "
717  "with sufficient interest.");
718 
719  RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector();
720  RCP<Epetra_MultiVector> lhsImpl = this->getEpetra_MultiVector();
721 
722  TEUCHOS_TEST_FOR_EXCEPTION(
723  rhsImpl.is_null(), std::logic_error,
724  "Xpetra::MultiVector::operator= "
725  "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
726  "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
727  "report this bug to the Xpetra developers.");
728  TEUCHOS_TEST_FOR_EXCEPTION(
729  lhsImpl.is_null(), std::logic_error,
730  "Xpetra::MultiVector::operator= "
731  "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
732  "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
733  "this bug to the Xpetra developers.");
734 
735  // Epetra_MultiVector's assignment operator does a deep copy.
736  *lhsImpl = *rhsImpl;
737  }
738 
739  private:
741  RCP<Epetra_MultiVector> vec_;
742 
743 }; // EpetraMultiVectorT class (specialization on GO=int, NO=EpetraNode
744 #endif
745 
746 // specialization on GO=long long and EpetraNode
747 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
748 template <>
750  : public virtual MultiVector<double, int, long long, EpetraNode> {
751  typedef double Scalar;
752  typedef int LocalOrdinal;
753  typedef long long GlobalOrdinal;
754  typedef EpetraNode Node;
755 
756  public:
758 
759 
761  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut = true)
762  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) {}
763 
766  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(source)))) {}
767 
769  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &ArrayOfPtrs, size_t NumVectors) {
770  // TODO: input argument 'NumVectors' is not necessary in both Xpetra and Tpetra interface. Should it be removed?
771 
772  const std::string tfecfFuncName("MultiVector(ArrayOfPtrs)");
773  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
774  ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
775 
776 #ifdef HAVE_XPETRA_DEBUG
777  // This cannot be tested by Epetra itself
778  {
779  size_t localLength = map->getLocalNumElements();
780  for (int j = 0; j < ArrayOfPtrs.size(); j++) {
781  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
782  ": ArrayOfPtrs[" << j << "].size() (== " << ArrayOfPtrs[j].size() << ") is not equal to getLocalLength() (== " << localLength);
783  }
784  }
785 #endif
786 
787  // Convert Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > to double**
788  Array<const double *> arrayOfRawPtrs(ArrayOfPtrs.size());
789  for (int i = 0; i < ArrayOfPtrs.size(); i++) {
790  arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
791  }
792  double **rawArrayOfRawPtrs = const_cast<double **>(arrayOfRawPtrs.getRawPtr()); // This const_cast should be fine, because Epetra_DataAccess=Copy.
793 
794  vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal, Node>(map), rawArrayOfRawPtrs, NumVectors));
795  }
796 
798  virtual ~EpetraMultiVectorT() {}
799 
801 
803 
804 
806  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
807  XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue");
808  vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
809  }
810 
812  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
813  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue");
814  vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
815  }
816 
818  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
819  XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue");
820  vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
821  }
822 
824  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
825  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue");
826  vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
827  }
828 
830  void putScalar(const Scalar &value) {
831  XPETRA_MONITOR("EpetraMultiVectorT::putScalar");
832  vec_->PutScalar(value);
833  }
834 
836 
838 
839 
841  Teuchos::RCP<const Vector<double, int, long long, EpetraNode> > getVector(size_t j) const;
842 
844  Teuchos::RCP<Vector<double, int, long long, EpetraNode> > getVectorNonConst(size_t j);
845 
847  Teuchos::ArrayRCP<const Scalar> getData(size_t j) const {
848  XPETRA_MONITOR("EpetraMultiVectorT::getData");
849 
850  double **arrayOfPointers;
851 
852  vec_->ExtractView(&arrayOfPointers);
853 
854  double *data = arrayOfPointers[j];
855  int localLength = vec_->MyLength();
856 
857  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
858  }
859 
861  Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j) {
862  XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
863 
864  double **arrayOfPointers;
865 
866  vec_->ExtractView(&arrayOfPointers);
867 
868  double *data = arrayOfPointers[j];
869  int localLength = vec_->MyLength();
870 
871  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
872  }
873 
875 
877 
878 
880  void dot(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {
881  XPETRA_MONITOR("EpetraMultiVectorT::dot");
882 
883  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
884  vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
885  }
886 
889  XPETRA_MONITOR("EpetraMultiVectorT::abs");
890  vec_->Abs(toEpetra<GlobalOrdinal, Node>(A));
891  }
892 
895  XPETRA_MONITOR("EpetraMultiVectorT::reciprocal");
896  vec_->Reciprocal(toEpetra<GlobalOrdinal, Node>(A));
897  }
898 
900  void scale(const Scalar &alpha) {
901  XPETRA_MONITOR("EpetraMultiVectorT::scale");
902  vec_->Scale(alpha);
903  }
904 
906  void scale(Teuchos::ArrayView<const Scalar> alpha) {
907  XPETRA_MONITOR("EpetraMultiVectorT::scale");
908  // Epetra, unlike Tpetra, doesn't implement this version of
909  // scale(). Deal with this by scaling one column at a time.
910  const size_t numVecs = this->getNumVectors();
911  for (size_t j = 0; j < numVecs; ++j) {
912  Epetra_Vector *v = (*vec_)(j);
913  v->Scale(alpha[j]);
914  }
915  }
916 
919  XPETRA_MONITOR("EpetraMultiVectorT::update");
920  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta);
921  }
922 
925  XPETRA_MONITOR("EpetraMultiVectorT::update");
926  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta, toEpetra<GlobalOrdinal, Node>(B), gamma);
927  }
928 
930  void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
931  XPETRA_MONITOR("EpetraMultiVectorT::norm1");
932  vec_->Norm1(norms.getRawPtr());
933  }
934 
936  void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
937  XPETRA_MONITOR("EpetraMultiVectorT::norm2");
938  vec_->Norm2(norms.getRawPtr());
939  }
940 
942  void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
943  XPETRA_MONITOR("EpetraMultiVectorT::normInf");
944  vec_->NormInf(norms.getRawPtr());
945  }
946 
948  void meanValue(const Teuchos::ArrayView<Scalar> &means) const {
949  XPETRA_MONITOR("EpetraMultiVectorT::meanValue");
950  vec_->MeanValue(means.getRawPtr());
951  } // TODO: modify ArrayView size ??
952 
954  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) {
955  XPETRA_MONITOR("EpetraMultiVectorT::multiply");
956  vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta);
957  }
958 
961  XPETRA_MONITOR("EpetraMultiVectorT::elementWiseMultiply");
962  vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal, Node>(A), toEpetra<GlobalOrdinal, Node>(B), scalarThis);
963  }
964 
966 
968 
969 
971  size_t getNumVectors() const {
972  XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors");
973  return vec_->NumVectors();
974  }
975 
977  size_t getLocalLength() const {
978  XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength");
979  return vec_->MyLength();
980  }
981 
984  XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength");
985  return vec_->GlobalLength64();
986  }
987 
990  XPETRA_MONITOR("EpetraMultiVectorT::isSameSize");
991  auto vv = toEpetra<GlobalOrdinal, Node>(vec);
992  return ((vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
993  }
994 
996 
998 
999 
1001  std::string description() const {
1002  XPETRA_MONITOR("EpetraMultiVectorT::description");
1003  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "TODO");
1004  // return "TODO"; // unreachable
1005  }
1006 
1008  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel /* verbLevel */ = Teuchos::Describable::verbLevel_default) const {
1009  XPETRA_MONITOR("EpetraMultiVectorT::describe");
1010  vec_->Print(out);
1011  }
1012 
1014 
1016  void randomize(bool bUseXpetraImplementation = false) {
1017  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
1018 
1019  if (bUseXpetraImplementation)
1021  else
1022  vec_->Random();
1023  }
1024 
1026  void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation = false) {
1027  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
1028 
1029  if (bUseXpetraImplementation)
1031  else {
1032  vec_->Random();
1033  const size_t numVectors = getNumVectors();
1034  for (size_t i = 0; i < numVectors; i++) {
1035  Teuchos::ArrayRCP<Scalar> datai = getDataNonConst(i);
1036 
1037  const size_t myLength = getLocalLength();
1038  for (size_t j = 0; j < myLength; j++) {
1039  datai[j] = 0.5 * (maxVal - minVal) * datai[j] + 0.5 * (maxVal + minVal);
1040  }
1041  }
1042  }
1043  }
1044 
1046  //{@
1047 
1049  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const {
1050  XPETRA_MONITOR("EpetraMultiVectorT::getMap");
1051  return toXpetra<GlobalOrdinal, Node>(vec_->Map());
1052  }
1053 
1056  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
1057 
1058  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1059  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1060 
1061  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
1062  int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1063  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra is " << err);
1064  }
1065 
1068  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
1069 
1070  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1071  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1072 
1073  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
1074  int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1075  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1076  }
1077 
1080  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
1081 
1082  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1083  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1084 
1085  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
1086  int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1087  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1088  }
1089 
1092  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
1093 
1094  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1095  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1096 
1097  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
1098  int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1099  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1100  }
1101 
1103  void replaceMap(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
1104  XPETRA_MONITOR("EpetraMultiVectorT::replaceMap");
1105  int err = 0;
1106  if (!map.is_null()) {
1107  err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra<GlobalOrdinal, Node>(map));
1108 
1109  } else {
1110  // Replace map with a dummy map to avoid potential hangs later
1111  Epetra_SerialComm SComm;
1112  Epetra_Map NewMap((GlobalOrdinal)vec_->MyLength(), (GlobalOrdinal)vec_->Map().IndexBase64(), SComm);
1113  err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
1114  }
1115  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1116  }
1117 
1119 
1121 
1122 
1124  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec)
1125  : vec_(vec) {} // TODO removed const
1126 
1128  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return vec_; }
1129 
1131  void setSeed(unsigned int seed) {
1132  XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
1133 
1134  Teuchos::ScalarTraits<Scalar>::seedrandom(seed);
1135  vec_->SetSeed(seed);
1136  }
1137 
1139 
1140  protected:
1143  virtual void
1145  typedef EpetraMultiVectorT this_type;
1146  const this_type *rhsPtr = dynamic_cast<const this_type *>(&rhs);
1147  TEUCHOS_TEST_FOR_EXCEPTION(
1148  rhsPtr == NULL, std::invalid_argument,
1149  "Xpetra::MultiVector::operator=: "
1150  "The left-hand side (LHS) of the assignment has a different type than "
1151  "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
1152  "(which means it wraps an Epetra_MultiVector), but the RHS has some "
1153  "other type. This probably means that the RHS wraps a Tpetra::Multi"
1154  "Vector. Xpetra::MultiVector does not currently implement assignment "
1155  "from a Tpetra object to an Epetra object, though this could be added "
1156  "with sufficient interest.");
1157 
1158  RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector();
1159  RCP<Epetra_MultiVector> lhsImpl = this->getEpetra_MultiVector();
1160 
1161  TEUCHOS_TEST_FOR_EXCEPTION(
1162  rhsImpl.is_null(), std::logic_error,
1163  "Xpetra::MultiVector::operator= "
1164  "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
1165  "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
1166  "report this bug to the Xpetra developers.");
1167  TEUCHOS_TEST_FOR_EXCEPTION(
1168  lhsImpl.is_null(), std::logic_error,
1169  "Xpetra::MultiVector::operator= "
1170  "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
1171  "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
1172  "this bug to the Xpetra developers.");
1173 
1174  // Epetra_MultiVector's assignment operator does a deep copy.
1175  *lhsImpl = *rhsImpl;
1176  }
1177 
1178  private:
1180  RCP<Epetra_MultiVector> vec_;
1181 
1182 }; // EpetraMultiVectorT class (specialization on GO=long long, NO=EpetraNode
1183 #endif
1184 
1185 } // namespace Xpetra
1186 
1187 #include "Xpetra_EpetraVector.hpp" // to avoid incomplete type instantiated above in out-of-body functions.
1188 
1189 #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.
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.
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.
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