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 namespace Xpetra {
71 
72 // TODO: move that elsewhere
73 template <class GlobalOrdinal, class Node>
74 const Epetra_MultiVector &toEpetra(const MultiVector<double, int, GlobalOrdinal, Node> &);
75 template <class GlobalOrdinal, class Node>
76 Epetra_MultiVector &toEpetra(MultiVector<double, int, GlobalOrdinal, Node> &);
77 template <class GlobalOrdinal, class Node>
78 RCP<MultiVector<double, int, GlobalOrdinal, Node> > toXpetra(RCP<Epetra_MultiVector> vec);
79 
80 // we need this forward declaration
81 #ifndef DOXYGEN_SHOULD_SKIP_THIS
82 template <class GlobalOrdinal, class Node>
83 class EpetraVectorT;
84 #endif
85 
86 template <class EpetraGlobalOrdinal, class Node>
88  : public virtual MultiVector<double, int, EpetraGlobalOrdinal, Node> {
89  typedef double Scalar;
90  typedef int LocalOrdinal;
91  typedef EpetraGlobalOrdinal GlobalOrdinal;
92 
93  public:
95 
96 
98  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut = true) {
99  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
100  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
101  }
102 
104  EpetraMultiVectorT(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Teuchos::DataAccess copyOrView = Teuchos::Copy) {
105  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
106  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
107  }
108 
110  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &ArrayOfPtrs, size_t NumVectors) {
111  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
112  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
113  }
114 
116  virtual ~EpetraMultiVectorT() {}
117 
119 
121 
122 
124  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {}
125 
127  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {}
128 
130  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {}
131 
133  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {}
134 
136  void putScalar(const Scalar &value) {}
137 
139 
141 
142 
144  Teuchos::RCP<const Vector<double, int, GlobalOrdinal, Node> > getVector(size_t j) const {
145  return Teuchos::null;
146  }
147 
149  Teuchos::RCP<Vector<double, int, GlobalOrdinal, Node> > getVectorNonConst(size_t j) {
150  return Teuchos::null;
151  }
152 
154  Teuchos::ArrayRCP<const Scalar> getData(size_t j) const {
155  return ArrayRCP<const Scalar>();
156  }
157 
159  Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j) {
160  return ArrayRCP<Scalar>();
161  }
162 
164 
166 
167 
169  void dot(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {}
170 
173 
176 
178  void scale(const Scalar &alpha) {}
179 
181  void scale(Teuchos::ArrayView<const Scalar> alpha) {}
182 
184  void update(const Scalar &alpha, const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Scalar &beta) {}
185 
188 
190  void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {}
191 
193  void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {}
194 
196  void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {}
197 
199  void meanValue(const Teuchos::ArrayView<Scalar> &means) const {}
200 
202  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) {}
203 
206 
208 
210 
211 
213  size_t getNumVectors() const { return 0; }
214 
216  size_t getLocalLength() const { return 0; }
217 
219  global_size_t getGlobalLength() const { return 0; }
220 
221  // \brief Checks to see if the local length, number of vectors and size of Scalar type match
223 
225 
227 
228 
230  std::string description() const { return std::string(""); }
231 
233  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const {}
234 
236 
238  void randomize(bool bUseXpetraImplementation = false) {}
239 
241  void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation = false) {}
242 
244  //{@
245 
247  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const { return Teuchos::null; }
248 
251 
254 
257 
260 
262  void replaceMap(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {}
263 
265 
267 
268 
270  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec) { // TODO removed const
271  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::RuntimeError,
272  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
273  }
274 
276  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return Teuchos::null; }
277 
279  void setSeed(unsigned int seed) {}
280 
282 
283  protected:
286  virtual void
288 
289 }; // EpetraMultiVectorT class
290 
291 // specialization on GO=int and Node=EpetraNode
292 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
293 template <>
295  : public virtual MultiVector<double, int, int, EpetraNode> {
296  typedef double Scalar;
297  typedef int LocalOrdinal;
298  typedef int GlobalOrdinal;
299  typedef EpetraNode Node;
300 
301  public:
303 
304 
306  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut = true)
307  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) {}
308 
310  EpetraMultiVectorT(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &source, const Teuchos::DataAccess copyOrView = Teuchos::Copy) {
311  if (copyOrView == Teuchos::Copy)
312  vec_ = Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(source)));
313  else {
314  int *indices = new int[source.getNumVectors()];
315  for (size_t i = 0; i < source.getNumVectors(); i++)
316  indices[i] = i;
317  vec_ = Teuchos::rcp(new Epetra_MultiVector(View, toEpetra<GlobalOrdinal, Node>(source), indices, source.getNumVectors()));
318  delete[] indices;
319  }
320  }
321 
323  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &ArrayOfPtrs, size_t NumVectors) {
324  // TODO: input argument 'NumVectors' is not necessary in both Xpetra and Tpetra interface. Should it be removed?
325 
326  const std::string tfecfFuncName("MultiVector(ArrayOfPtrs)");
327  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
328  ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
329 
330 #ifdef HAVE_XPETRA_DEBUG
331  // This cannot be tested by Epetra itself
332  {
333  size_t localLength = map->getLocalNumElements();
334  for (int j = 0; j < ArrayOfPtrs.size(); j++) {
335  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
336  ": ArrayOfPtrs[" << j << "].size() (== " << ArrayOfPtrs[j].size() << ") is not equal to getLocalLength() (== " << localLength);
337  }
338  }
339 #endif
340 
341  // Convert Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > to double**
342  Array<const double *> arrayOfRawPtrs(ArrayOfPtrs.size());
343  for (int i = 0; i < ArrayOfPtrs.size(); i++) {
344  arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
345  }
346  double **rawArrayOfRawPtrs = const_cast<double **>(arrayOfRawPtrs.getRawPtr()); // This const_cast should be fine, because Epetra_DataAccess=Copy.
347 
348  vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal, Node>(map), rawArrayOfRawPtrs, static_cast<int>(NumVectors)));
349  }
350 
352  virtual ~EpetraMultiVectorT() {}
353 
355 
357 
358 
360  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
361  XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue");
362  vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
363  }
364 
366  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
367  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue");
368  vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
369  }
370 
372  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
373  XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue");
374  vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
375  }
376 
378  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
379  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue");
380  vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
381  }
382 
384  void putScalar(const Scalar &value) {
385  XPETRA_MONITOR("EpetraMultiVectorT::putScalar");
386  vec_->PutScalar(value);
387  }
388 
390 
392 
393 
395  Teuchos::RCP<const Vector<double, int, int, EpetraNode> > getVector(size_t j) const;
396 
398  Teuchos::RCP<Vector<double, int, int, EpetraNode> > getVectorNonConst(size_t j);
399 
401  Teuchos::ArrayRCP<const Scalar> getData(size_t j) const {
402  XPETRA_MONITOR("EpetraMultiVectorT::getData");
403 
404  double **arrayOfPointers;
405 
406  vec_->ExtractView(&arrayOfPointers);
407 
408  double *data = arrayOfPointers[j];
409  int localLength = vec_->MyLength();
410 
411  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
412  }
413 
415  Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j) {
416  XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
417 
418  double **arrayOfPointers;
419 
420  vec_->ExtractView(&arrayOfPointers);
421 
422  double *data = arrayOfPointers[j];
423  int localLength = vec_->MyLength();
424 
425  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
426  }
427 
429 
431 
432 
434  void dot(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {
435  XPETRA_MONITOR("EpetraMultiVectorT::dot");
436 
437  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
438  vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
439  }
440 
443  XPETRA_MONITOR("EpetraMultiVectorT::abs");
444  vec_->Abs(toEpetra<GlobalOrdinal, Node>(A));
445  }
446 
449  XPETRA_MONITOR("EpetraMultiVectorT::reciprocal");
450  vec_->Reciprocal(toEpetra<GlobalOrdinal, Node>(A));
451  }
452 
454  void scale(const Scalar &alpha) {
455  XPETRA_MONITOR("EpetraMultiVectorT::scale");
456  vec_->Scale(alpha);
457  }
458 
460  void scale(Teuchos::ArrayView<const Scalar> alpha) {
461  XPETRA_MONITOR("EpetraMultiVectorT::scale");
462  // Epetra, unlike Tpetra, doesn't implement this version of
463  // scale(). Deal with this by scaling one column at a time.
464  const size_t numVecs = this->getNumVectors();
465  for (size_t j = 0; j < numVecs; ++j) {
466  Epetra_Vector *v = (*vec_)(j);
467  v->Scale(alpha[j]);
468  }
469  }
470 
473  XPETRA_MONITOR("EpetraMultiVectorT::update");
474  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta);
475  }
476 
479  XPETRA_MONITOR("EpetraMultiVectorT::update");
480  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta, toEpetra<GlobalOrdinal, Node>(B), gamma);
481  }
482 
484  void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
485  XPETRA_MONITOR("EpetraMultiVectorT::norm1");
486  vec_->Norm1(norms.getRawPtr());
487  }
488 
490  void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
491  XPETRA_MONITOR("EpetraMultiVectorT::norm2");
492  vec_->Norm2(norms.getRawPtr());
493  }
494 
496  void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
497  XPETRA_MONITOR("EpetraMultiVectorT::normInf");
498  vec_->NormInf(norms.getRawPtr());
499  }
500 
502  void meanValue(const Teuchos::ArrayView<Scalar> &means) const {
503  XPETRA_MONITOR("EpetraMultiVectorT::meanValue");
504  vec_->MeanValue(means.getRawPtr());
505  } // TODO: modify ArrayView size ??
506 
508  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) {
509  XPETRA_MONITOR("EpetraMultiVectorT::multiply");
510  vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta);
511  }
512 
515  XPETRA_MONITOR("EpetraMultiVectorT::elementWiseMultiply");
516  vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal, Node>(A), toEpetra<GlobalOrdinal, Node>(B), scalarThis);
517  }
518 
520 
522 
523 
525  size_t getNumVectors() const {
526  XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors");
527  return vec_->NumVectors();
528  }
529 
531  size_t getLocalLength() const {
532  XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength");
533  return vec_->MyLength();
534  }
535 
538  XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength");
539  return vec_->GlobalLength64();
540  }
541 
544  XPETRA_MONITOR("EpetraMultiVectorT::isSameSize");
545  auto vv = toEpetra<GlobalOrdinal, Node>(vec);
546  return ((vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
547  }
548 
550 
552 
553 
555  std::string description() const {
556  XPETRA_MONITOR("EpetraMultiVectorT::description");
557  TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO");
558  TEUCHOS_UNREACHABLE_RETURN("TODO");
559  }
560 
562  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel /* verbLevel */ = Teuchos::Describable::verbLevel_default) const {
563  XPETRA_MONITOR("EpetraMultiVectorT::describe");
564  vec_->Print(out);
565  }
566 
568 
570  void randomize(bool bUseXpetraImplementation = false) {
571  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
572 
573  if (bUseXpetraImplementation)
575  else
576  vec_->Random();
577  }
578 
580  void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation = false) {
581  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
582 
583  if (bUseXpetraImplementation)
585  else {
586  vec_->Random();
587  const size_t numVectors = getNumVectors();
588  for (size_t i = 0; i < numVectors; i++) {
589  Teuchos::ArrayRCP<Scalar> datai = getDataNonConst(i);
590 
591  const size_t myLength = getLocalLength();
592  for (size_t j = 0; j < myLength; j++) {
593  datai[j] = 0.5 * (maxVal - minVal) * datai[j] + 0.5 * (maxVal + minVal);
594  }
595  }
596  }
597  }
598 
600  //{@
601 
603  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const {
604  XPETRA_MONITOR("EpetraMultiVectorT::getMap");
605  return toXpetra<GlobalOrdinal, Node>(vec_->Map());
606  }
607 
610  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
611 
612  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
613  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
614 
615  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
616  int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
617  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra is " << err);
618  }
619 
622  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
623 
624  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
625  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
626 
627  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
628  int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
629  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
630  }
631 
634  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
635 
636  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
637  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
638 
639  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
640  int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
641  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
642  }
643 
646  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
647 
648  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
649  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
650 
651  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
652  int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
653  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
654  }
655 
657  void replaceMap(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
658  XPETRA_MONITOR("EpetraMultiVectorT::replaceMap");
659  int err = 0;
660  if (!map.is_null()) {
661  err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra<GlobalOrdinal, Node>(map));
662 
663  } else {
664  // Replace map with a dummy map to avoid potential hangs later
665  Epetra_SerialComm SComm;
666  Epetra_Map NewMap((GlobalOrdinal)vec_->MyLength(), (GlobalOrdinal)vec_->Map().IndexBase64(), SComm);
667  err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
668  }
669  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
670  }
671 
673 
675 
676 
678  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec)
679  : vec_(vec) {} // TODO removed const
680 
682  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return vec_; }
683 
685  void setSeed(unsigned int seed) {
686  XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
687 
688  Teuchos::ScalarTraits<Scalar>::seedrandom(seed);
689  vec_->SetSeed(seed);
690  }
691 
693 
694  typename dual_view_type::t_host_const_um getHostLocalView(Access::ReadOnlyStruct) const override { return getHostLocalView(Access::ReadWrite); }
695 
696  typename dual_view_type::t_dev_const_um getDeviceLocalView(Access::ReadOnlyStruct) const override { return getDeviceLocalView(Access::ReadWrite); }
697 
698  typename dual_view_type::t_host_um getHostLocalView(Access::OverwriteAllStruct) const override { return getHostLocalView(Access::ReadWrite); }
699 
700  typename dual_view_type::t_dev_um getDeviceLocalView(Access::OverwriteAllStruct) const override { return getDeviceLocalView(Access::ReadWrite); }
701 
702  typename dual_view_type::t_host_um getHostLocalView(Access::ReadWriteStruct) const override {
703  typedef Kokkos::View<typename dual_view_type::t_host::data_type,
704  Kokkos::LayoutLeft,
705  typename dual_view_type::t_host::device_type,
706  Kokkos::MemoryUnmanaged>
707  epetra_view_type;
708 
709  // access Epetra multivector data
710  double *data = NULL;
711  int myLDA;
712  vec_->ExtractView(&data, &myLDA);
713  int localLength = vec_->MyLength();
714  int numVectors = getNumVectors();
715 
716  // create view
717  epetra_view_type test = epetra_view_type(data, localLength, numVectors);
718  typename dual_view_type::t_host_um ret = subview(test, Kokkos::ALL(), Kokkos::ALL());
719 
720  return ret;
721  }
722 
723  typename dual_view_type::t_dev_um getDeviceLocalView(Access::ReadWriteStruct) const override { return getHostLocalView(Access::ReadWrite); }
724 
726 
727  protected:
730  virtual void
732  typedef EpetraMultiVectorT this_type;
733  const this_type *rhsPtr = dynamic_cast<const this_type *>(&rhs);
734  TEUCHOS_TEST_FOR_EXCEPTION(
735  rhsPtr == NULL, std::invalid_argument,
736  "Xpetra::MultiVector::operator=: "
737  "The left-hand side (LHS) of the assignment has a different type than "
738  "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
739  "(which means it wraps an Epetra_MultiVector), but the RHS has some "
740  "other type. This probably means that the RHS wraps a Tpetra::Multi"
741  "Vector. Xpetra::MultiVector does not currently implement assignment "
742  "from a Tpetra object to an Epetra object, though this could be added "
743  "with sufficient interest.");
744 
745  RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector();
746  RCP<Epetra_MultiVector> lhsImpl = this->getEpetra_MultiVector();
747 
748  TEUCHOS_TEST_FOR_EXCEPTION(
749  rhsImpl.is_null(), std::logic_error,
750  "Xpetra::MultiVector::operator= "
751  "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
752  "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
753  "report this bug to the Xpetra developers.");
754  TEUCHOS_TEST_FOR_EXCEPTION(
755  lhsImpl.is_null(), std::logic_error,
756  "Xpetra::MultiVector::operator= "
757  "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
758  "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
759  "this bug to the Xpetra developers.");
760 
761  // Epetra_MultiVector's assignment operator does a deep copy.
762  *lhsImpl = *rhsImpl;
763  }
764 
765  private:
767  RCP<Epetra_MultiVector> vec_;
768 
769 }; // EpetraMultiVectorT class (specialization on GO=int, NO=EpetraNode
770 #endif
771 
772 // specialization on GO=long long and EpetraNode
773 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
774 template <>
776  : public virtual MultiVector<double, int, long long, EpetraNode> {
777  typedef double Scalar;
778  typedef int LocalOrdinal;
779  typedef long long GlobalOrdinal;
780  typedef EpetraNode Node;
781 
782  public:
784 
785 
787  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut = true)
788  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) {}
789 
792  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal, Node>(source)))) {}
793 
795  EpetraMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, const Teuchos::ArrayView<const Teuchos::ArrayView<const Scalar> > &ArrayOfPtrs, size_t NumVectors) {
796  // TODO: input argument 'NumVectors' is not necessary in both Xpetra and Tpetra interface. Should it be removed?
797 
798  const std::string tfecfFuncName("MultiVector(ArrayOfPtrs)");
799  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
800  ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
801 
802 #ifdef HAVE_XPETRA_DEBUG
803  // This cannot be tested by Epetra itself
804  {
805  size_t localLength = map->getLocalNumElements();
806  for (int j = 0; j < ArrayOfPtrs.size(); j++) {
807  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
808  ": ArrayOfPtrs[" << j << "].size() (== " << ArrayOfPtrs[j].size() << ") is not equal to getLocalLength() (== " << localLength);
809  }
810  }
811 #endif
812 
813  // Convert Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > to double**
814  Array<const double *> arrayOfRawPtrs(ArrayOfPtrs.size());
815  for (int i = 0; i < ArrayOfPtrs.size(); i++) {
816  arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
817  }
818  double **rawArrayOfRawPtrs = const_cast<double **>(arrayOfRawPtrs.getRawPtr()); // This const_cast should be fine, because Epetra_DataAccess=Copy.
819 
820  vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal, Node>(map), rawArrayOfRawPtrs, NumVectors));
821  }
822 
824  virtual ~EpetraMultiVectorT() {}
825 
827 
829 
830 
832  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
833  XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue");
834  vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
835  }
836 
838  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
839  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue");
840  vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value);
841  }
842 
844  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
845  XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue");
846  vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
847  }
848 
850  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
851  XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue");
852  vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value);
853  }
854 
856  void putScalar(const Scalar &value) {
857  XPETRA_MONITOR("EpetraMultiVectorT::putScalar");
858  vec_->PutScalar(value);
859  }
860 
862 
864 
865 
867  Teuchos::RCP<const Vector<double, int, long long, EpetraNode> > getVector(size_t j) const;
868 
870  Teuchos::RCP<Vector<double, int, long long, EpetraNode> > getVectorNonConst(size_t j);
871 
873  Teuchos::ArrayRCP<const Scalar> getData(size_t j) const {
874  XPETRA_MONITOR("EpetraMultiVectorT::getData");
875 
876  double **arrayOfPointers;
877 
878  vec_->ExtractView(&arrayOfPointers);
879 
880  double *data = arrayOfPointers[j];
881  int localLength = vec_->MyLength();
882 
883  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
884  }
885 
887  Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j) {
888  XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
889 
890  double **arrayOfPointers;
891 
892  vec_->ExtractView(&arrayOfPointers);
893 
894  double *data = arrayOfPointers[j];
895  int localLength = vec_->MyLength();
896 
897  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
898  }
899 
901 
903 
904 
906  void dot(const MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> &A, const Teuchos::ArrayView<Scalar> &dots) const {
907  XPETRA_MONITOR("EpetraMultiVectorT::dot");
908 
909  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
910  vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
911  }
912 
915  XPETRA_MONITOR("EpetraMultiVectorT::abs");
916  vec_->Abs(toEpetra<GlobalOrdinal, Node>(A));
917  }
918 
921  XPETRA_MONITOR("EpetraMultiVectorT::reciprocal");
922  vec_->Reciprocal(toEpetra<GlobalOrdinal, Node>(A));
923  }
924 
926  void scale(const Scalar &alpha) {
927  XPETRA_MONITOR("EpetraMultiVectorT::scale");
928  vec_->Scale(alpha);
929  }
930 
932  void scale(Teuchos::ArrayView<const Scalar> alpha) {
933  XPETRA_MONITOR("EpetraMultiVectorT::scale");
934  // Epetra, unlike Tpetra, doesn't implement this version of
935  // scale(). Deal with this by scaling one column at a time.
936  const size_t numVecs = this->getNumVectors();
937  for (size_t j = 0; j < numVecs; ++j) {
938  Epetra_Vector *v = (*vec_)(j);
939  v->Scale(alpha[j]);
940  }
941  }
942 
945  XPETRA_MONITOR("EpetraMultiVectorT::update");
946  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta);
947  }
948 
951  XPETRA_MONITOR("EpetraMultiVectorT::update");
952  vec_->Update(alpha, toEpetra<GlobalOrdinal, Node>(A), beta, toEpetra<GlobalOrdinal, Node>(B), gamma);
953  }
954 
956  void norm1(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
957  XPETRA_MONITOR("EpetraMultiVectorT::norm1");
958  vec_->Norm1(norms.getRawPtr());
959  }
960 
962  void norm2(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
963  XPETRA_MONITOR("EpetraMultiVectorT::norm2");
964  vec_->Norm2(norms.getRawPtr());
965  }
966 
968  void normInf(const Teuchos::ArrayView<Teuchos::ScalarTraits<Scalar>::magnitudeType> &norms) const {
969  XPETRA_MONITOR("EpetraMultiVectorT::normInf");
970  vec_->NormInf(norms.getRawPtr());
971  }
972 
974  void meanValue(const Teuchos::ArrayView<Scalar> &means) const {
975  XPETRA_MONITOR("EpetraMultiVectorT::meanValue");
976  vec_->MeanValue(means.getRawPtr());
977  } // TODO: modify ArrayView size ??
978 
980  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) {
981  XPETRA_MONITOR("EpetraMultiVectorT::multiply");
982  vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta);
983  }
984 
987  XPETRA_MONITOR("EpetraMultiVectorT::elementWiseMultiply");
988  vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal, Node>(A), toEpetra<GlobalOrdinal, Node>(B), scalarThis);
989  }
990 
992 
994 
995 
997  size_t getNumVectors() const {
998  XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors");
999  return vec_->NumVectors();
1000  }
1001 
1003  size_t getLocalLength() const {
1004  XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength");
1005  return vec_->MyLength();
1006  }
1007 
1010  XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength");
1011  return vec_->GlobalLength64();
1012  }
1013 
1016  XPETRA_MONITOR("EpetraMultiVectorT::isSameSize");
1017  auto vv = toEpetra<GlobalOrdinal, Node>(vec);
1018  return ((vec_->MyLength() == vv.MyLength()) && (vec_->NumVectors() == vv.NumVectors()));
1019  }
1020 
1022 
1024 
1025 
1027  std::string description() const {
1028  XPETRA_MONITOR("EpetraMultiVectorT::description");
1029  TEUCHOS_TEST_FOR_EXCEPTION(true, Xpetra::Exceptions::NotImplemented, "TODO");
1030  // return "TODO"; // unreachable
1031  }
1032 
1034  void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel /* verbLevel */ = Teuchos::Describable::verbLevel_default) const {
1035  XPETRA_MONITOR("EpetraMultiVectorT::describe");
1036  vec_->Print(out);
1037  }
1038 
1040 
1042  void randomize(bool bUseXpetraImplementation = false) {
1043  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
1044 
1045  if (bUseXpetraImplementation)
1047  else
1048  vec_->Random();
1049  }
1050 
1052  void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation = false) {
1053  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
1054 
1055  if (bUseXpetraImplementation)
1057  else {
1058  vec_->Random();
1059  const size_t numVectors = getNumVectors();
1060  for (size_t i = 0; i < numVectors; i++) {
1061  Teuchos::ArrayRCP<Scalar> datai = getDataNonConst(i);
1062 
1063  const size_t myLength = getLocalLength();
1064  for (size_t j = 0; j < myLength; j++) {
1065  datai[j] = 0.5 * (maxVal - minVal) * datai[j] + 0.5 * (maxVal + minVal);
1066  }
1067  }
1068  }
1069  }
1070 
1072  //{@
1073 
1075  Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > getMap() const {
1076  XPETRA_MONITOR("EpetraMultiVectorT::getMap");
1077  return toXpetra<GlobalOrdinal, Node>(vec_->Map());
1078  }
1079 
1082  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
1083 
1084  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1085  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1086 
1087  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
1088  int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1089  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra is " << err);
1090  }
1091 
1094  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
1095 
1096  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1097  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1098 
1099  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
1100  int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
1101  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1102  }
1103 
1106  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
1107 
1108  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1109  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1110 
1111  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
1112  int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1113  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1114  }
1115 
1118  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
1119 
1120  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1121  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1122 
1123  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
1124  int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1125  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1126  }
1127 
1129  void replaceMap(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map) {
1130  XPETRA_MONITOR("EpetraMultiVectorT::replaceMap");
1131  int err = 0;
1132  if (!map.is_null()) {
1133  err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra<GlobalOrdinal, Node>(map));
1134 
1135  } else {
1136  // Replace map with a dummy map to avoid potential hangs later
1137  Epetra_SerialComm SComm;
1138  Epetra_Map NewMap((GlobalOrdinal)vec_->MyLength(), (GlobalOrdinal)vec_->Map().IndexBase64(), SComm);
1139  err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
1140  }
1141  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1142  }
1143 
1145 
1147 
1148 
1150  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec)
1151  : vec_(vec) {} // TODO removed const
1152 
1154  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return vec_; }
1155 
1157  void setSeed(unsigned int seed) {
1158  XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
1159 
1160  Teuchos::ScalarTraits<Scalar>::seedrandom(seed);
1161  vec_->SetSeed(seed);
1162  }
1163 
1165 
1166  protected:
1169  virtual void
1171  typedef EpetraMultiVectorT this_type;
1172  const this_type *rhsPtr = dynamic_cast<const this_type *>(&rhs);
1173  TEUCHOS_TEST_FOR_EXCEPTION(
1174  rhsPtr == NULL, std::invalid_argument,
1175  "Xpetra::MultiVector::operator=: "
1176  "The left-hand side (LHS) of the assignment has a different type than "
1177  "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
1178  "(which means it wraps an Epetra_MultiVector), but the RHS has some "
1179  "other type. This probably means that the RHS wraps a Tpetra::Multi"
1180  "Vector. Xpetra::MultiVector does not currently implement assignment "
1181  "from a Tpetra object to an Epetra object, though this could be added "
1182  "with sufficient interest.");
1183 
1184  RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector();
1185  RCP<Epetra_MultiVector> lhsImpl = this->getEpetra_MultiVector();
1186 
1187  TEUCHOS_TEST_FOR_EXCEPTION(
1188  rhsImpl.is_null(), std::logic_error,
1189  "Xpetra::MultiVector::operator= "
1190  "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
1191  "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
1192  "report this bug to the Xpetra developers.");
1193  TEUCHOS_TEST_FOR_EXCEPTION(
1194  lhsImpl.is_null(), std::logic_error,
1195  "Xpetra::MultiVector::operator= "
1196  "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
1197  "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
1198  "this bug to the Xpetra developers.");
1199 
1200  // Epetra_MultiVector's assignment operator does a deep copy.
1201  *lhsImpl = *rhsImpl;
1202  }
1203 
1204  private:
1206  RCP<Epetra_MultiVector> vec_;
1207 
1208 }; // EpetraMultiVectorT class (specialization on GO=long long, NO=EpetraNode
1209 #endif
1210 
1211 } // namespace Xpetra
1212 
1213 #include "Xpetra_EpetraVector.hpp" // to avoid incomplete type instantiated above in out-of-body functions.
1214 
1215 #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).
RCP< const CrsGraph< int, GlobalOrdinal, Node > > toXpetra(const Epetra_CrsGraph &g)
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
dual_view_type::t_host_const_um getHostLocalView(Access::ReadOnlyStruct) const override