Xpetra Version of the Day
Loading...
Searching...
No Matches
Xpetra_EpetraIntMultiVector.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_EPETRAINTMULTIVECTOR_HPP
47#define XPETRA_EPETRAINTMULTIVECTOR_HPP
48
50
51#include "Xpetra_ConfigDefs.hpp"
52#include "Xpetra_MultiVector.hpp"
53#include "Xpetra_Exceptions.hpp"
54
55#include "Xpetra_EpetraMap.hpp"
57#include "Epetra_IntMultiVector.h"
58
59namespace Xpetra {
60
61// TODO: move that elsewhere
62template<class GlobalOrdinal, class Node>
64
65template<class GlobalOrdinal, class Node>
66const Epetra_IntMultiVector & toEpetra(const MultiVector<int, int, GlobalOrdinal, Node> &);
67//
68
69 // stub implementation for EpetraIntMultiVectorT
70 template<class EpetraGlobalOrdinal, class Node>
72 : public MultiVector<int,int,EpetraGlobalOrdinal, Node>
73 {
74 typedef int Scalar;
75 typedef int LocalOrdinal;
76 typedef EpetraGlobalOrdinal GlobalOrdinal;
77
78 public:
79
81
82
84 EpetraIntMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut=true) {
86 "Xpetra::EpetraIntMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
87 }
88
92 "Xpetra::EpetraIntMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
93 }
94
98 "Xpetra::EpetraIntMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
99 }
100
103
105
107
108
110 void putScalar(const int &value) { }
111
113 void randomize(bool bUseXpetraImplementation = true) { XPETRA_MONITOR("EpetraIntMultiVectorT::randomize"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntMultiVectorT::randomize(): Functionnality not available in Epetra"); }
114
116 void randomize(const Scalar& minVal, const Scalar& maxVal, bool bUseXpetraImplementation = true) { XPETRA_MONITOR("EpetraIntMultiVectorT::randomize"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntMultiVectorT::randomize(): Functionnality not available in Epetra"); }
117
119
120 void setSeed(unsigned int seed) { XPETRA_MONITOR("EpetraIntMultiVectorT::setSeed");
122 "Xpetra::EpetraIntMultiVectorT::setSeed(): Functionnality not available in Epetra"); }
123
125
127
128
133
138
144
150
152
154
155
157 const Teuchos::ArrayView<int> &dots) const {
159 "This function is not implemented in Epetra_IntMultiVector");
160 }
161
164
168 "This function is not implemented in Epetra_IntMultiVector");
169 }
170
172 void scale(const int &alpha) { }
173
176 XPETRA_MONITOR("EpetraIntMultiVectorT::scale");
178 "Xpetra::EpetraIntMultiVectorT::scale(): Functionnality not available in Epetra");
179 }
180
182 void update(const int &alpha, const MultiVector<int,int,GlobalOrdinal,Node> &A, const int &beta) {
183 XPETRA_MONITOR("EpetraIntMultiVectorT::update");
185 "Xpetra::EpetraIntMultiVectorT::update(): Functionnality not available in Epetra");
186 }
187
189 void update(const int &alpha, const MultiVector<int,int,GlobalOrdinal,Node> &A, const int &beta, const MultiVector<int,int,GlobalOrdinal,Node> &B, const int &gamma) {
190 XPETRA_MONITOR("EpetraIntMultiVectorT::update");
192 "Xpetra::EpetraIntMultiVectorT::update(): Functionnality not available in Epetra");
193 }
194
197 XPETRA_MONITOR("EpetraIntMultiVectorT::norm1");
199 "Xpetra::EpetraIntMultiVectorT::norm1(): Functionnality not available in Epetra");
200 }
201
204 XPETRA_MONITOR("EpetraIntMultiVectorT::norm2");
206 "Xpetra::EpetraIntMultiVectorT::norm2(): Functionnality not available in Epetra"); }
207
210 XPETRA_MONITOR("EpetraIntMultiVectorT::normInf");
212 "Xpetra::EpetraIntMultiVectorT::normInf(): Functionnality not available in Epetra"); }
213
215 void meanValue(const Teuchos::ArrayView<int> &means) const {
216 XPETRA_MONITOR("EpetraIntMultiVectorT::meanValue");
218 "Xpetra::EpetraIntMultiVectorT::meanValue(): Functionnality not available in Epetra");
219 }
220
222 void maxValue(const Teuchos::ArrayView<int> &maxs) const {
223 XPETRA_MONITOR("EpetraIntMultiVectorT::maxValue");
225 "Xpetra::EpetraIntMultiVectorT::maxValue(): Functionnality not available in Epetra");
226 }
227
229 void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const int &alpha, const MultiVector<int,int,GlobalOrdinal,Node> &A, const MultiVector<int,int,GlobalOrdinal,Node> &B, const int &beta) {
230 XPETRA_MONITOR("EpetraIntMultiVectorT::multiply");
232 "Xpetra::EpetraIntMultiVectorT::multiply(): Functionnality not available in Epetra");
233 }
234
237 XPETRA_MONITOR("EpetraIntMultiVectorT::elementWiseMultiply");
239 "Xpetra_EpetraIntMultiVector: elementWiseMultiply not implemented because Epetra_IntMultiVector does not support this operation");
240 }
241
243
245
246
248 void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
249 XPETRA_MONITOR("EpetraIntMultiVectorT::replaceGlobalValue");
251 }
252
254 void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
255 XPETRA_MONITOR("EpetraIntMultiVectorT::sumIntoGlobalValue");
257 }
258
260 void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
261 XPETRA_MONITOR("EpetraIntMultiVectorT::replaceLocalValue");
263 }
264
266 void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
267 XPETRA_MONITOR("EpetraIntMultiVectorT::sumIntoLocalValue");
269 }
270
272
274
275
277 size_t getNumVectors() const { XPETRA_MONITOR("EpetraIntMultiVectorT::getNumVectors"); return 1; }
278
279
281 size_t getLocalLength() const { return 0; }
282
284 global_size_t getGlobalLength() const { return 0; }
285
287 bool isSameSize(const MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> & vec) const { return false; }
288
290
292
293
295 std::string description() const {
296 return std::string("");
297 }
298
301
303
305
306 const RCP<const Comm<int> > getComm() const {
307 TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO getComm Epetra MultiVector not implemented");
308 }
309
310 // Implementing DistObject
312 return Teuchos::null;
313 }
314
317
320
323
326
328 // do nothing
329 }
330
331 protected:
334 virtual void
337
338
339 private:
341 //RCP< Epetra_IntMultiVector > vec_;
342
343 }; // class EpetraIntMultiVectorT
344
345 // specialization on GO=int and Node=Serial
346#ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
347 template<>
349 : public virtual MultiVector<int,int,int,EpetraNode>
350 {
351 typedef int Scalar;
352 typedef int LocalOrdinal;
353 typedef int GlobalOrdinal;
355
356 public:
357
359
360
362 EpetraIntMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut=true) {
363 vec_ = rcp(new Epetra_IntMultiVector(toEpetra<GlobalOrdinal,Node>(map), NumVectors, zeroOut));
364 }
365
368
369 if (copyOrView==Teuchos::Copy)
371 else {
372 int* indices = new int [getNumVectors()];
373 for (size_t i = 0; i < getNumVectors(); i++)
374 indices[i] = i;
376 delete [] indices;
377 }
378 }
379
381 EpetraIntMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &/* map */, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &/* ArrayOfPtrs */, size_t /* NumVectors */) {
383 "Xpetra::EpetraIntMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
384 }
385
388
390
392
393
395 void putScalar(const int &value) {
396 int ierr = 0;
397 ierr = vec_->PutScalar(value);
398 TEUCHOS_TEST_FOR_EXCEPTION(ierr != 0, Xpetra::Exceptions::RuntimeError, "Epetra_IntMultiVector::PutScalar returned an error.")
399 }
400
402 void randomize(bool /* bUseXpetraImplementation */ = true) { XPETRA_MONITOR("EpetraIntMultiVectorT::randomize"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntMultiVectorT::randomize(): Functionnality not available in Epetra"); }
403
405 void randomize(const Scalar& minVal, const Scalar& maxVal, bool bUseXpetraImplementation = true) { XPETRA_MONITOR("EpetraIntMultiVectorT::randomize"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntMultiVectorT::randomize(): Functionnality not available in Epetra"); }
406
407
409
410 void setSeed(unsigned int /* seed */) { XPETRA_MONITOR("EpetraIntMultiVectorT::setSeed"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntMultiVectorT::setSeed(): Functionnality not available in Epetra"); }
411
413
414 typename dual_view_type::t_host_const_um getHostLocalView (Access::ReadOnlyStruct) const override { return getHostLocalView(Access::ReadWrite); }
415
416 typename dual_view_type::t_dev_const_um getDeviceLocalView(Access::ReadOnlyStruct) const override { return getDeviceLocalView(Access::ReadWrite); }
417
418 typename dual_view_type::t_host_um getHostLocalView (Access::OverwriteAllStruct) const override { return getHostLocalView(Access::ReadWrite); }
419
420 typename dual_view_type::t_dev_um getDeviceLocalView(Access::OverwriteAllStruct) const override { return getDeviceLocalView(Access::ReadWrite); }
421
422 typename dual_view_type::t_host_um getHostLocalView (Access::ReadWriteStruct) const override {
423 typedef Kokkos::View< typename dual_view_type::t_host::data_type ,
424 Kokkos::LayoutLeft,
425 typename dual_view_type::t_host::device_type ,
426 Kokkos::MemoryUnmanaged> epetra_view_type;
427 // access Epetra multivector data
428 Scalar* data = NULL;
429 int myLDA;
430 vec_->ExtractView(&data, &myLDA);
431 int localLength = vec_->MyLength();
432 int numVectors = getNumVectors();
433
434 // create view
435 epetra_view_type test = epetra_view_type(data, localLength, numVectors);
436 typename dual_view_type::t_host_um ret = subview(test, Kokkos::ALL(), Kokkos::ALL());
437
438 return ret;
439 }
440
441 typename dual_view_type::t_dev_um getDeviceLocalView(Access::ReadWriteStruct) const override { return getHostLocalView(Access::ReadWrite); }
442
444
446
447
452
457
461 XPETRA_MONITOR("EpetraIntMultiVectorT::getData");
462
463 int ** arrayOfPointers;
464 vec_->ExtractView(&arrayOfPointers);
465 int * data = arrayOfPointers[j];
466 int localLength = vec_->MyLength();
467
468 return ArrayRCP<int>(data, 0, localLength, false); // not ownership
469 }
470
474 XPETRA_MONITOR("EpetraIntMultiVectorT::getDataNonConst");
475
476 int ** arrayOfPointers;
477 vec_->ExtractView(&arrayOfPointers);
478 int * data = arrayOfPointers[j];
479 int localLength = vec_->MyLength();
480
481 return ArrayRCP<int>(data, 0, localLength, false); // not ownership
482 }
483
485
487
488
490 const Teuchos::ArrayView<int> &/* dots */) const {
491 XPETRA_MONITOR("EpetraIntMultiVectorT::dot");
492
493 //XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
495 "This function is not implemented in Epetra_IntMultiVector");
496 }
497
500 XPETRA_MONITOR("EpetraIntMultiVectorT::abs");
502 "This function is not available in Epetra_IntMultiVector");
503 }
504
507 XPETRA_MONITOR("EpetraIntMultiVectorT::reciprocal");
508
509 //XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
510 TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::RuntimeError, "The reciprocal of an IntMultiVector is not defined!");
511 }
512
514 void scale(const int &/* alpha */) {
515 XPETRA_MONITOR("EpetraIntMultiVectorT::scale");
517 }
518
521 XPETRA_MONITOR("EpetraIntMultiVectorT::scale");
523 }
524
526 void update(const int &/* alpha */, const MultiVector<int,int,GlobalOrdinal,Node> &/* A */, const int &/* beta */) {
527 XPETRA_MONITOR("EpetraIntMultiVectorT::update");
528
529 // XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
531 }
532
534 void update(const int &/* alpha */, const MultiVector<int,int,GlobalOrdinal,Node> &/* A */, const int &/* beta */, const MultiVector<int,int,GlobalOrdinal,Node> &/* B */, const int &/* gamma */) {
535 XPETRA_MONITOR("EpetraIntMultiVectorT::update");
536
537 //XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
538 //XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, B, eB, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
540 }
541
544
547
550
552 void meanValue(const Teuchos::ArrayView<int> &/* means */) const { XPETRA_MONITOR("EpetraIntMultiVectorT::meanValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
553
555 void maxValue(const Teuchos::ArrayView<int> &/* maxs */) const { XPETRA_MONITOR("EpetraIntMultiVectorT::maxValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
556
558 void multiply(Teuchos::ETransp /* transA */, Teuchos::ETransp /* transB */, const int &/* alpha */, const MultiVector<int,int,GlobalOrdinal,Node> &/* A */, const MultiVector<int,int,GlobalOrdinal,Node> &/* B */, const int &/* beta */) { XPETRA_MONITOR("EpetraIntMultiVectorT::multiply"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Not available in Epetra"); }
559
561 void elementWiseMultiply(int /* scalarAB */, const Vector<int,int,GlobalOrdinal,Node> &/* A */, const MultiVector<int,int,GlobalOrdinal,Node> &/* B */, int /* scalarThis */) {
562 XPETRA_MONITOR("EpetraIntMultiVectorT::elementWiseMultiply");
563 TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra_EpetraIntMultiVector: elementWiseMultiply not implemented because Epetra_IntMultiVector does not support this operation");
564 }
565
567
569
570
572 void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
573 vec_->ReplaceGlobalValue(globalRow, vectorIndex, value);
574 }
575
577 void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
578 vec_->SumIntoGlobalValue(globalRow, vectorIndex, value);
579 }
580
582 void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
583 vec_->ReplaceMyValue(myRow, vectorIndex, value);
584 }
585
587 void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
588 vec_->SumIntoMyValue(myRow, vectorIndex, value);
589 }
590
592
594
595
597 size_t getNumVectors() const {
598 return vec_->NumVectors();
599 }
600
601
603 size_t getLocalLength() const {
604 return vec_->MyLength();
605 }
606
608 global_size_t getGlobalLength() const { return vec_->GlobalLength64(); }
609
612 XPETRA_MONITOR("EpetraIntMultiVectorT::isSameSize");
613 auto vv = toEpetra<GlobalOrdinal,Node>(vec);
614 return ( (getLocalLength() == Teuchos::as<size_t>(vv.MyLength())) &&
615 (getNumVectors() == Teuchos::as<size_t>(vv.NumVectors())));
616 }
617
619
621
622
624 std::string description() const {
625 XPETRA_MONITOR("EpetraIntMultiVectorT::description");
626
627 // This implementation come from Epetra_Vector_def.hpp (without modification)
628 std::ostringstream oss;
630 oss << "{length="<<this->getGlobalLength()
631 << "}";
632 return oss.str();
633 }
634
637 XPETRA_MONITOR("EpetraIntMultiVectorT::describe");
638
639 // This implementation come from Tpetra_Vector_def.hpp (without modification) // JG: true?
640 using std::endl;
641 using std::setw;
643 using Teuchos::VERB_NONE;
644 using Teuchos::VERB_LOW;
646 using Teuchos::VERB_HIGH;
648
649 if (verbLevel > Teuchos::VERB_NONE)
650 vec_->Print(out);
651 }
652
654
656
657 const RCP<const Comm<int> > getComm() const {
658 TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO getComm Epetra MultiVector not implemented");
659 }
660
661 // Implementing DistObject
666
668 const Import<int, GlobalOrdinal, Node> &importer, CombineMode CM) {
669 XPETRA_MONITOR("EpetraIntMultiVectorT::doImport");
670
671 XPETRA_DYNAMIC_CAST(const EpetraIntMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraIntMultiVectorT as input arguments.");
672 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
673
674 const Epetra_IntMultiVector & v = *tSource.getEpetra_IntMultiVector();
675 int err = vec_->Import(v, *tImporter.getEpetra_Import(), toEpetra(CM));
676 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
677 }
678
680 const Import<int, GlobalOrdinal, Node>& importer, CombineMode CM) {
681 XPETRA_MONITOR("EpetraIntMultiVectorT::doExport");
682
683 XPETRA_DYNAMIC_CAST(const EpetraIntMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraIntMultiVectorT as input arguments.");
684 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
685
686 const Epetra_IntMultiVector & v = *tDest.getEpetra_IntMultiVector();
687 int err = vec_->Import(v, *tImporter.getEpetra_Import(), toEpetra(CM));
688 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
689 }
690
692 const Export<int, GlobalOrdinal, Node>& exporter, CombineMode CM) {
693 XPETRA_MONITOR("EpetraIntMultiVectorT::doImport");
694
695 XPETRA_DYNAMIC_CAST(const EpetraIntMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraIntMultiVectorT as input arguments.");
696 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
697
698 const Epetra_IntMultiVector & v = *tSource.getEpetra_IntMultiVector();
699 int err = vec_->Import(v, *tExporter.getEpetra_Export(), toEpetra(CM));
700 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
701 }
702
704 const Export<int, GlobalOrdinal, Node>& exporter, CombineMode CM) {
705 XPETRA_MONITOR("EpetraIntMultiVectorT::doExport");
706
707 XPETRA_DYNAMIC_CAST(const EpetraIntMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraIntMultiVectorT as input arguments.");
708 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
709
710 const Epetra_IntMultiVector & v = *tDest.getEpetra_IntMultiVector();
711 int err = vec_->Export(v, *tExporter.getEpetra_Export(), toEpetra(CM));
712 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
713 }
714
716 XPETRA_MONITOR("EpetraIntMultiVectorT::replaceMap");
717 int err = 0;
718 if (!map.is_null()) {
719 err = this->getEpetra_IntMultiVector()->ReplaceMap(toEpetra<GlobalOrdinal,Node>(map));
720
721 } else {
722 // Replace map with a dummy map to avoid potential hangs later
723 Epetra_SerialComm SComm;
724 Epetra_Map NewMap((GlobalOrdinal) vec_->MyLength(), (GlobalOrdinal) vec_->Map().IndexBase64(), SComm);
725 err = this->getEpetra_IntMultiVector()->ReplaceMap(NewMap);
726 }
727 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
728 }
729
730 protected:
733 virtual void
735 {
737 const this_type* rhsPtr = dynamic_cast<const this_type*> (&rhs);
739 rhsPtr == NULL, std::invalid_argument, "Xpetra::MultiVector::operator=: "
740 "The left-hand side (LHS) of the assignment has a different type than "
741 "the right-hand side (RHS). The LHS has type Xpetra::EpetraIntMultiVectorT "
742 "(which means it wraps an Epetra_IntMultiVector), but the RHS has some "
743 "other type. This probably means that the RHS wraps either an "
744 "Tpetra::MultiVector, or an Epetra_MultiVector. Xpetra::MultiVector "
745 "does not currently implement assignment from a Tpetra object to an "
746 "Epetra object, though this could be added with sufficient interest.");
747
748 RCP<const Epetra_IntMultiVector> rhsImpl = rhsPtr->getEpetra_IntMultiVector ();
750
752 rhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
753 "(in Xpetra::EpetraIntMultiVectorT::assign): *this (the right-hand side of "
754 "the assignment) has a null RCP<Epetra_IntMultiVector> inside. Please "
755 "report this bug to the Xpetra developers.");
757 lhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
758 "(in Xpetra::EpetraIntMultiVectorT::assign): The left-hand side of the "
759 "assignment has a null RCP<Epetra_IntMultiVector> inside. Please report "
760 "this bug to the Xpetra developers.");
761
762 // Epetra_IntMultiVector's assignment operator does a deep copy.
763 *lhsImpl = *rhsImpl;
764 }
765
766
767 private:
770 };
771#endif
772
773 // specialization on GO=long long and Node=Serial
774#ifndef XPETRA_EPETRA_NO_64BIT_GLOBAL_INDICES
775 template<>
777 : public virtual MultiVector<int,int,long long,EpetraNode>
778 {
779 typedef int Scalar;
780 typedef int LocalOrdinal;
781 typedef long long GlobalOrdinal;
783
784 public:
785
787
788
790 EpetraIntMultiVectorT(const Teuchos::RCP<const Map<LocalOrdinal, GlobalOrdinal, Node> > &map, size_t NumVectors, bool zeroOut=true) {
791 vec_ = rcp(new Epetra_IntMultiVector(toEpetra<GlobalOrdinal,Node>(map), NumVectors, zeroOut));
792 }
793
798
800 EpetraIntMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &/* map */, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &/* ArrayOfPtrs */, size_t /* NumVectors */) {
802 "Xpetra::EpetraIntMultiVector only available for GO=int or GO=long long with EpetraNode (Serial or OpenMP depending on configuration)");
803 }
804
807
809
811
812
814 void putScalar(const int &value) {
815 int ierr = 0;
816 ierr = vec_->PutScalar(value);
817 TEUCHOS_TEST_FOR_EXCEPTION(ierr != 0, Xpetra::Exceptions::RuntimeError, "Epetra_IntMultiVector::PutScalar returns a non zero error.");
818 }
819
821 void randomize(bool /* bUseXpetraImplementation */ = true) { XPETRA_MONITOR("EpetraIntMultiVectorT::randomize"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntMultiVectorT::randomize(): Functionnality not available in Epetra"); }
822
824 void randomize(const Scalar& minVal, const Scalar& maxVal, bool bUseXpetraImplementation = true) { XPETRA_MONITOR("EpetraIntMultiVectorT::randomize"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntMultiVectorT::randomize(): Functionnality not available in Epetra"); }
825
826
828
829 void setSeed(unsigned int /* seed */) { XPETRA_MONITOR("EpetraIntMultiVectorT::setSeed"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra::EpetraIntMultiVectorT::setSeed(): Functionnality not available in Epetra"); }
830
832
834
835
840
845
849 XPETRA_MONITOR("EpetraIntMultiVectorT::getData");
850
851 int ** arrayOfPointers;
852 vec_->ExtractView(&arrayOfPointers);
853 int * data = arrayOfPointers[j];
854 int localLength = vec_->MyLength();
855
856 return ArrayRCP<int>(data, 0, localLength, false); // not ownership
857 }
858
862 XPETRA_MONITOR("EpetraIntMultiVectorT::getDataNonConst");
863
864 int ** arrayOfPointers;
865 vec_->ExtractView(&arrayOfPointers);
866 int * data = arrayOfPointers[j];
867 int localLength = vec_->MyLength();
868
869 return ArrayRCP<int>(data, 0, localLength, false); // not ownership
870 }
871
873
875
876
878 const Teuchos::ArrayView<int> &/* dots */) const {
879 XPETRA_MONITOR("EpetraIntMultiVectorT::dot");
880
881 //XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
883 }
884
887 XPETRA_MONITOR("EpetraIntMultiVectorT::abs");
889 "This function is not available in Epetra_IntMultiVector");
890 }
891
894 XPETRA_MONITOR("EpetraIntMultiVectorT::reciprocal");
896 "This function is not implemented in Epetra_IntMultiVector");
897 }
898
900 void scale(const int &/* alpha */) {
901 XPETRA_MONITOR("EpetraIntMultiVectorT::scale");
903 }
904
907 XPETRA_MONITOR("EpetraIntMultiVectorT::scale");
909 }
910
912 void update(const int &/* alpha */, const MultiVector<int,int,GlobalOrdinal,Node> &/* A */, const int &/* beta */) {
913 XPETRA_MONITOR("EpetraIntMultiVectorT::update");
914
915 // XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
917 }
918
920 void update(const int &/* alpha */, const MultiVector<int,int,GlobalOrdinal,Node> &/* A */, const int &/* beta */, const MultiVector<int,int,GlobalOrdinal,Node> &/* B */, const int &/* gamma */) {
921 XPETRA_MONITOR("EpetraIntMultiVectorT::update");
922
923 //XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, A, eA, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
924 //XPETRA_DYNAMIC_CAST(const EpetraMultiVectorT, B, eB, "This Xpetra::EpetraMultiVectorT method only accept Xpetra::EpetraMultiVectorT as input arguments.");
926 }
927
930
933
936
938 void meanValue(const Teuchos::ArrayView<int> &/* means */) const { XPETRA_MONITOR("EpetraIntMultiVectorT::meanValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
939
941 void maxValue(const Teuchos::ArrayView<int> &/* maxs */) const { XPETRA_MONITOR("EpetraIntMultiVectorT::maxValue"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO"); }
942
944 void multiply(Teuchos::ETransp /* transA */, Teuchos::ETransp /* transB */, const int &/* alpha */, const MultiVector<int,int,GlobalOrdinal,Node> &/* A */, const MultiVector<int,int,GlobalOrdinal,Node> &/* B */, const int &/* beta */) { XPETRA_MONITOR("EpetraIntMultiVectorT::multiply"); TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Not available in Epetra"); }
945
947 void elementWiseMultiply(int /* scalarAB */, const Vector<int,int,GlobalOrdinal,Node> &/* A */, const MultiVector<int,int,GlobalOrdinal,Node> &/* B */, int /* scalarThis */) {
948 XPETRA_MONITOR("EpetraIntMultiVectorT::elementWiseMultiply");
949 TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "Xpetra_EpetraIntMultiVector: elementWiseMultiply not implemented because Epetra_IntMultiVector does not support this operation");
950 }
951
953
955
956
958 void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
959 vec_->ReplaceGlobalValue(globalRow, vectorIndex, value);
960 }
961
963 void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value) {
964 vec_->SumIntoGlobalValue(globalRow, vectorIndex, value);
965 }
966
968 void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
969 vec_->ReplaceMyValue(myRow, vectorIndex, value);
970 }
971
973 void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value) {
974 vec_->SumIntoMyValue(myRow, vectorIndex, value);
975 }
976
978
980
981
983 size_t getNumVectors() const {
984 return vec_->NumVectors();
985 }
986
987
989 size_t getLocalLength() const { return vec_->MyLength(); }
990
992 global_size_t getGlobalLength() const { return vec_->GlobalLength64(); }
993
994
997 XPETRA_MONITOR("EpetraIntMultiVectorT::isSameSize");
998 auto vv = toEpetra<GlobalOrdinal, Node>(vec);
999 return ( (getLocalLength() == Teuchos::as<size_t>(vv.MyLength())) &&
1000 (getNumVectors() == Teuchos::as<size_t>(vv.NumVectors())));
1001 }
1002
1003
1005
1006
1008 std::string description() const {
1009 XPETRA_MONITOR("EpetraIntMultiVectorT::description");
1010
1011 // This implementation come from Epetra_Vector_def.hpp (without modification)
1012 std::ostringstream oss;
1014 oss << "{length="<<this->getGlobalLength()
1015 << "}";
1016 return oss.str();
1017 }
1018
1021 XPETRA_MONITOR("EpetraIntMultiVectorT::describe");
1022
1023 // This implementation come from Tpetra_Vector_def.hpp (without modification) // JG: true?
1024 using std::endl;
1025 using std::setw;
1027 using Teuchos::VERB_NONE;
1028 using Teuchos::VERB_LOW;
1030 using Teuchos::VERB_HIGH;
1032
1033 if (verbLevel > Teuchos::VERB_NONE)
1034 vec_->Print(out);
1035 }
1036
1038
1040
1042 TEUCHOS_TEST_FOR_EXCEPTION(1, Xpetra::Exceptions::NotImplemented, "TODO getComm Epetra MultiVector not implemented");
1043 }
1044
1045 // Implementing DistObject
1050
1052 const Import<int, GlobalOrdinal, Node> &importer, CombineMode CM) {
1053 XPETRA_MONITOR("EpetraIntMultiVectorT::doImport");
1054
1055 XPETRA_DYNAMIC_CAST(const EpetraIntMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraIntMultiVectorT as input arguments.");
1056 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1057
1058 const Epetra_IntMultiVector & v = *tSource.getEpetra_IntMultiVector();
1059 int err = vec_->Import(v, *tImporter.getEpetra_Import(), toEpetra(CM));
1060 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1061 }
1062
1064 const Import<int, GlobalOrdinal, Node>& importer, CombineMode CM) {
1065 XPETRA_MONITOR("EpetraIntMultiVectorT::doExport");
1066
1067 XPETRA_DYNAMIC_CAST(const EpetraIntMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraIntMultiVectorT as input arguments.");
1068 XPETRA_DYNAMIC_CAST(const EpetraImportT<GlobalOrdinal XPETRA_COMMA Node>, importer, tImporter, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1069
1070 const Epetra_IntMultiVector & v = *tDest.getEpetra_IntMultiVector();
1071 int err = vec_->Import(v, *tImporter.getEpetra_Import(), toEpetra(CM));
1072 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1073 }
1074
1076 const Export<int, GlobalOrdinal, Node>& exporter, CombineMode CM) {
1077 XPETRA_MONITOR("EpetraIntMultiVectorT::doImport");
1078
1079 XPETRA_DYNAMIC_CAST(const EpetraIntMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, source, tSource, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraIntMultiVectorT as input arguments.");
1080 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1081
1082 const Epetra_IntMultiVector & v = *tSource.getEpetra_IntMultiVector();
1083 int err = vec_->Import(v, *tExporter.getEpetra_Export(), toEpetra(CM));
1084 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1085 }
1086
1088 const Export<int, GlobalOrdinal, Node>& exporter, CombineMode CM) {
1089 XPETRA_MONITOR("EpetraIntMultiVectorT::doExport");
1090
1091 XPETRA_DYNAMIC_CAST(const EpetraIntMultiVectorT<GlobalOrdinal XPETRA_COMMA Node>, dest, tDest, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraIntMultiVectorT as input arguments.");
1092 XPETRA_DYNAMIC_CAST(const EpetraExportT<GlobalOrdinal XPETRA_COMMA Node>, exporter, tExporter, "Xpetra::EpetraIntMultiVectorT::doImport only accept Xpetra::EpetraImportT as input arguments.");
1093
1094 const Epetra_IntMultiVector & v = *tDest.getEpetra_IntMultiVector();
1095 int err = vec_->Export(v, *tExporter.getEpetra_Export(), toEpetra(CM));
1096 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1097 }
1098
1100 XPETRA_MONITOR("EpetraIntMultiVectorT::replaceMap");
1101 int err = 0;
1102 if (!map.is_null()) {
1103 err = this->getEpetra_IntMultiVector()->ReplaceMap(toEpetra<GlobalOrdinal,Node>(map));
1104
1105 } else {
1106 // Replace map with a dummy map to avoid potential hangs later
1107 Epetra_SerialComm SComm;
1108 Epetra_Map NewMap((GlobalOrdinal) vec_->MyLength(), (GlobalOrdinal) vec_->Map().IndexBase64(), SComm);
1109 err = this->getEpetra_IntMultiVector()->ReplaceMap(NewMap);
1110 }
1111 TEUCHOS_TEST_FOR_EXCEPTION(err != 0, std::runtime_error, "Catch error code returned by Epetra.");
1112 }
1113
1114 protected:
1117 virtual void
1119 {
1121 const this_type* rhsPtr = dynamic_cast<const this_type*> (&rhs);
1123 rhsPtr == NULL, std::invalid_argument, "Xpetra::MultiVector::operator=: "
1124 "The left-hand side (LHS) of the assignment has a different type than "
1125 "the right-hand side (RHS). The LHS has type Xpetra::EpetraIntMultiVectorT "
1126 "(which means it wraps an Epetra_IntMultiVector), but the RHS has some "
1127 "other type. This probably means that the RHS wraps either an "
1128 "Tpetra::MultiVector, or an Epetra_MultiVector. Xpetra::MultiVector "
1129 "does not currently implement assignment from a Tpetra object to an "
1130 "Epetra object, though this could be added with sufficient interest.");
1131
1132 RCP<const Epetra_IntMultiVector> rhsImpl = rhsPtr->getEpetra_IntMultiVector ();
1134
1136 rhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
1137 "(in Xpetra::EpetraIntMultiVectorT::assign): *this (the right-hand side of "
1138 "the assignment) has a null RCP<Epetra_IntMultiVector> inside. Please "
1139 "report this bug to the Xpetra developers.");
1141 lhsImpl.is_null (), std::logic_error, "Xpetra::MultiVector::operator= "
1142 "(in Xpetra::EpetraIntMultiVectorT::assign): The left-hand side of the "
1143 "assignment has a null RCP<Epetra_IntMultiVector> inside. Please report "
1144 "this bug to the Xpetra developers.");
1145
1146 // Epetra_IntMultiVector's assignment operator does a deep copy.
1147 *lhsImpl = *rhsImpl;
1148 }
1149
1150
1151 private:
1154 };
1155#endif
1156
1157
1158} // namespace Xpetra
1159
1160#endif // XPETRA_EPETRAINTMULTIVECTOR_HPP
View
#define XPETRA_MONITOR(funcName)
#define XPETRA_DYNAMIC_CAST(type, obj, newObj, exceptionMsg)
static const EVerbosityLevel verbLevel_default
virtual std::string description() const
bool is_null() const
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t) const
Return a Vector which is a const view of column j.
void update(const int &, const MultiVector< int, int, GlobalOrdinal, Node > &, const int &, const MultiVector< int, int, GlobalOrdinal, Node > &, const int &)
Update multi-vector with scaled values of A and B, this = gamma*this + alpha*A + beta*B.
EpetraIntMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &, size_t)
Set multi-vector values from array of pointers using Teuchos memory management classes....
void reciprocal(const MultiVector< int, int, GlobalOrdinal, Node > &)
Puts element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,...
dual_view_type::t_dev_um getDeviceLocalView(Access::ReadWriteStruct) const override
std::string description() const
Return a simple one-line description of this object.
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< int >::magnitudeType > &) const
Compute 1-norm of each vector in multi-vector.
Teuchos::RCP< const Map< int, GlobalOrdinal, Node > > getMap() const
The Map describing the parallel distribution of this object.
virtual void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t)
Return a Vector which is a nonconst view of column j.
void randomize(bool=true)
Set multi-vector values to random numbers.
void doExport(const DistObject< int, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< int, GlobalOrdinal, Node > &importer, CombineMode CM)
void doImport(const DistObject< int, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< int, GlobalOrdinal, Node > &exporter, CombineMode CM)
void multiply(Teuchos::ETransp, Teuchos::ETransp, const int &, const MultiVector< int, int, GlobalOrdinal, Node > &, const MultiVector< int, int, GlobalOrdinal, Node > &, const int &)
Matrix-Matrix multiplication, this = beta*this + alpha*op(A)*op(B).
void doExport(const DistObject< int, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< int, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export data into this object using an Export object ("forward mode").
dual_view_type::t_host_const_um getHostLocalView(Access::ReadOnlyStruct) const override
void update(const int &, const MultiVector< int, int, GlobalOrdinal, Node > &, const int &)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
dual_view_type::t_dev_const_um getDeviceLocalView(Access::ReadOnlyStruct) const override
void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< int >::magnitudeType > &) const
Compute Inf-norm of each vector in multi-vector.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
RCP< Epetra_IntMultiVector > vec_
The Epetra_IntMultiVector which this class wraps.
dual_view_type::t_host_um getHostLocalView(Access::OverwriteAllStruct) const override
void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< int >::magnitudeType > &) const
Compute 2-norm of each vector in multi-vector.
void scale(Teuchos::ArrayView< const int >)
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
dual_view_type::t_host_um getHostLocalView(Access::ReadWriteStruct) const override
size_t getNumVectors() const
Returns the number of vectors in the multi-vector.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
dual_view_type::t_dev_um getDeviceLocalView(Access::OverwriteAllStruct) const override
void elementWiseMultiply(int, const Vector< int, int, GlobalOrdinal, Node > &, const MultiVector< int, int, GlobalOrdinal, Node > &, int)
Element-wise multiply of a Vector A with a EpetraMultiVector B.
Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::dual_view_type dual_view_type
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation=true)
Set multi-vector values to random numbers.
void setSeed(unsigned int)
Set seed for Random function.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
void doImport(const DistObject< int, int, GlobalOrdinal, Node > &source, const Import< int, GlobalOrdinal, Node > &importer, CombineMode CM)
Import data into this object using an Import object ("forward mode").
EpetraIntMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Sets all vector entries to zero.
void scale(const int &)
Scale the current values of a multi-vector, this = alpha*this.
void replaceMap(const RCP< const Map< int, GlobalOrdinal, Node > > &map)
void maxValue(const Teuchos::ArrayView< int > &) const
Compute max value of each vector in multi-vector.
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 replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
EpetraIntMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::DataAccess copyOrView=Teuchos::Copy)
MultiVector copy constructor.
global_size_t getGlobalLength() const
Returns the global vector length of vectors in the multi-vector.
void meanValue(const Teuchos::ArrayView< int > &) const
Compute mean (average) value of each vector in multi-vector.
void dot(const MultiVector< int, int, GlobalOrdinal, Node > &, const Teuchos::ArrayView< int > &) const
Computes dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
void putScalar(const int &value)
Initialize all values in a multi-vector with specified value.
void abs(const MultiVector< int, int, GlobalOrdinal, Node > &)
Puts element-wise absolute values of input Multi-vector in target: A = abs(this).
Teuchos::ArrayRCP< const int > getData(size_t j) const
size_t getLocalLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation=true)
Set multi-vector values to random numbers.
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
void dot(const MultiVector< int, int, GlobalOrdinal, Node > &, const Teuchos::ArrayView< int > &) const
Computes dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
void maxValue(const Teuchos::ArrayView< int > &) const
Compute max value of each vector in multi-vector.
global_size_t getGlobalLength() const
Returns the global vector length of vectors in the multi-vector.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
void putScalar(const int &value)
Initialize all values in a multi-vector with specified value.
void reciprocal(const MultiVector< int, int, GlobalOrdinal, Node > &)
Puts element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,...
void doImport(const DistObject< int, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< int, GlobalOrdinal, Node > &exporter, CombineMode CM)
size_t getLocalLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
void scale(const int &)
Scale the current values of a multi-vector, this = alpha*this.
void elementWiseMultiply(int, const Vector< int, int, GlobalOrdinal, Node > &, const MultiVector< int, int, GlobalOrdinal, Node > &, int)
Element-wise multiply of a Vector A with a EpetraMultiVector B.
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 norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< int >::magnitudeType > &) const
Compute 2-norm of each vector in multi-vector.
void abs(const MultiVector< int, int, GlobalOrdinal, Node > &)
Puts element-wise absolute values of input Multi-vector in target: A = abs(this).
void replaceMap(const RCP< const Map< int, GlobalOrdinal, Node > > &map)
void doImport(const DistObject< int, int, GlobalOrdinal, Node > &source, const Import< int, GlobalOrdinal, Node > &importer, CombineMode CM)
Import data into this object using an Import object ("forward mode").
Teuchos::RCP< const Map< int, GlobalOrdinal, Node > > getMap() const
The Map describing the parallel distribution of this object.
void scale(Teuchos::ArrayView< const int >)
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
EpetraIntMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Sets all vector entries to zero.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
EpetraIntMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &, const Teuchos::ArrayView< const Teuchos::ArrayView< const Scalar > > &, size_t)
Set multi-vector values from array of pointers using Teuchos memory management classes....
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
void meanValue(const Teuchos::ArrayView< int > &) const
Compute mean (average) value of each vector in multi-vector.
void setSeed(unsigned int)
Set seed for Random function.
RCP< Epetra_IntMultiVector > vec_
The Epetra_IntMultiVector which this class wraps.
void doExport(const DistObject< int, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< int, GlobalOrdinal, Node > &importer, CombineMode CM)
virtual void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
void update(const int &, const MultiVector< int, int, GlobalOrdinal, Node > &, const int &, const MultiVector< int, int, GlobalOrdinal, Node > &, const int &)
Update multi-vector with scaled values of A and B, this = gamma*this + alpha*A + beta*B.
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< int >::magnitudeType > &) const
Compute 1-norm of each vector in multi-vector.
std::string description() const
Return a simple one-line description of this object.
size_t getNumVectors() const
Returns the number of vectors in the multi-vector.
void randomize(bool=true)
Set multi-vector values to random numbers.
void update(const int &, const MultiVector< int, int, GlobalOrdinal, Node > &, const int &)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t)
Return a Vector which is a nonconst view of column j.
void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< int >::magnitudeType > &) const
Compute Inf-norm of each vector in multi-vector.
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
EpetraIntMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source)
MultiVector copy constructor.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t) const
Return a Vector which is a const view of column j.
void doExport(const DistObject< int, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< int, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export data into this object using an Export object ("forward mode").
void multiply(Teuchos::ETransp, Teuchos::ETransp, const int &, const MultiVector< int, int, GlobalOrdinal, Node > &, const MultiVector< int, int, GlobalOrdinal, Node > &, const int &)
Matrix-Matrix multiplication, this = beta*this + alpha*op(A)*op(B).
std::string description() const
Return a simple one-line description of this object.
void setSeed(unsigned int seed)
Set seed for Random function.
void update(const int &alpha, const MultiVector< int, int, GlobalOrdinal, Node > &A, const int &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
size_t getLocalLength() const
Returns the local vector length on the calling processor of vectors in the multi-vector.
void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
void norm1(const Teuchos::ArrayView< Teuchos::ScalarTraits< int >::magnitudeType > &norms) const
Compute 1-norm of each vector in multi-vector.
void meanValue(const Teuchos::ArrayView< int > &means) const
Compute mean (average) value of each vector in multi-vector.
Teuchos::RCP< const Map< int, GlobalOrdinal, Node > > getMap() const
The Map describing the parallel distribution of this object.
Teuchos::RCP< const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
size_t getNumVectors() const
Returns the number of vectors in the multi-vector.
void doExport(const DistObject< int, LocalOrdinal, GlobalOrdinal, Node > &dest, const Import< int, GlobalOrdinal, Node > &importer, CombineMode CM)
EpetraIntMultiVectorT(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source, const Teuchos::DataAccess copyOrView=Teuchos::Copy)
MultiVector copy constructor.
void abs(const MultiVector< int, int, GlobalOrdinal, Node > &A)
Puts element-wise absolute values of input Multi-vector in target: A = abs(this).
void randomize(const Scalar &minVal, const Scalar &maxVal, bool bUseXpetraImplementation=true)
Set multi-vector values to random numbers.
EpetraIntMultiVectorT(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....
Teuchos::ArrayRCP< int > getDataNonConst(size_t j)
void putScalar(const int &value)
Initialize all values in a multi-vector with specified value.
void maxValue(const Teuchos::ArrayView< int > &maxs) const
Compute max value of each vector in multi-vector.
void normInf(const Teuchos::ArrayView< Teuchos::ScalarTraits< int >::magnitudeType > &norms) const
Compute Inf-norm of each vector in multi-vector.
EpetraIntMultiVectorT(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, size_t NumVectors, bool zeroOut=true)
Sets all vector entries to zero.
void replaceMap(const RCP< const Map< int, GlobalOrdinal, Node > > &map)
void norm2(const Teuchos::ArrayView< Teuchos::ScalarTraits< int >::magnitudeType > &norms) const
Compute 2-norm of each vector in multi-vector.
void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
void reciprocal(const MultiVector< int, int, GlobalOrdinal, Node > &A)
Puts element-wise reciprocal values of input Multi-vector in target, this(i,j) = 1/A(i,...
void multiply(Teuchos::ETransp transA, Teuchos::ETransp transB, const int &alpha, const MultiVector< int, int, GlobalOrdinal, Node > &A, const MultiVector< int, int, GlobalOrdinal, Node > &B, const int &beta)
Matrix-Matrix multiplication, this = beta*this + alpha*op(A)*op(B).
void doImport(const DistObject< int, int, GlobalOrdinal, Node > &source, const Import< int, GlobalOrdinal, Node > &importer, CombineMode CM)
Import data into this object using an Import object ("forward mode").
void elementWiseMultiply(int scalarAB, const Vector< int, int, GlobalOrdinal, Node > &A, const MultiVector< int, int, GlobalOrdinal, Node > &B, int scalarThis)
Element-wise multiply of a Vector A with a EpetraMultiVector B.
const RCP< const Comm< int > > getComm() const
void dot(const MultiVector< int, int, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< int > &dots) const
Computes dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
void doExport(const DistObject< int, LocalOrdinal, GlobalOrdinal, Node > &dest, const Export< int, GlobalOrdinal, Node > &exporter, CombineMode CM)
Export data into this object using an Export object ("forward mode").
void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.
Teuchos::ArrayRCP< const int > getData(size_t j) const
global_size_t getGlobalLength() const
Returns the global vector length of vectors in the multi-vector.
void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
void scale(const int &alpha)
Scale the current values of a multi-vector, this = alpha*this.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
virtual void assign(const MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
Teuchos::RCP< Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
void scale(Teuchos::ArrayView< const int > alpha)
Scale the current values of a multi-vector, this[j] = alpha[j]*this[j].
RCP< Epetra_IntMultiVector > getEpetra_IntMultiVector() const
void update(const int &alpha, const MultiVector< int, int, GlobalOrdinal, Node > &A, const int &beta, const MultiVector< int, int, GlobalOrdinal, Node > &B, const int &gamma)
Update multi-vector with scaled values of A and B, this = gamma*this + alpha*A + beta*B.
void randomize(bool bUseXpetraImplementation=true)
Set multi-vector values to random numbers.
void doImport(const DistObject< int, LocalOrdinal, GlobalOrdinal, Node > &source, const Export< int, GlobalOrdinal, Node > &exporter, CombineMode CM)
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.
Exception throws when you call an unimplemented method of Xpetra.
Exception throws to report errors in the internal logical of the program.
Kokkos::DualView< impl_scalar_type **, Kokkos::LayoutStride, typename node_type::device_type, Kokkos::MemoryUnmanaged > dual_view_type
virtual dual_view_type::t_host_const_um getHostLocalView(Access::ReadOnlyStruct) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
TypeTo as(const TypeFrom &t)
basic_FancyOStream< char > FancyOStream
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
constexpr struct ReadWriteStruct ReadWrite
Xpetra namespace
Tpetra::KokkosCompat::KokkosSerialWrapperNode EpetraNode
size_t global_size_t
Global size_t object.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal, Node > > &graph)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
CombineMode
Xpetra::Combine Mode enumerable type.