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 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_EPETRAMULTIVECTOR_HPP
47 #define XPETRA_EPETRAMULTIVECTOR_HPP
48 
49 /* this file is automatically generated - do not edit (see script/epetra.py) */
50 
51 #include <Kokkos_Core.hpp>
52 #include <Kokkos_DualView.hpp>
53 
55 
56 #include "Xpetra_MultiVector.hpp"
57 #include "Xpetra_Vector.hpp"
58 
59 #include "Xpetra_EpetraMap.hpp"
60 #include "Xpetra_EpetraExport.hpp"
61 #include "Xpetra_Utils.hpp"
62 #include "Xpetra_EpetraUtils.hpp"
63 #include "Xpetra_EpetraImport.hpp"
64 #include "Xpetra_Exceptions.hpp"
65 #include "Epetra_SerialComm.h"
66 
67 #include <Epetra_MultiVector.h>
68 #include <Epetra_Vector.h>
69 
70 #if defined(XPETRA_ENABLE_DEPRECATED_CODE)
71 #ifdef __GNUC__
72 #warning "The header file Trilinos/packages/xpetra/src/MultiVector/Xpetra_EpetraMultiVector.hpp is deprecated."
73 #endif
74 #else
75 #error "The header file Trilinos/packages/xpetra/src/MultiVector/Xpetra_EpetraMultiVector.hpp is deprecated."
76 #endif
77 
78 namespace Xpetra {
79 
80 // TODO: move that elsewhere
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);
87 
88 // we need this forward declaration
89 #ifndef DOXYGEN_SHOULD_SKIP_THIS
90 template <class GlobalOrdinal, class Node>
91 class EpetraVectorT;
92 #endif
93 
94 template <class EpetraGlobalOrdinal, class Node>
95 class XPETRA_DEPRECATED EpetraMultiVectorT
96  : public virtual MultiVector<double, int, EpetraGlobalOrdinal, Node> {
97  typedef double Scalar;
98  typedef int LocalOrdinal;
99  typedef EpetraGlobalOrdinal GlobalOrdinal;
100 
101  public:
103 
104 
106  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut = true) {
107  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
108  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
109  }
110 
112  EpetraMultiVectorT(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Teuchos::DataAccess copyOrView = Teuchos::Copy) {
113  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
114  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
115  }
116 
118  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &ArrayOfPtrs, size_t NumVectors) {
119  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
120  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
121  }
122 
124  virtual ~EpetraMultiVectorT() {}
125 
127 
129 
130 
132  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {}
133 
135  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {}
136 
138  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {}
139 
141  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {}
142 
144  void putScalar(const Scalar &value) {}
145 
147 
149 
150 
152  Teuchos::RCP<const Vector<double, int, GlobalOrdinal, Node> > getVector(size_t j) const {
153  return Teuchos::null;
154  }
155 
157  Teuchos::RCP<Vector<double, int, GlobalOrdinal, Node> > getVectorNonConst(size_t j) {
158  return Teuchos::null;
159  }
160 
162  Teuchos::ArrayRCP<const Scalar> getData(size_t j) const {
163  return ArrayRCP<const Scalar>();
164  }
165 
167  Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j) {
168  return ArrayRCP<Scalar>();
169  }
170 
172 
174 
175 
177  void dot(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {}
178 
181 
184 
186  void scale(const Scalar &alpha) {}
187 
189  void scale(Teuchos::ArrayView<const Scalar> alpha) {}
190 
192  void update(const Scalar &alpha, const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Scalar &beta) {}
193 
196 
198  void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {}
199 
201  void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {}
202 
204  void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {}
205 
207  void meanValue(const Teuchos::ArrayView<Scalar> &means) const {}
208 
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) {}
211 
214 
216 
218 
219 
221  size_t getNumVectors() const { return 0; }
222 
224  size_t getLocalLength() const { return 0; }
225 
227  global_size_t getGlobalLength() const { return 0; }
228 
229  // \brief Checks to see if the local length, number of vectors and size of Scalar type match
231 
233 
235 
236 
238  std::string description() const { return std::string(""); }
239 
241  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {}
242 
244 
246  void randomize(bool bUseXpetraImplementation = false) {}
247 
249  void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation = false) {}
250 
252  //{@
253 
255  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const { return Teuchos::null; }
256 
259 
262 
265 
268 
270  void replaceMap(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {}
271 
273 
275 
276 
278  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec) { // TODO removed const
279  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
280  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
281  }
282 
284  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return Teuchos::null; }
285 
287  void setSeed(unsigned int seed) {}
288 
290 
291  protected:
294  virtual void
296 
297 }; // EpetraMultiVectorT class
298 
299 // specialization on GO=int and Node=EpetraNode
300 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
301 template <>
303  : public virtual MultiVector<double, int, int, EpetraNode> {
304  typedef double Scalar;
305  typedef int LocalOrdinal;
306  typedef int GlobalOrdinal;
307  typedef EpetraNode Node;
308 
309  public:
311 
312 
314  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut = true)
315  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) {}
316 
318  EpetraMultiVectorT(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Teuchos::DataAccess copyOrView = Teuchos::Copy) {
319  if (copyOrView == Teuchos::Copy)
320  vec_ = Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(source)));
321  else {
322  int *indices = new int[source.getNumVectors()];
323  for (size_t i = 0; i < source.getNumVectors(); i++)
324  indices[i] = i;
325  vec_ = Teuchos::rcp(new Epetra_MultiVector(View, toEpetra<GlobalOrdinal, Node>(source), indices, source.getNumVectors()));
326  delete[] indices;
327  }
328  }
329 
331  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &ArrayOfPtrs, size_t NumVectors) {
332  // TODO: input argument 'NumVectors' is not necessary in both Xpetra and Tpetra interface. Should it be removed?
333 
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.");
337 
338 #ifdef HAVE_XPETRA_DEBUG
339  // This cannot be tested by Epetra itself
340  {
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);
345  }
346  }
347 #endif
348 
349  // Convert Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > to double**
350  Array<const double *> arrayOfRawPtrs(ArrayOfPtrs.size());
351  for (int i = 0; i < ArrayOfPtrs.size(); i++) {
352  arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
353  }
354  double **rawArrayOfRawPtrs = const_cast<double **>(arrayOfRawPtrs.getRawPtr()); // This const_cast should be fine, because Epetra_DataAccess=Copy.
355 
356  vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal, Node>(map), rawArrayOfRawPtrs, static_cast<int>(NumVectors)));
357  }
358 
360  virtual ~EpetraMultiVectorT() {}
361 
363 
365 
366 
368  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
369  XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue");
370  vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
371  }
372 
374  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
375  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue");
376  vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
377  }
378 
380  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
381  XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue");
382  vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
383  }
384 
386  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
387  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue");
388  vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
389  }
390 
392  void putScalar(const Scalar &value) {
393  XPETRA_MONITOR("EpetraMultiVectorT::putScalar");
394  vec_->PutScalar(value);
395  }
396 
398 
400 
401 
403  Teuchos::RCP<const Vector<double, int, int, EpetraNode> > getVector(size_t j) const;
404 
406  Teuchos::RCP<Vector<double, int, int, EpetraNode> > getVectorNonConst(size_t j);
407 
409  Teuchos::ArrayRCP<const Scalar> getData(size_t j) const {
410  XPETRA_MONITOR("EpetraMultiVectorT::getData");
411 
412  double **arrayOfPointers;
413 
414  vec_->ExtractView(&arrayOfPointers);
415 
416  double *data = arrayOfPointers[j];
417  int localLength = vec_->MyLength();
418 
419  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
420  }
421 
423  Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j) {
424  XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
425 
426  double **arrayOfPointers;
427 
428  vec_->ExtractView(&arrayOfPointers);
429 
430  double *data = arrayOfPointers[j];
431  int localLength = vec_->MyLength();
432 
433  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
434  }
435 
437 
439 
440 
442  void dot(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {
443  XPETRA_MONITOR("EpetraMultiVectorT::dot");
444 
445  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
446  vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
447  }
448 
451  XPETRA_MONITOR("EpetraMultiVectorT::abs");
452  vec_->Abs(toEpetra<GlobalOrdinal, Node>(A));
453  }
454 
457  XPETRA_MONITOR("EpetraMultiVectorT::reciprocal");
458  vec_->Reciprocal(toEpetra<GlobalOrdinal, Node>(A));
459  }
460 
462  void scale(const Scalar &alpha) {
463  XPETRA_MONITOR("EpetraMultiVectorT::scale");
464  vec_->Scale(alpha);
465  }
466 
468  void scale(Teuchos::ArrayView<const Scalar> alpha) {
469  XPETRA_MONITOR("EpetraMultiVectorT::scale");
470  // Epetra, unlike Tpetra, doesn't implement this version of
471  // scale(). Deal with this by scaling one column at a time.
472  const size_t numVecs = this->getNumVectors();
473  for (size_t j = 0; j < numVecs; ++j) {
474  Epetra_Vector *v = (*vec_)(j);
475  v->Scale(alpha[j]);
476  }
477  }
478 
481  XPETRA_MONITOR("EpetraMultiVectorT::update");
482  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta);
483  }
484 
487  XPETRA_MONITOR("EpetraMultiVectorT::update");
488  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta, toEpetra<GlobalOrdinal, Node>(B), gamma);
489  }
490 
492  void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
493  XPETRA_MONITOR("EpetraMultiVectorT::norm1");
494  vec_->Norm1(norms.getRawPtr());
495  }
496 
498  void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
499  XPETRA_MONITOR("EpetraMultiVectorT::norm2");
500  vec_->Norm2(norms.getRawPtr());
501  }
502 
504  void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
505  XPETRA_MONITOR("EpetraMultiVectorT::normInf");
506  vec_->NormInf(norms.getRawPtr());
507  }
508 
510  void meanValue(const Teuchos::ArrayView<Scalar> &means) const {
511  XPETRA_MONITOR("EpetraMultiVectorT::meanValue");
512  vec_->MeanValue(means.getRawPtr());
513  } // TODO: modify ArrayView size ??
514 
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) {
517  XPETRA_MONITOR("EpetraMultiVectorT::multiply");
518  vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta);
519  }
520 
523  XPETRA_MONITOR("EpetraMultiVectorT::elementWiseMultiply");
524  vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal, Node>(A), toEpetra<GlobalOrdinal, Node>(B), scalarThis);
525  }
526 
528 
530 
531 
533  size_t getNumVectors() const {
534  XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors");
535  return vec_->NumVectors();
536  }
537 
539  size_t getLocalLength() const {
540  XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength");
541  return vec_->MyLength();
542  }
543 
546  XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength");
547  return vec_->GlobalLength64();
548  }
549 
552  XPETRA_MONITOR("EpetraMultiVectorT::isSameSize");
553  auto vv = toEpetra<GlobalOrdinal, Node>(vec);
554  return ((vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
555  }
556 
558 
560 
561 
563  std::string description() const {
564  XPETRA_MONITOR("EpetraMultiVectorT::description");
565  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO");
566  TEUCHOS_UNREACHABLE_RETURN("TODO");
567  }
568 
570  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel /* verbLevel */ = Teuchos::Describable::verbLevel_default) const {
571  XPETRA_MONITOR("EpetraMultiVectorT::describe");
572  vec_->Print(out);
573  }
574 
576 
578  void randomize(bool bUseXpetraImplementation = false) {
579  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
580 
581  if (bUseXpetraImplementation)
583  else
584  vec_->Random();
585  }
586 
588  void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation = false) {
589  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
590 
591  if (bUseXpetraImplementation)
593  else {
594  vec_->Random();
595  const size_t numVectors = getNumVectors();
596  for (size_t i = 0; i < numVectors; i++) {
597  Teuchos::ArrayRCP<Scalar> datai = getDataNonConst(i);
598 
599  const size_t myLength = getLocalLength();
600  for (size_t j = 0; j < myLength; j++) {
601  datai[j] = 0.5 * (maxVal - minVal) * datai[j] + 0.5 * (maxVal + minVal);
602  }
603  }
604  }
605  }
606 
608  //{@
609 
611  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const {
612  XPETRA_MONITOR("EpetraMultiVectorT::getMap");
613  return toXpetra<GlobalOrdinal, Node>(vec_->Map());
614  }
615 
618  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
619 
620  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
621  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
622 
623  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
624  int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
625  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra is " << err);
626  }
627 
630  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
631 
632  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
633  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
634 
635  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
636  int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
637  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
638  }
639 
642  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
643 
644  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
645  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
646 
647  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
648  int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
649  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
650  }
651 
654  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
655 
656  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
657  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
658 
659  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
660  int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
661  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
662  }
663 
665  void replaceMap(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
666  XPETRA_MONITOR("EpetraMultiVectorT::replaceMap");
667  int err = 0;
668  if (!map.is_null()) {
669  err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra<GlobalOrdinal, Node>(map));
670 
671  } else {
672  // Replace map with a dummy map to avoid potential hangs later
673  Epetra_SerialComm SComm;
674  Epetra_Map NewMap((GlobalOrdinal)vec_->MyLength(), (GlobalOrdinal)vec_->Map().IndexBase64(), SComm);
675  err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
676  }
677  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
678  }
679 
681 
683 
684 
686  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec)
687  : vec_(vec) {} // TODO removed const
688 
690  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return vec_; }
691 
693  void setSeed(unsigned int seed) {
694  XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
695 
696  Teuchos::ScalarTraits<Scalar>::seedrandom(seed);
697  vec_->SetSeed(seed);
698  }
699 
701 
702  typename dual_view_type::t_host_const_um getHostLocalView(Access::ReadOnlyStruct) const override { return getHostLocalView(Access::ReadWrite); }
703 
704  typename dual_view_type::t_dev_const_um getDeviceLocalView(Access::ReadOnlyStruct) const override { return getDeviceLocalView(Access::ReadWrite); }
705 
706  typename dual_view_type::t_host_um getHostLocalView(Access::OverwriteAllStruct) const override { return getHostLocalView(Access::ReadWrite); }
707 
708  typename dual_view_type::t_dev_um getDeviceLocalView(Access::OverwriteAllStruct) const override { return getDeviceLocalView(Access::ReadWrite); }
709 
710  typename dual_view_type::t_host_um getHostLocalView(Access::ReadWriteStruct) const override {
711  typedef Kokkos::View<typename dual_view_type::t_host::data_type,
712  Kokkos::LayoutLeft,
713  typename dual_view_type::t_host::device_type,
714  Kokkos::MemoryUnmanaged>
715  epetra_view_type;
716 
717  // access Epetra multivector data
718  double *data = NULL;
719  int myLDA;
720  vec_->ExtractView(&data, &myLDA);
721  int localLength = vec_->MyLength();
722  int numVectors = getNumVectors();
723 
724  // create view
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());
727 
728  return ret;
729  }
730 
731  typename dual_view_type::t_dev_um getDeviceLocalView(Access::ReadWriteStruct) const override { return getHostLocalView(Access::ReadWrite); }
732 
734 
735  protected:
738  virtual void
740  typedef EpetraMultiVectorT this_type;
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.");
752 
753  RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector();
754  RCP<Epetra_MultiVector> lhsImpl = this->getEpetra_MultiVector();
755 
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.");
768 
769  // Epetra_MultiVector's assignment operator does a deep copy.
770  *lhsImpl = *rhsImpl;
771  }
772 
773  private:
775  RCP<Epetra_MultiVector> vec_;
776 
777 }; // EpetraMultiVectorT class (specialization on GO=int, NO=EpetraNode
778 #endif
779 
780 // specialization on GO=long long and EpetraNode
781 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
782 template <>
784  : public virtual MultiVector<double, int, long long, EpetraNode> {
785  typedef double Scalar;
786  typedef int LocalOrdinal;
787  typedef long long GlobalOrdinal;
788  typedef EpetraNode Node;
789 
790  public:
792 
793 
795  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut = true)
796  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) {}
797 
800  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(source)))) {}
801 
803  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &ArrayOfPtrs, size_t NumVectors) {
804  // TODO: input argument 'NumVectors' is not necessary in both Xpetra and Tpetra interface. Should it be removed?
805 
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.");
809 
810 #ifdef HAVE_XPETRA_DEBUG
811  // This cannot be tested by Epetra itself
812  {
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);
817  }
818  }
819 #endif
820 
821  // Convert Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > to double**
822  Array<const double *> arrayOfRawPtrs(ArrayOfPtrs.size());
823  for (int i = 0; i < ArrayOfPtrs.size(); i++) {
824  arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
825  }
826  double **rawArrayOfRawPtrs = const_cast<double **>(arrayOfRawPtrs.getRawPtr()); // This const_cast should be fine, because Epetra_DataAccess=Copy.
827 
828  vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal, Node>(map), rawArrayOfRawPtrs, NumVectors));
829  }
830 
832  virtual ~EpetraMultiVectorT() {}
833 
835 
837 
838 
840  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
841  XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue");
842  vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
843  }
844 
846  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
847  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue");
848  vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
849  }
850 
852  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
853  XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue");
854  vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
855  }
856 
858  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
859  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue");
860  vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
861  }
862 
864  void putScalar(const Scalar &value) {
865  XPETRA_MONITOR("EpetraMultiVectorT::putScalar");
866  vec_->PutScalar(value);
867  }
868 
870 
872 
873 
875  Teuchos::RCP<const Vector<double, int, long long, EpetraNode> > getVector(size_t j) const;
876 
878  Teuchos::RCP<Vector<double, int, long long, EpetraNode> > getVectorNonConst(size_t j);
879 
881  Teuchos::ArrayRCP<const Scalar> getData(size_t j) const {
882  XPETRA_MONITOR("EpetraMultiVectorT::getData");
883 
884  double **arrayOfPointers;
885 
886  vec_->ExtractView(&arrayOfPointers);
887 
888  double *data = arrayOfPointers[j];
889  int localLength = vec_->MyLength();
890 
891  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
892  }
893 
895  Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j) {
896  XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
897 
898  double **arrayOfPointers;
899 
900  vec_->ExtractView(&arrayOfPointers);
901 
902  double *data = arrayOfPointers[j];
903  int localLength = vec_->MyLength();
904 
905  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
906  }
907 
909 
911 
912 
914  void dot(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {
915  XPETRA_MONITOR("EpetraMultiVectorT::dot");
916 
917  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
918  vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
919  }
920 
923  XPETRA_MONITOR("EpetraMultiVectorT::abs");
924  vec_->Abs(toEpetra<GlobalOrdinal, Node>(A));
925  }
926 
929  XPETRA_MONITOR("EpetraMultiVectorT::reciprocal");
930  vec_->Reciprocal(toEpetra<GlobalOrdinal, Node>(A));
931  }
932 
934  void scale(const Scalar &alpha) {
935  XPETRA_MONITOR("EpetraMultiVectorT::scale");
936  vec_->Scale(alpha);
937  }
938 
940  void scale(Teuchos::ArrayView<const Scalar> alpha) {
941  XPETRA_MONITOR("EpetraMultiVectorT::scale");
942  // Epetra, unlike Tpetra, doesn't implement this version of
943  // scale(). Deal with this by scaling one column at a time.
944  const size_t numVecs = this->getNumVectors();
945  for (size_t j = 0; j < numVecs; ++j) {
946  Epetra_Vector *v = (*vec_)(j);
947  v->Scale(alpha[j]);
948  }
949  }
950 
953  XPETRA_MONITOR("EpetraMultiVectorT::update");
954  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta);
955  }
956 
959  XPETRA_MONITOR("EpetraMultiVectorT::update");
960  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta, toEpetra<GlobalOrdinal, Node>(B), gamma);
961  }
962 
964  void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
965  XPETRA_MONITOR("EpetraMultiVectorT::norm1");
966  vec_->Norm1(norms.getRawPtr());
967  }
968 
970  void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
971  XPETRA_MONITOR("EpetraMultiVectorT::norm2");
972  vec_->Norm2(norms.getRawPtr());
973  }
974 
976  void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
977  XPETRA_MONITOR("EpetraMultiVectorT::normInf");
978  vec_->NormInf(norms.getRawPtr());
979  }
980 
982  void meanValue(const Teuchos::ArrayView<Scalar> &means) const {
983  XPETRA_MONITOR("EpetraMultiVectorT::meanValue");
984  vec_->MeanValue(means.getRawPtr());
985  } // TODO: modify ArrayView size ??
986 
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) {
989  XPETRA_MONITOR("EpetraMultiVectorT::multiply");
990  vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta);
991  }
992 
995  XPETRA_MONITOR("EpetraMultiVectorT::elementWiseMultiply");
996  vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal, Node>(A), toEpetra<GlobalOrdinal, Node>(B), scalarThis);
997  }
998 
1000 
1002 
1003 
1005  size_t getNumVectors() const {
1006  XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors");
1007  return vec_->NumVectors();
1008  }
1009 
1011  size_t getLocalLength() const {
1012  XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength");
1013  return vec_->MyLength();
1014  }
1015 
1018  XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength");
1019  return vec_->GlobalLength64();
1020  }
1021 
1024  XPETRA_MONITOR("EpetraMultiVectorT::isSameSize");
1025  auto vv = toEpetra<GlobalOrdinal, Node>(vec);
1026  return ((vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
1027  }
1028 
1030 
1032 
1033 
1035  std::string description() const {
1036  XPETRA_MONITOR("EpetraMultiVectorT::description");
1037  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "TODO");
1038  // return "TODO"; // unreachable
1039  }
1040 
1042  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel /* verbLevel */ = Teuchos::Describable::verbLevel_default) const {
1043  XPETRA_MONITOR("EpetraMultiVectorT::describe");
1044  vec_->Print(out);
1045  }
1046 
1048 
1050  void randomize(bool bUseXpetraImplementation = false) {
1051  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
1052 
1053  if (bUseXpetraImplementation)
1055  else
1056  vec_->Random();
1057  }
1058 
1060  void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation = false) {
1061  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
1062 
1063  if (bUseXpetraImplementation)
1065  else {
1066  vec_->Random();
1067  const size_t numVectors = getNumVectors();
1068  for (size_t i = 0; i < numVectors; i++) {
1069  Teuchos::ArrayRCP<Scalar> datai = getDataNonConst(i);
1070 
1071  const size_t myLength = getLocalLength();
1072  for (size_t j = 0; j < myLength; j++) {
1073  datai[j] = 0.5 * (maxVal - minVal) * datai[j] + 0.5 * (maxVal + minVal);
1074  }
1075  }
1076  }
1077  }
1078 
1080  //{@
1081 
1083  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const {
1084  XPETRA_MONITOR("EpetraMultiVectorT::getMap");
1085  return toXpetra<GlobalOrdinal, Node>(vec_->Map());
1086  }
1087 
1090  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
1091 
1092  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1093  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1094 
1095  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
1096  int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1097  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra is " << err);
1098  }
1099 
1102  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
1103 
1104  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1105  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1106 
1107  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
1108  int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1109  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1110  }
1111 
1114  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
1115 
1116  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1117  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1118 
1119  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
1120  int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1121  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1122  }
1123 
1126  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
1127 
1128  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1129  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1130 
1131  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
1132  int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1133  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1134  }
1135 
1137  void replaceMap(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
1138  XPETRA_MONITOR("EpetraMultiVectorT::replaceMap");
1139  int err = 0;
1140  if (!map.is_null()) {
1141  err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra<GlobalOrdinal, Node>(map));
1142 
1143  } else {
1144  // Replace map with a dummy map to avoid potential hangs later
1145  Epetra_SerialComm SComm;
1146  Epetra_Map NewMap((GlobalOrdinal)vec_->MyLength(), (GlobalOrdinal)vec_->Map().IndexBase64(), SComm);
1147  err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
1148  }
1149  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1150  }
1151 
1153 
1155 
1156 
1158  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec)
1159  : vec_(vec) {} // TODO removed const
1160 
1162  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return vec_; }
1163 
1165  void setSeed(unsigned int seed) {
1166  XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
1167 
1168  Teuchos::ScalarTraits<Scalar>::seedrandom(seed);
1169  vec_->SetSeed(seed);
1170  }
1171 
1173 
1174  protected:
1177  virtual void
1179  typedef EpetraMultiVectorT this_type;
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.");
1191 
1192  RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector();
1193  RCP<Epetra_MultiVector> lhsImpl = this->getEpetra_MultiVector();
1194 
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.");
1207 
1208  // Epetra_MultiVector's assignment operator does a deep copy.
1209  *lhsImpl = *rhsImpl;
1210  }
1211 
1212  private:
1214  RCP<Epetra_MultiVector> vec_;
1215 
1216 }; // EpetraMultiVectorT class (specialization on GO=long long, NO=EpetraNode
1217 #endif
1218 
1219 } // namespace Xpetra
1220 
1221 #include "Xpetra_EpetraVector.hpp" // to avoid incomplete type instantiated above in out-of-body functions.
1222 
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.
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