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 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
52 #include <Kokkos_Core.hpp>
53 #include <Kokkos_DualView.hpp>
54 #endif
55 
56 
58 
59 #include "Xpetra_MultiVector.hpp"
60 #include "Xpetra_Vector.hpp"
61 
62 #include "Xpetra_EpetraMap.hpp"
63 #include "Xpetra_EpetraExport.hpp"
64 #include "Xpetra_Utils.hpp"
65 #include "Xpetra_EpetraUtils.hpp"
66 #include "Xpetra_EpetraImport.hpp"
67 #include "Xpetra_Exceptions.hpp"
68 #include "Epetra_SerialComm.h"
69 
70 #include <Epetra_MultiVector.h>
71 
72 namespace Xpetra {
73 
74  // TODO: move that elsewhere
75  template<class GlobalOrdinal, class Node>
76  const Epetra_MultiVector & toEpetra(const MultiVector<double,int,GlobalOrdinal,Node> &);
77  template<class GlobalOrdinal, class Node>
78  Epetra_MultiVector & toEpetra(MultiVector<double, int,GlobalOrdinal,Node> &);
79  template<class GlobalOrdinal, class Node>
80  RCP<MultiVector<double, int, GlobalOrdinal, Node> > toXpetra(RCP<Epetra_MultiVector> vec);
81 
82  // we need this forward declaration
83 #ifndef DOXYGEN_SHOULD_SKIP_THIS
84  template<class GlobalOrdinal, class Node> class EpetraVectorT;
85 #endif
86 
87  template<class EpetraGlobalOrdinal, class Node>
89  : public virtual MultiVector<double, int, EpetraGlobalOrdinal, Node>
90  {
91  typedef double Scalar;
92  typedef int LocalOrdinal;
93  typedef EpetraGlobalOrdinal GlobalOrdinal;
94 
95  public:
96 
98 
99 
101  EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true) {
103  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
104  }
105 
109  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
110  }
111 
115  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
116  }
117 
119  virtual ~EpetraMultiVectorT() {}
120 
122 
124 
125 
127  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { }
128 
130  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { }
131 
133  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { }
134 
136  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { }
137 
139  void putScalar(const Scalar &value) { }
140 
142 
144 
145 
148  return Teuchos::null;
149  }
150 
153  return Teuchos::null;
154  }
155 
158  return ArrayRCP<const Scalar>();
159  }
160 
163  return ArrayRCP<Scalar>();
164  }
165 
167 
169 
170 
173 
176 
179 
181  void scale(const Scalar &alpha) { }
182 
185 
187  void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta) { }
188 
190  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) { }
191 
194 
197 
200 
202  void meanValue(const Teuchos::ArrayView< Scalar > &means) const { }
203 
206 
209 
211 
213 
214 
216  size_t getNumVectors() const { return 0; }
217 
219  size_t getLocalLength() const { return 0; }
220 
222  global_size_t getGlobalLength() const { return 0; }
223 
225 
227 
228 
230  std::string description() const { return std::string(""); }
231 
234 
236 
238  void randomize(bool bUseXpetraImplementation = false) { }
239 
241  //{@
242 
245 
248 
251 
254 
257 
260 
262 
264 
265 
267  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec) { //TODO removed const
269  "Xpetra::EpetraMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
270  }
271 
273  RCP<Epetra_MultiVector> getEpetra_MultiVector() const { return Teuchos::null; }
274 
276  void setSeed(unsigned int seed) { }
277 
278 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
279 
281 
292  template<class TargetDeviceType>
293  typename Kokkos::Impl::if_c<
294  Kokkos::Impl::is_same<
295  typename dual_view_type::t_dev_um::execution_space::memory_space,
296  typename TargetDeviceType::memory_space>::value,
297  typename dual_view_type::t_dev_um,
298  typename dual_view_type::t_host_um>::type
299  getLocalView () const {
300  typename Kokkos::Impl::if_c<
301  Kokkos::Impl::is_same<
302  typename dual_view_type::t_dev_um::execution_space::memory_space,
303  typename TargetDeviceType::memory_space>::value,
304  typename dual_view_type::t_dev_um,
305  typename dual_view_type::t_host_um>::type dummy;
306  return dummy;
307  }
308 
309  typename dual_view_type::t_host_um getHostLocalView () const {
310  return typename dual_view_type::t_host_um();
311  }
312 
313  typename dual_view_type::t_dev_um getDeviceLocalView() const {
314  throw std::runtime_error("Epetra does not support device views!");
315  typename dual_view_type::t_dev_um ret;
316  return ret; // make compiler happy
317  }
318 
319 #endif
320 
322 
323  protected:
326  virtual void
328 
329  }; // EpetraMultiVectorT class
330 
331  // specialization for Node=Kokkos::Compat::KokkosSerialWrapperNode (needed for Epetra and Tpetra)
332 //#ifdef HAVE_XPETRA_SERIAL
333 // template<class EpetraGlobalOrdinal>
334 // class EpetraMultiVectorT<EpetraGlobalOrdinal, Kokkos::Compat::KokkosSerialWrapperNode>
335 // : public virtual MultiVector<double, int, EpetraGlobalOrdinal, Kokkos::Compat::KokkosSerialWrapperNode>
336 
337 
338  // specialization on GO=int and Node=Serial
339 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
340  template<>
342  : public virtual MultiVector<double, int, int, EpetraNode>
343  {
344  typedef double Scalar;
345  typedef int LocalOrdinal;
346  typedef int GlobalOrdinal;
347  typedef EpetraNode Node;
348 
349  public:
350 
352 
353 
355  EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
356  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal,Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) { }
357 
360  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal,Node>(source)))) { }
361 
364  //TODO: input argument 'NumVectors' is not necessary in both Xpetra and Tpetra interface. Should it be removed?
365 
366  const std::string tfecfFuncName("MultiVector(ArrayOfPtrs)");
367  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
368  ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
369 
370  #ifdef HAVE_XPETRA_DEBUG
371  // This cannot be tested by Epetra itself
372  {
373  size_t localLength = map->getNodeNumElements();
374  for(int j=0; j<ArrayOfPtrs.size(); j++) {
375  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
376  ": ArrayOfPtrs[" << j << "].size() (== " << ArrayOfPtrs[j].size() <<
377  ") is not equal to getLocalLength() (== " << localLength);
378 
379  }
380  }
381  #endif
382 
383  // Convert Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > to double**
384  Array<const double*> arrayOfRawPtrs(ArrayOfPtrs.size());
385  for(int i=0; i<ArrayOfPtrs.size(); i++) {
386  arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
387  }
388  double** rawArrayOfRawPtrs = const_cast<double**>(arrayOfRawPtrs.getRawPtr()); // This const_cast should be fine, because Epetra_DataAccess=Copy.
389 
390  vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal,Node>(map), rawArrayOfRawPtrs, NumVectors));
391  }
392 
394  virtual ~EpetraMultiVectorT() {}
395 
397 
399 
400 
402  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue"); vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value); }
403 
405  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue"); vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value); }
406 
408  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue"); vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value); }
409 
411  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue"); vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value); }
412 
414  void putScalar(const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::putScalar"); vec_->PutScalar(value); }
415 
417 
419 
420 
423 
426 
429  XPETRA_MONITOR("EpetraMultiVectorT::getData");
430 
431  double ** arrayOfPointers;
432 
433  vec_->ExtractView(&arrayOfPointers);
434 
435  double * data = arrayOfPointers[j];
436  int localLength = vec_->MyLength();
437 
438  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
439  }
440 
443  XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
444 
445  double ** arrayOfPointers;
446 
447  vec_->ExtractView(&arrayOfPointers);
448 
449  double * data = arrayOfPointers[j];
450  int localLength = vec_->MyLength();
451 
452  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
453  }
454 
456 
458 
459 
462  XPETRA_MONITOR("EpetraMultiVectorT::dot");
463 
464  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
465  vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
466  }
467 
469  void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVectorT::abs"); vec_->Abs(toEpetra<GlobalOrdinal,Node>(A)); }
470 
472  void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVectorT::reciprocal"); vec_->Reciprocal(toEpetra<GlobalOrdinal,Node>(A)); }
473 
475  void scale(const Scalar &alpha) { XPETRA_MONITOR("EpetraMultiVectorT::scale"); vec_->Scale(alpha); }
476 
479  XPETRA_MONITOR("EpetraMultiVectorT::scale");
480  // Epetra, unlike Tpetra, doesn't implement this version of
481  // scale(). Deal with this by scaling one column at a time.
482  const size_t numVecs = this->getNumVectors ();
483  for (size_t j = 0; j < numVecs; ++j) {
484  vec_->Scale (alpha[j]);
485  }
486  }
487 
489  void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta) { XPETRA_MONITOR("EpetraMultiVectorT::update"); vec_->Update(alpha, toEpetra<GlobalOrdinal,Node>(A), beta); }
490 
492  void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &gamma) { XPETRA_MONITOR("EpetraMultiVectorT::update"); vec_->Update(alpha, toEpetra<GlobalOrdinal,Node>(A), beta, toEpetra<GlobalOrdinal,Node>(B), gamma); }
493 
495  void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::norm1"); vec_->Norm1(norms.getRawPtr()); }
496 
498  void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::norm2"); vec_->Norm2(norms.getRawPtr()); }
499 
501  void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::normInf"); vec_->NormInf(norms.getRawPtr()); }
502 
504  void meanValue(const Teuchos::ArrayView< Scalar > &means) const { XPETRA_MONITOR("EpetraMultiVectorT::meanValue"); vec_->MeanValue(means.getRawPtr()); } //TODO: modify ArrayView size ??
505 
507  void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &beta) { XPETRA_MONITOR("EpetraMultiVectorT::multiply"); vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta); }
508 
510  void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis) { XPETRA_MONITOR("EpetraMultiVectorT::elementWiseMultiply"); vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal,Node>(A), toEpetra<GlobalOrdinal,Node>(B), scalarThis); }
511 
513 
515 
516 
518  size_t getNumVectors() const { XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors"); return vec_->NumVectors(); }
519 
521  size_t getLocalLength() const { XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength"); return vec_->MyLength(); }
522 
524  global_size_t getGlobalLength() const { XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength"); return vec_->GlobalLength64(); }
525 
527 
529 
530 
532  std::string description() const {
533  XPETRA_MONITOR("EpetraMultiVectorT::description");
535  return "TODO";
536  }
537 
540  XPETRA_MONITOR("EpetraMultiVectorT::describe");
541  vec_->Print(out);
542  }
543 
545 
547  void randomize(bool bUseXpetraImplementation = false) {
548  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
549 
550  if (bUseXpetraImplementation)
552  else
553  vec_->Random();
554  }
555 
557  //{@
558 
560  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const { XPETRA_MONITOR("EpetraMultiVectorT::getMap"); return toXpetra<GlobalOrdinal,Node>(vec_->Map()); }
561 
564  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
565 
566  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
567  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
568 
569  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
570  int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
571  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra is " << err);
572  }
573 
576  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
577 
578  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
579  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
580 
581  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
582  int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
583  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
584  }
585 
588  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
589 
590  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
591  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
592 
593  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
594  int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
595  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
596  }
597 
600  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
601 
602  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
603  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
604 
605  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
606  int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
607  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
608  }
609 
612  int err = 0;
613  if (!map.is_null()) {
614  err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra<GlobalOrdinal,Node>(map));
615 
616  } else {
617  // Replace map with a dummy map to avoid potential hangs later
618  Epetra_SerialComm SComm;
619  Epetra_Map NewMap((GlobalOrdinal) vec_->MyLength(), (GlobalOrdinal) vec_->Map().IndexBase64(), SComm);
620  err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
621  }
622  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
623  }
624 
626 
628 
629 
631  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec) : vec_(vec) { } //TODO removed const
632 
635 
637  void setSeed(unsigned int seed) {
638  XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
639 
641  vec_->SetSeed(seed);
642  }
643 
644 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
645 
647 
658  template<class TargetDeviceType>
659  typename Kokkos::Impl::if_c<
660  Kokkos::Impl::is_same<
661  typename dual_view_type::t_dev_um::execution_space::memory_space,
662  typename TargetDeviceType::memory_space>::value,
663  typename dual_view_type::t_dev_um,
664  typename dual_view_type::t_host_um>::type
665  getLocalView () const {
666  return this->MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::template getLocalView<TargetDeviceType>();
667  }
668 
669  typename dual_view_type::t_host_um getHostLocalView () const {
670  typedef Kokkos::View< typename dual_view_type::t_host::data_type ,
671  Kokkos::LayoutLeft,
672  typename dual_view_type::t_host::device_type ,
673  Kokkos::MemoryUnmanaged> epetra_view_type;
674 
675  // access Epetra multivector data
676  double* data = NULL;
677  int myLDA;
678  vec_->ExtractView(&data, &myLDA);
679  int localLength = vec_->MyLength();
680  int numVectors = getNumVectors();
681 
682  // create view
683  epetra_view_type test = epetra_view_type(data, localLength, numVectors);
684  typename dual_view_type::t_host_um ret = subview(test, Kokkos::ALL(), Kokkos::ALL());
685 
686  return ret;
687  }
688 
689  typename dual_view_type::t_dev_um getDeviceLocalView() const {
690  throw std::runtime_error("Epetra does not support device views!");
691  typename dual_view_type::t_dev_um ret;
692  return ret; // make compiler happy
693  }
694 
695 #endif
696 
698 
699  protected:
702  virtual void
704  typedef EpetraMultiVectorT this_type;
705  const this_type* rhsPtr = dynamic_cast<const this_type*> (&rhs);
707  rhsPtr == NULL, std::invalid_argument, "Xpetra::MultiVector::operator=: "
708  "The left-hand side (LHS) of the assignment has a different type than "
709  "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
710  "(which means it wraps an Epetra_MultiVector), but the RHS has some "
711  "other type. This probably means that the RHS wraps a Tpetra::Multi"
712  "Vector. Xpetra::MultiVector does not currently implement assignment "
713  "from a Tpetra object to an Epetra object, though this could be added "
714  "with sufficient interest.");
715 
716  RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector ();
718 
720  rhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
721  "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
722  "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
723  "report this bug to the Xpetra developers.");
725  lhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
726  "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
727  "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
728  "this bug to the Xpetra developers.");
729 
730  // Epetra_MultiVector's assignment operator does a deep copy.
731  *lhsImpl = *rhsImpl;
732  }
733 
734  private:
737 
738  }; // EpetraMultiVectorT class (specialization on GO=int, NO=EpetraNode
739 #endif
740 
741  // specialization on GO=long long and Node=Serial
742 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
743  template<>
744  class EpetraMultiVectorT<long long, EpetraNode>
745  : public virtual MultiVector<double, int, long long, EpetraNode>
746  {
747  typedef double Scalar;
748  typedef int LocalOrdinal;
749  typedef long long GlobalOrdinal;
750  typedef EpetraNode Node;
751 
752  public:
753 
755 
756 
758  EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
759  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal,Node>(map), Teuchos::as<int>(NumVectors), zeroOut))) { }
760 
763  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra<GlobalOrdinal,Node>(source)))) { }
764 
767  //TODO: input argument 'NumVectors' is not necessary in both Xpetra and Tpetra interface. Should it be removed?
768 
769  const std::string tfecfFuncName("MultiVector(ArrayOfPtrs)");
770  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
771  ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
772 
773  #ifdef HAVE_XPETRA_DEBUG
774  // This cannot be tested by Epetra itself
775  {
776  size_t localLength = map->getNodeNumElements();
777  for(int j=0; j<ArrayOfPtrs.size(); j++) {
778  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
779  ": ArrayOfPtrs[" << j << "].size() (== " << ArrayOfPtrs[j].size() <<
780  ") is not equal to getLocalLength() (== " << localLength);
781 
782  }
783  }
784  #endif
785 
786  // Convert Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > to double**
787  Array<const double*> arrayOfRawPtrs(ArrayOfPtrs.size());
788  for(int i=0; i<ArrayOfPtrs.size(); i++) {
789  arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
790  }
791  double** rawArrayOfRawPtrs = const_cast<double**>(arrayOfRawPtrs.getRawPtr()); // This const_cast should be fine, because Epetra_DataAccess=Copy.
792 
793  vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra<GlobalOrdinal,Node>(map), rawArrayOfRawPtrs, NumVectors));
794  }
795 
797  virtual ~EpetraMultiVectorT() {}
798 
800 
802 
803 
805  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue"); vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value); }
806 
808  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue"); vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value); }
809 
811  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue"); vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value); }
812 
814  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue"); vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value); }
815 
817  void putScalar(const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::putScalar"); vec_->PutScalar(value); }
818 
820 
822 
823 
826 
829 
832  XPETRA_MONITOR("EpetraMultiVectorT::getData");
833 
834  double ** arrayOfPointers;
835 
836  vec_->ExtractView(&arrayOfPointers);
837 
838  double * data = arrayOfPointers[j];
839  int localLength = vec_->MyLength();
840 
841  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
842  }
843 
846  XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
847 
848  double ** arrayOfPointers;
849 
850  vec_->ExtractView(&arrayOfPointers);
851 
852  double * data = arrayOfPointers[j];
853  int localLength = vec_->MyLength();
854 
855  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
856  }
857 
859 
861 
862 
865  XPETRA_MONITOR("EpetraMultiVectorT::dot");
866 
867  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
868  vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
869  }
870 
872  void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVectorT::abs"); vec_->Abs(toEpetra<GlobalOrdinal,Node>(A)); }
873 
875  void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVectorT::reciprocal"); vec_->Reciprocal(toEpetra<GlobalOrdinal,Node>(A)); }
876 
878  void scale(const Scalar &alpha) { XPETRA_MONITOR("EpetraMultiVectorT::scale"); vec_->Scale(alpha); }
879 
882  XPETRA_MONITOR("EpetraMultiVectorT::scale");
883  // Epetra, unlike Tpetra, doesn't implement this version of
884  // scale(). Deal with this by scaling one column at a time.
885  const size_t numVecs = this->getNumVectors ();
886  for (size_t j = 0; j < numVecs; ++j) {
887  vec_->Scale (alpha[j]);
888  }
889  }
890 
892  void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta) { XPETRA_MONITOR("EpetraMultiVectorT::update"); vec_->Update(alpha, toEpetra<GlobalOrdinal,Node>(A), beta); }
893 
895  void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &gamma) { XPETRA_MONITOR("EpetraMultiVectorT::update"); vec_->Update(alpha, toEpetra<GlobalOrdinal,Node>(A), beta, toEpetra<GlobalOrdinal,Node>(B), gamma); }
896 
898  void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::norm1"); vec_->Norm1(norms.getRawPtr()); }
899 
901  void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::norm2"); vec_->Norm2(norms.getRawPtr()); }
902 
904  void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::normInf"); vec_->NormInf(norms.getRawPtr()); }
905 
907  void meanValue(const Teuchos::ArrayView< Scalar > &means) const { XPETRA_MONITOR("EpetraMultiVectorT::meanValue"); vec_->MeanValue(means.getRawPtr()); } //TODO: modify ArrayView size ??
908 
910  void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, const Scalar &beta) { XPETRA_MONITOR("EpetraMultiVectorT::multiply"); vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta); }
911 
913  void elementWiseMultiply(Scalar scalarAB, const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &B, Scalar scalarThis) { XPETRA_MONITOR("EpetraMultiVectorT::elementWiseMultiply"); vec_->Multiply(scalarAB, toEpetra<GlobalOrdinal,Node>(A), toEpetra<GlobalOrdinal,Node>(B), scalarThis); }
914 
916 
918 
919 
921  size_t getNumVectors() const { XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors"); return vec_->NumVectors(); }
922 
924  size_t getLocalLength() const { XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength"); return vec_->MyLength(); }
925 
927  global_size_t getGlobalLength() const { XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength"); return vec_->GlobalLength64(); }
928 
930 
932 
933 
935  std::string description() const {
936  XPETRA_MONITOR("EpetraMultiVectorT::description");
938  return "TODO";
939  }
940 
943  XPETRA_MONITOR("EpetraMultiVectorT::describe");
944  vec_->Print(out);
945  }
946 
948 
950  void randomize(bool bUseXpetraImplementation = false) {
951  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
952 
953  if (bUseXpetraImplementation)
955  else
956  vec_->Random();
957  }
958 
960  //{@
961 
963  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const { XPETRA_MONITOR("EpetraMultiVectorT::getMap"); return toXpetra<GlobalOrdinal,Node>(vec_->Map()); }
964 
967  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
968 
969  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
970  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
971 
972  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
973  int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
974  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra is " << err);
975  }
976 
979  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
980 
981  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
982  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal COMMA Node>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
983 
984  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
985  int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
986  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
987  }
988 
991  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
992 
993  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
994  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
995 
996  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
997  int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
998  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
999  }
1000 
1003  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
1004 
1005  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal COMMA Node>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
1006  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal COMMA Node>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1007 
1008  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
1009  int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
1010  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1011  }
1012 
1015  int err = 0;
1016  if (!map.is_null()) {
1017  err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra<GlobalOrdinal,Node>(map));
1018 
1019  } else {
1020  // Replace map with a dummy map to avoid potential hangs later
1021  Epetra_SerialComm SComm;
1022  Epetra_Map NewMap((GlobalOrdinal) vec_->MyLength(), (GlobalOrdinal) vec_->Map().IndexBase64(), SComm);
1023  err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
1024  }
1025  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1026  }
1027 
1029 
1031 
1032 
1034  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec) : vec_(vec) { } //TODO removed const
1035 
1038 
1040  void setSeed(unsigned int seed) {
1041  XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
1042 
1044  vec_->SetSeed(seed);
1045  }
1046 
1047 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
1048 
1050 
1061  template<class TargetDeviceType>
1062  typename Kokkos::Impl::if_c<
1063  Kokkos::Impl::is_same<
1064  typename dual_view_type::t_dev_um::execution_space::memory_space,
1065  typename TargetDeviceType::memory_space>::value,
1066  typename dual_view_type::t_dev_um,
1067  typename dual_view_type::t_host_um>::type
1068  getLocalView () const {
1069  return this->MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::template getLocalView<TargetDeviceType>();
1070  }
1071 
1072  typename dual_view_type::t_host_um getHostLocalView () const {
1073  typedef Kokkos::View< typename dual_view_type::t_host::data_type ,
1074  Kokkos::LayoutLeft,
1075  typename dual_view_type::t_host::device_type ,
1076  Kokkos::MemoryUnmanaged> epetra_view_type;
1077 
1078  // access Epetra multivector data
1079  double* data = NULL;
1080  int myLDA;
1081  vec_->ExtractView(&data, &myLDA);
1082  int localLength = vec_->MyLength();
1083  int numVectors = getNumVectors();
1084 
1085  // create view
1086  epetra_view_type test = epetra_view_type(data, localLength, numVectors);
1087  typename dual_view_type::t_host_um ret = subview(test, Kokkos::ALL(), Kokkos::ALL());
1088 
1089  return ret;
1090  }
1091 
1092  typename dual_view_type::t_dev_um getDeviceLocalView() const {
1093  throw std::runtime_error("Epetra does not support device views!");
1094  typename dual_view_type::t_dev_um ret;
1095  return ret; // make compiler happy
1096  }
1097 
1098 #endif
1099 
1101 
1102  protected:
1105  virtual void
1107  typedef EpetraMultiVectorT this_type;
1108  const this_type* rhsPtr = dynamic_cast<const this_type*> (&rhs);
1110  rhsPtr == NULL, std::invalid_argument, "Xpetra::MultiVector::operator=: "
1111  "The left-hand side (LHS) of the assignment has a different type than "
1112  "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
1113  "(which means it wraps an Epetra_MultiVector), but the RHS has some "
1114  "other type. This probably means that the RHS wraps a Tpetra::Multi"
1115  "Vector. Xpetra::MultiVector does not currently implement assignment "
1116  "from a Tpetra object to an Epetra object, though this could be added "
1117  "with sufficient interest.");
1118 
1119  RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector ();
1121 
1123  rhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
1124  "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
1125  "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
1126  "report this bug to the Xpetra developers.");
1128  lhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
1129  "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
1130  "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
1131  "this bug to the Xpetra developers.");
1132 
1133  // Epetra_MultiVector's assignment operator does a deep copy.
1134  *lhsImpl = *rhsImpl;
1135  }
1136 
1137  private:
1140 
1141  }; // EpetraMultiVectorT class (specialization on GO=long long, NO=EpetraNode
1142 #endif
1143 
1144 } // Xpetra namespace
1145 
1146 #include "Xpetra_EpetraVector.hpp" // to avoid incomplete type instantiated above in out-of-body functions.
1147 
1148 #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.
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).
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.
std::string description() const
A simple one-line description of this object.
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const 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.
RCP< Epetra_MultiVector > vec_
The Epetra_MultiVector which this class wraps.
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.
#define TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(throw_exception_test, Exception, msg)
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...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void Xpetra_randomize()
Set multi-vector values to random numbers. XPetra implementation.
Xpetra namespace
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.
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).
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
Exception throws to report errors in the internal logical of the program.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Basic MultiVector constuctor.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
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 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).
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
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.
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
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.
void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
std::string description() const
A simple one-line description of this 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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.
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.
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.
T * getRawPtr() const
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
static void seedrandom(unsigned int s)
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
#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).
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.
static const EVerbosityLevel verbLevel_default
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
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)
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].
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.
TypeTo as(const TypeFrom &t)
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.
Copy
void replaceMap(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Replace the underlying Map in place.
EpetraMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source)
MultiVector copy constructor.
RCP< Epetra_MultiVector > getEpetra_MultiVector() const
Get the underlying Epetra multivector.
CombineMode
Xpetra::Combine Mode enumerable type.
#define XPETRA_MONITOR(funcName)
void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
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.
EpetraMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source)
MultiVector copy constructor.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
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.
Teuchos::RCP< const Vector< double, int, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const
Implements DistObject interface.
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
bool is_null() const