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>
76  const Epetra_MultiVector & toEpetra(const MultiVector<double,int,GlobalOrdinal> &);
77  template<class GlobalOrdinal>
78  Epetra_MultiVector & toEpetra(MultiVector<double, int,GlobalOrdinal> &);
79  template<class GlobalOrdinal>
80  RCP<MultiVector<double, int, GlobalOrdinal> > toXpetra(RCP<Epetra_MultiVector> vec);
81 
82  // #ifndef DOXYGEN_SHOULD_SKIP_THIS
83  // // forward declaration of EpetraVectorT, needed to prevent circular inclusions
84  // template<class S, class LO, class GO, class N> class EpetraVectorT;
85  // #endif
86 
87  template<class EpetraGlobalOrdinal>
89  : public virtual MultiVector<double, int, EpetraGlobalOrdinal>
90  {
91  typedef double Scalar;
92  typedef int LocalOrdinal;
93  typedef EpetraGlobalOrdinal GlobalOrdinal;
95 
96  public:
97 
99 
100 
102  EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
103  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra(map), Teuchos::as<int>(NumVectors), zeroOut))) { }
104 
107  : vec_(Teuchos::rcp(new Epetra_MultiVector(toEpetra(source)))) { }
108 
111 
113  virtual ~EpetraMultiVectorT() {}
114 
116 
118 
119 
121  void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::replaceGlobalValue"); vec_->ReplaceGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value); }
122 
124  void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::sumIntoGlobalValue"); vec_->SumIntoGlobalValue(globalRow, Teuchos::as<int>(vectorIndex), value); }
125 
127  void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::replaceLocalValue"); vec_->ReplaceMyValue(myRow, Teuchos::as<int>(vectorIndex), value); }
128 
130  void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::sumIntoLocalValue"); vec_->SumIntoMyValue(myRow, Teuchos::as<int>(vectorIndex), value); }
131 
133  void putScalar(const Scalar &value) { XPETRA_MONITOR("EpetraMultiVectorT::putScalar"); vec_->PutScalar(value); }
134 
136 
138 
139 
142 
145 
148 
151 
153 
155 
156 
159 
161  void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVectorT::abs"); vec_->Abs(toEpetra(A)); }
162 
164  void reciprocal(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A) { XPETRA_MONITOR("EpetraMultiVectorT::reciprocal"); vec_->Reciprocal(toEpetra(A)); }
165 
167  void scale(const Scalar &alpha) { XPETRA_MONITOR("EpetraMultiVectorT::scale"); vec_->Scale(alpha); }
168 
171  XPETRA_MONITOR("EpetraMultiVectorT::scale");
172  // Epetra, unlike Tpetra, doesn't implement this version of
173  // scale(). Deal with this by scaling one column at a time.
174  const size_t numVecs = this->getNumVectors ();
175  for (size_t j = 0; j < numVecs; ++j) {
176  vec_->Scale (alpha[j]);
177  }
178  }
179 
181  void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta) { XPETRA_MONITOR("EpetraMultiVectorT::update"); vec_->Update(alpha, toEpetra(A), beta); }
182 
184  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(A), beta, toEpetra(B), gamma); }
185 
188 
191 
194 
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) { XPETRA_MONITOR("EpetraMultiVectorT::multiply"); vec_->Multiply(toEpetra(transA), toEpetra(transB), alpha, toEpetra(A), toEpetra(B), beta); }
203 
205  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(A), toEpetra(B), scalarThis); }
206 
208 
210 
211 
213  size_t getNumVectors() const { XPETRA_MONITOR("EpetraMultiVectorT::getNumVectors"); return vec_->NumVectors(); }
214 
216  size_t getLocalLength() const { XPETRA_MONITOR("EpetraMultiVectorT::getLocalLength"); return vec_->MyLength(); }
217 
219  global_size_t getGlobalLength() const { XPETRA_MONITOR("EpetraMultiVectorT::getGlobalLength"); return vec_->GlobalLength64(); }
220 
222 
224 
225 
227  std::string description() const;
228 
231 
233 
235  void randomize(bool bUseXpetraImplementation = false) {
236  XPETRA_MONITOR("EpetraMultiVectorT::randomize");
237 
238  if (bUseXpetraImplementation)
240  else
241  vec_->Random();
242  }
243 
245  //{@
246 
248  Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getMap() const { XPETRA_MONITOR("EpetraMultiVectorT::getMap"); return toXpetra<GlobalOrdinal>(vec_->Map()); }
249 
252 
255 
258 
261 
264 
266 
268 
269 
271  EpetraMultiVectorT(const RCP<Epetra_MultiVector> &vec) : vec_(vec) { } //TODO removed const
272 
275 
277  void setSeed(unsigned int seed) {
278  XPETRA_MONITOR("EpetraMultiVectorT::seedrandom");
279 
281  vec_->SetSeed(seed);
282  }
283 
284 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
285 
287 
298  template<class TargetDeviceType>
299  typename Kokkos::Impl::if_c<
300  Kokkos::Impl::is_same<
301  typename dual_view_type::t_dev_um::execution_space::memory_space,
302  typename TargetDeviceType::memory_space>::value,
303  typename dual_view_type::t_dev_um,
304  typename dual_view_type::t_host_um>::type
305  getLocalView () const {
306  return this->MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::template getLocalView<TargetDeviceType>();
307  }
308 
309  typename dual_view_type::t_host_um getHostLocalView () const {
310  typedef Kokkos::View< typename dual_view_type::t_host::data_type ,
311  Kokkos::LayoutLeft,
312  typename dual_view_type::t_host::device_type ,
313  Kokkos::MemoryUnmanaged> epetra_view_type;
314 
315  // access Epetra multivector data
316  double* data = NULL;
317  int myLDA;
318  vec_->ExtractView(&data, &myLDA);
319  int localLength = vec_->MyLength();
320  int numVectors = getNumVectors();
321 
322  // create view
323  epetra_view_type test = epetra_view_type(data, localLength, numVectors);
324  typename dual_view_type::t_host_um ret = subview(test, Kokkos::ALL(), Kokkos::ALL());
325 
326  return ret;
327  }
328 
329  typename dual_view_type::t_dev_um getDeviceLocalView() const {
330  throw std::runtime_error("Epetra does not support device views!");
331  typename dual_view_type::t_dev_um ret;
332  return ret; // make compiler happy
333  }
334 
335 #endif
336 
338 
339  protected:
342  virtual void
344 
345  private:
348 
349  }; // EpetraMultiVectorT class
350 
351 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
353 #endif
354 
355 #ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
357 #endif
358 
359 // Moving here from cpp since some compilers don't have public visibility of virtual thunks.
360 // https://software.sandia.gov/bugzilla/show_bug.cgi?id=6232
361 
362  template<class> class EpetraVectorT;
363 
364  template<class EpetraGlobalOrdinal>
366  //TODO: input argument 'NumVectors' is not necessary in both Xpetra and Tpetra interface. Should it be removed?
367 
368  const std::string tfecfFuncName("MultiVector(ArrayOfPtrs)");
369  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(NumVectors < 1 || NumVectors != Teuchos::as<size_t>(ArrayOfPtrs.size()), std::runtime_error,
370  ": ArrayOfPtrs.size() must be strictly positive and as large as ArrayOfPtrs.");
371 
372 #ifdef HAVE_XPETRA_DEBUG
373  // This cannot be tested by Epetra itself
374  {
375  size_t localLength = map->getNodeNumElements();
376  for(int j=0; j<ArrayOfPtrs.size(); j++) {
377  TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(Teuchos::as<size_t>(ArrayOfPtrs[j].size()) != localLength, std::runtime_error,
378  ": ArrayOfPtrs[" << j << "].size() (== " << ArrayOfPtrs[j].size() <<
379  ") is not equal to getLocalLength() (== " << localLength);
380 
381  }
382  }
383 #endif
384 
385  // Convert Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > to double**
386  Array<const double*> arrayOfRawPtrs(ArrayOfPtrs.size());
387  for(int i=0; i<ArrayOfPtrs.size(); i++) {
388  arrayOfRawPtrs[i] = ArrayOfPtrs[i].getRawPtr();
389  }
390  double** rawArrayOfRawPtrs = const_cast<double**>(arrayOfRawPtrs.getRawPtr()); // This const_cast should be fine, because Epetra_DataAccess=Copy.
391 
392  vec_ = Teuchos::rcp(new Epetra_MultiVector(Copy, toEpetra(map), rawArrayOfRawPtrs, NumVectors));
393  }
394 
395 
396  template<class EpetraGlobalOrdinal>
398  XPETRA_MONITOR("EpetraMultiVectorT::getVector");
399  return rcp(new EpetraVectorT<GlobalOrdinal>(vec_, j)); // See constructor EpetraVectorT(const RCP<EpetraMultiVectorT> &mv, size_t j) for more info
400  }
401 
402  template<class EpetraGlobalOrdinal>
404  XPETRA_MONITOR("EpetraMultiVectorT::getVector");
405  return rcp(new EpetraVectorT<GlobalOrdinal>(vec_, j)); // See constructor EpetraVectorT(const RCP<EpetraMultiVectorT> &mv, size_t j) for more info
406  }
407 
408  template<class EpetraGlobalOrdinal>
410  XPETRA_MONITOR("EpetraMultiVectorT::getData");
411 
412  double ** arrayOfPointers;
413 
414  vec_->ExtractView(&arrayOfPointers);
415 
416  double * data = arrayOfPointers[j];
417  int localLength = vec_->MyLength();
418 
419  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
420  }
421 
422  template<class EpetraGlobalOrdinal>
424  XPETRA_MONITOR("EpetraMultiVectorT::getDataNonConst");
425 
426  double ** arrayOfPointers;
427 
428  vec_->ExtractView(&arrayOfPointers);
429 
430  double * data = arrayOfPointers[j];
431  int localLength = vec_->MyLength();
432 
433  return ArrayRCP<double>(data, 0, localLength, false); // no ownership
434  }
435 
436  template<class EpetraGlobalOrdinal>
438  XPETRA_MONITOR("EpetraMultiVectorT::dot");
439 
440  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
441  vec_->Dot(*eA.getEpetra_MultiVector(), dots.getRawPtr());
442  }
443 
444  template<class EpetraGlobalOrdinal>
445  void EpetraMultiVectorT<EpetraGlobalOrdinal>::norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::norm1"); vec_->Norm1(norms.getRawPtr()); }
446 
447  template<class EpetraGlobalOrdinal>
448  void EpetraMultiVectorT<EpetraGlobalOrdinal>::norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::norm2"); vec_->Norm2(norms.getRawPtr()); }
449 
450  template<class EpetraGlobalOrdinal>
451  void EpetraMultiVectorT<EpetraGlobalOrdinal>::normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const { XPETRA_MONITOR("EpetraMultiVectorT::normInf"); vec_->NormInf(norms.getRawPtr()); }
452 
453  template<class EpetraGlobalOrdinal>
455  XPETRA_MONITOR("EpetraMultiVectorT::normWeighted");
456 
457  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, weights, eWeights, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
458  vec_->NormWeighted(*eWeights.getEpetra_MultiVector(), norms.getRawPtr());
459  }
460 
461  template<class EpetraGlobalOrdinal>
462  void EpetraMultiVectorT<EpetraGlobalOrdinal>::meanValue(const Teuchos::ArrayView<double> &means) const { XPETRA_MONITOR("EpetraMultiVectorT::meanValue"); vec_->MeanValue(means.getRawPtr()); } //TODO: modify ArrayView size ??
463 
464  template<class EpetraGlobalOrdinal>
466  XPETRA_MONITOR("EpetraMultiVectorT::description");
468  return "TODO";
469  }
470 
471  template<class EpetraGlobalOrdinal>
473  XPETRA_MONITOR("EpetraMultiVectorT::describe");
474  vec_->Print(out);
475  }
476 
477  template<class EpetraGlobalOrdinal>
479  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
480 
481  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
482  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
483 
484  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
485  int err = this->getEpetra_MultiVector()->Import(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
486  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
487  }
488 
489  template<class EpetraGlobalOrdinal>
491  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
492 
493  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
494  XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal>, importer, tImporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
495 
496  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
497  int err = this->getEpetra_MultiVector()->Export(*v, *tImporter.getEpetra_Import(), toEpetra(CM));
498  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
499  }
500 
501  template<class EpetraGlobalOrdinal>
503  XPETRA_MONITOR("EpetraMultiVectorT::doImport");
504 
505  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal>, source, tSource, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
506  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
507 
508  RCP<Epetra_MultiVector> v = tSource.getEpetra_MultiVector();
509  int err = this->getEpetra_MultiVector()->Import(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
510  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
511  }
512 
513  template<class EpetraGlobalOrdinal>
515  XPETRA_MONITOR("EpetraMultiVectorT::doExport");
516 
517  XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT<GlobalOrdinal>, dest, tDest, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraMultiVectorT as input arguments.");
518  XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal>, exporter, tExporter, "Xpetra::EpetraMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
519 
520  RCP<Epetra_MultiVector> v = tDest.getEpetra_MultiVector();
521  int err = this->getEpetra_MultiVector()->Export(*v, *tExporter.getEpetra_Export(), toEpetra(CM));
522  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
523  }
524 
525  template<class EpetraGlobalOrdinal>
527  int err = 0;
528  if (!map.is_null()) {
529  err = this->getEpetra_MultiVector()->ReplaceMap(toEpetra(map));
530 
531  } else {
532  // Replace map with a dummy map to avoid potential hangs later
533  Epetra_SerialComm SComm;
534  Epetra_Map NewMap((EpetraGlobalOrdinal) vec_->MyLength(), (EpetraGlobalOrdinal) vec_->Map().IndexBase64(), SComm);
535  err = this->getEpetra_MultiVector()->ReplaceMap(NewMap);
536  }
537  TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
538  }
539 
540  template<class EpetraGlobalOrdinal>
543  {
544  typedef EpetraMultiVectorT this_type;
545  const this_type* rhsPtr = dynamic_cast<const this_type*> (&rhs);
547  rhsPtr == NULL, std::invalid_argument, "Xpetra::MultiVector::operator=: "
548  "The left-hand side (LHS) of the assignment has a different type than "
549  "the right-hand side (RHS). The LHS has type Xpetra::EpetraMultiVectorT "
550  "(which means it wraps an Epetra_MultiVector), but the RHS has some "
551  "other type. This probably means that the RHS wraps a Tpetra::Multi"
552  "Vector. Xpetra::MultiVector does not currently implement assignment "
553  "from a Tpetra object to an Epetra object, though this could be added "
554  "with sufficient interest.");
555 
556  RCP<const Epetra_MultiVector> rhsImpl = rhsPtr->getEpetra_MultiVector ();
558 
560  rhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
561  "(in Xpetra::EpetraMultiVectorT::assign): *this (the right-hand side of "
562  "the assignment) has a null RCP<Epetra_MultiVector> inside. Please "
563  "report this bug to the Xpetra developers.");
565  lhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
566  "(in Xpetra::EpetraMultiVectorT::assign): The left-hand side of the "
567  "assignment has a null RCP<Epetra_MultiVector> inside. Please report "
568  "this bug to the Xpetra developers.");
569 
570  // Epetra_MultiVector's assignment operator does a deep copy.
571  *lhsImpl = *rhsImpl;
572  }
573 
574 
575 } // Xpetra namespace
576 
577 #include "Xpetra_EpetraVector.hpp" // to avoid incomplete type instantiated above in out-of-body functions.
578 
579 #endif // XPETRA_EPETRAMULTIVECTOR_HPP
size_t getLocalLength() const
Local number of rows on the calling process.
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...
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal > > &graph)
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.
EpetraMultiVectorT< int > EpetraMultiVector
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).
#define TEUCHOS_TEST_FOR_EXCEPTION_CLASS_FUNC(throw_exception_test, Exception, msg)
void abs(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input Multi-vector in target: A = abs(this).
void randomize(bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
RCP< Epetra_MultiVector > vec_
The Epetra_MultiVector which this class wraps.
#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
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.
Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this multivector.
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 norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
RCP< const CrsGraph< int, GlobalOrdinal > > toXpetra(const Epetra_CrsGraph &g)
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
MultiVector< double, int, GlobalOrdinal >::node_type Node
void update(const Scalar &alpha, const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update: this = beta*this + alpha*A.
void replaceMap(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map)
Replace the underlying Map in place.
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 doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Export.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
Exception throws when you call an unimplemented method of Xpetra.
T * getRawPtr() const
void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Import< LocalOrdinal, GlobalOrdinal, Node > &importer, CombineMode CM)
Import.
static void seedrandom(unsigned int s)
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
size_t global_size_t
Global size_t object.
static const EVerbosityLevel verbLevel_default
Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this multivector.
std::string description() const
A simple one-line description of this object.
EpetraMultiVectorT(const RCP< Epetra_MultiVector > &vec)
EpetraMultiVectorT constructor to wrap a Epetra_MultiVector object.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
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.
TypeTo as(const TypeFrom &t)
void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
Copy
void scale(Teuchos::ArrayView< const Scalar > alpha)
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
Teuchos::RCP< Vector< double, int, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
CombineMode
Xpetra::Combine Mode enumerable type.
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
#define XPETRA_MONITOR(funcName)
EpetraMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source)
MultiVector copy constructor.
EpetraMultiVectorT< long long > EpetraMultiVector64
void scale(const Scalar &alpha)
Scale in place: this = alpha*this.
EpetraMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Basic MultiVector constuctor.
size_t getNumVectors() const
Number of columns in the multivector.
void setSeed(unsigned int seed)
Set seed for Random function.
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.
virtual void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
void normWeighted(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights, const Teuchos::ArrayView< Teuchos::ScalarTraits< Scalar >::magnitudeType > &norms) const
global_size_t getGlobalLength() const
Global number of rows in the multivector.
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.
virtual ~EpetraMultiVectorT()
MultiVector destructor.
bool is_null() const