Anasazi  Version of the Day
AnasaziEpetraAdapter.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Anasazi: Block Eigensolvers Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
25 //
26 // ***********************************************************************
27 // @HEADER
28 
33 #ifndef ANASAZI_EPETRA_ADAPTER_HPP
34 #define ANASAZI_EPETRA_ADAPTER_HPP
35 
36 #include "AnasaziConfigDefs.hpp"
37 #include "Anasaziepetra_DLLExportMacro.h"
38 #include "AnasaziTypes.hpp"
39 #include "AnasaziMultiVec.hpp"
40 #include "AnasaziOperator.hpp"
41 
42 #include "Teuchos_Assert.hpp"
44 #include "Epetra_MultiVector.h"
45 #include "Epetra_Vector.h"
46 #include "Epetra_Operator.h"
47 #include "Epetra_Map.h"
48 #include "Epetra_LocalMap.h"
49 
50 #if defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
51 # include <Tpetra_ConfigDefs.hpp> // HAVE_TPETRA_EPETRA
52 # if defined(HAVE_TPETRA_EPETRA)
53 # include <Epetra_TsqrAdaptor.hpp>
54 # endif // defined(HAVE_TPETRA_EPETRA)
55 #endif // defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
56 
57 namespace Anasazi {
58 
60 
61 
65  class EpetraMultiVecFailure : public AnasaziError {public:
66  EpetraMultiVecFailure(const std::string& what_arg) : AnasaziError(what_arg)
67  {}};
68 
72  class EpetraOpFailure : public AnasaziError {public:
73  EpetraOpFailure(const std::string& what_arg) : AnasaziError(what_arg)
74  {}};
75 
77 
79 
80 
85 
86  public:
89 
91  virtual Epetra_MultiVector* GetEpetraMultiVec() { return 0; }
92 
94  virtual const Epetra_MultiVector* GetEpetraMultiVec() const { return 0; }
95  };
96 
98 
100  //
101  //--------template class AnasaziEpetraMultiVec-----------------
102  //
104 
111  class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraMultiVec : public MultiVec<double>, public Epetra_MultiVector, public EpetraMultiVecAccessor {
112  public:
114 
115 
117 
122  EpetraMultiVec(const Epetra_BlockMap& Map_in, const int numvecs);
123 
125  EpetraMultiVec(const Epetra_MultiVector & P_vec);
126 
128 
136  EpetraMultiVec(const Epetra_BlockMap& Map_in, double * array, const int numvecs, const int stride=0);
137 
139 
145  EpetraMultiVec(Epetra_DataAccess CV, const Epetra_MultiVector& P_vec, const std::vector<int>& index);
146 
148  virtual ~EpetraMultiVec() {};
149 
151 
153 
154 
159  MultiVec<double> * Clone ( const int numvecs ) const;
160 
166  MultiVec<double> * CloneCopy () const;
167 
175  MultiVec<double> * CloneCopy ( const std::vector<int>& index ) const;
176 
184  MultiVec<double> * CloneViewNonConst ( const std::vector<int>& index );
185 
193  const MultiVec<double> * CloneView ( const std::vector<int>& index ) const;
194 
196 
198  ptrdiff_t GetGlobalLength () const
199  {
200  if ( Map().GlobalIndicesLongLong() )
201  return static_cast<ptrdiff_t>( GlobalLength64() );
202  else
203  return static_cast<ptrdiff_t>( GlobalLength() );
204  }
205 
208  int GetNumberVecs () const { return NumVectors(); }
209 
211 
213 
214 
216  void MvTimesMatAddMv ( double alpha, const MultiVec<double>& A,
218  double beta );
219 
222  void MvAddMv ( double alpha, const MultiVec<double>& A,
223  double beta, const MultiVec<double>& B);
224 
227  void MvTransMv ( double alpha, const MultiVec<double>& A, Teuchos::SerialDenseMatrix<int,double>& B
228 #ifdef HAVE_ANASAZI_EXPERIMENTAL
229  , ConjType conj = Anasazi::CONJ
230 #endif
231  ) const;
232 
235  void MvDot ( const MultiVec<double>& A, std::vector<double> &b
236 #ifdef HAVE_ANASAZI_EXPERIMENTAL
237  , ConjType conj = Anasazi::CONJ
238 #endif
239  ) const;
240 
243  void MvScale ( double alpha ) {
244  TEUCHOS_TEST_FOR_EXCEPTION( this->Scale( alpha )!=0, EpetraMultiVecFailure,
245  "Anasazi::EpetraMultiVec::MvScale call to Epetra_MultiVector::Scale() returned a nonzero value.");
246  }
247 
250  void MvScale ( const std::vector<double>& alpha );
251 
253 
255 
259  void MvNorm ( std::vector<double> & normvec ) const {
260  if (((int)normvec.size() >= GetNumberVecs()) ) {
261  TEUCHOS_TEST_FOR_EXCEPTION( this->Norm2(&normvec[0])!=0, EpetraMultiVecFailure,
262  "Anasazi::EpetraMultiVec::MvNorm call to Epetra_MultiVector::Norm2() returned a nonzero value.");
263  }
264  };
266 
268 
269 
274  void SetBlock ( const MultiVec<double>& A, const std::vector<int>& index );
275 
278  void MvRandom() {
280  "Anasazi::EpetraMultiVec::MvRandom call to Epetra_MultiVector::Random() returned a nonzero value.");
281  };
282 
285  void MvInit ( double alpha ) {
286  TEUCHOS_TEST_FOR_EXCEPTION( this->PutScalar( alpha )!=0, EpetraMultiVecFailure,
287  "Anasazi::EpetraMultiVec::MvInit call to Epetra_MultiVector::PutScalar() returned a nonzero value.");
288  };
289 
291 
292 
295 
297  const Epetra_MultiVector* GetEpetraMultiVec() const { return this; };
298 
300 
302 
304 
306  void MvPrint( std::ostream& os ) const { os << *this << std::endl; };
308 
309  private:
310  };
311  //-------------------------------------------------------------
312 
314  //
315  //--------template class AnasaziEpetraOp---------------------
316  //
318 
325  class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraOp : public virtual Operator<double> {
326  public:
328 
329 
332 
334  ~EpetraOp();
336 
338 
339 
343  void Apply ( const MultiVec<double>& X, MultiVec<double>& Y ) const;
345 
346  private:
347 //use pragmas to disable some false-positive warnings for windows
348 // sharedlibs export
349 #ifdef _MSC_VER
350 #pragma warning(push)
351 #pragma warning(disable:4251)
352 #endif
354 #ifdef _MSC_VER
355 #pragma warning(pop)
356 #endif
357  };
358  //-------------------------------------------------------------
359 
361  //
362  //--------template class AnasaziEpetraGenOp--------------------
363  //
365 
379  class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraGenOp : public virtual Operator<double>, public virtual Epetra_Operator {
380  public:
382 
387  bool isAInverse = true );
388 
390  ~EpetraGenOp();
391 
393 
395  void Apply ( const MultiVec<double>& X, MultiVec<double>& Y ) const;
396 
398 
400  int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
401 
403 
405  int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
406 
408  const char* Label() const { return "Epetra_Operator applying A^{-1}M"; };
409 
411  bool UseTranspose() const { return (false); };
412 
414  int SetUseTranspose(bool /*UseTranspose_in*/) { return 0; };
415 
417  bool HasNormInf() const { return (false); };
418 
420  double NormInf() const { return (-1.0); };
421 
423  const Epetra_Comm& Comm() const { return Epetra_AOp->Comm(); };
424 
426  const Epetra_Map& OperatorDomainMap() const { return Epetra_AOp->OperatorDomainMap(); };
427 
429  const Epetra_Map& OperatorRangeMap() const { return Epetra_AOp->OperatorRangeMap(); };
430 
431  private:
432  bool isAInverse;
433 
434 //use pragmas to disable some false-positive warnings for windows
435 // sharedlibs export
436 #ifdef _MSC_VER
437 #pragma warning(push)
438 #pragma warning(disable:4251)
439 #endif
442 #ifdef _MSC_VER
443 #pragma warning(pop)
444 #endif
445  };
446 
448  //
449  //--------template class AnasaziEpetraSymOp--------------------
450  //
452 
465  class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraSymOp : public virtual Operator<double>, public virtual Epetra_Operator {
466  public:
468 
470  EpetraSymOp(const Teuchos::RCP<Epetra_Operator> &Op, bool isTrans = false );
471 
473  ~EpetraSymOp();
474 
476 
478  void Apply ( const MultiVec<double>& X, MultiVec<double>& Y ) const;
479 
481 
483  int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
484 
486 
489  int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const;
490 
492  const char* Label() const { return "Epetra_Operator applying A^TA or AA^T"; };
493 
495  bool UseTranspose() const { return (false); };
496 
498  int SetUseTranspose(bool /*UseTranspose_in*/) { return 0; };
499 
501  bool HasNormInf() const { return (false); };
502 
504  double NormInf() const { return (-1.0); };
505 
507  const Epetra_Comm& Comm() const { return Epetra_Op->Comm(); };
508 
510  const Epetra_Map& OperatorDomainMap() const { return Epetra_Op->OperatorDomainMap(); };
511 
513  const Epetra_Map& OperatorRangeMap() const { return Epetra_Op->OperatorRangeMap(); };
514 
515  private:
516 
517 //use pragmas to disable false-positive warnings in generating windows sharedlib exports
518 #ifdef _MSC_VER
519 #pragma warning(push)
520 #pragma warning(disable:4251)
521 #endif
523 #ifdef _MSC_VER
524 #pragma warning(pop)
525 #endif
526 
527  bool isTrans_;
528  };
529 
530 
532  //
533  //--------template class AnasaziEpetraSymMVOp---------------------
534  //
536 
549  class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraSymMVOp : public virtual Operator<double> {
550  public:
552 
555  bool isTrans = false );
556 
559 
561 
563  void Apply ( const MultiVec<double>& X, MultiVec<double>& Y ) const;
564 
565  private:
566 
567 //use pragmas to disable some false-positive warnings for windows
568 // sharedlibs export
569 #ifdef _MSC_VER
570 #pragma warning(push)
571 #pragma warning(disable:4251)
572 #endif
574  Teuchos::RCP<const Epetra_Map> MV_localmap;
576 #ifdef _MSC_VER
577 #pragma warning(pop)
578 #endif
579 
580  bool isTrans_;
581  };
582 
584  //
585  //--------template class AnasaziEpetraWSymMVOp---------------------
586  //
588 
601  class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraWSymMVOp : public virtual Operator<double> {
602  public:
605  const Teuchos::RCP<Epetra_Operator> &OP );
606 
609 
611 
613  void Apply ( const MultiVec<double>& X, MultiVec<double>& Y ) const;
614 
615  private:
616 //use pragmas to disable some false-positive warnings for windows
617 // sharedlibs export
618 #ifdef _MSC_VER
619 #pragma warning(push)
620 #pragma warning(disable:4251)
621 #endif
625  Teuchos::RCP<const Epetra_Map> MV_localmap;
627 #ifdef _MSC_VER
628 #pragma warning(pop)
629 #endif
630  };
631 
633  //
634  //--------template class AnasaziEpetraW2SymMVOp---------------------
635  //
637 
650  class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraW2SymMVOp : public virtual Operator<double> {
651  public:
654  const Teuchos::RCP<Epetra_Operator> &OP );
655 
658 
660 
662  void Apply ( const MultiVec<double>& X, MultiVec<double>& Y ) const;
663 
664  private:
665 //use pragmas to disable some false-positive warnings for windows
666 // sharedlibs export
667 #ifdef _MSC_VER
668 #pragma warning(push)
669 #pragma warning(disable:4251)
670 #endif
674  Teuchos::RCP<const Epetra_Map> MV_localmap;
676 #ifdef _MSC_VER
677 #pragma warning(pop)
678 #endif
679  };
680 
681 
683  //
684  // Implementation of the Anasazi::MultiVecTraits for Epetra::MultiVector.
685  //
687 
698  template<>
700  {
701  public:
702 
704 
705 
711  Clone (const Epetra_MultiVector& mv, const int outNumVecs)
712  {
713  TEUCHOS_TEST_FOR_EXCEPTION(outNumVecs <= 0, std::invalid_argument,
714  "Belos::MultiVecTraits<double, Epetra_MultiVector>::"
715  "Clone(mv, outNumVecs = " << outNumVecs << "): "
716  "outNumVecs must be positive.");
717  // FIXME (mfh 13 Jan 2011) Anasazi currently lets Epetra fill in
718  // the entries of the returned multivector with zeros, but Belos
719  // does not. We retain this different behavior for now, but the
720  // two versions will need to be reconciled.
721  return Teuchos::rcp (new Epetra_MultiVector (mv.Map(), outNumVecs));
722  }
723 
730  {
731  return Teuchos::rcp (new Epetra_MultiVector (mv));
732  }
733 
740  CloneCopy (const Epetra_MultiVector& mv, const std::vector<int>& index)
741  {
742  const int inNumVecs = GetNumberVecs (mv);
743  const int outNumVecs = index.size();
744 
745  // Simple, inexpensive tests of the index vector.
746  TEUCHOS_TEST_FOR_EXCEPTION(outNumVecs == 0, std::invalid_argument,
747  "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::"
748  "CloneCopy(mv, index = {}): At least one vector must be"
749  " cloned from mv.");
750  if (outNumVecs > inNumVecs)
751  {
752  std::ostringstream os;
753  os << "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::"
754  "CloneCopy(mv, index = {";
755  for (int k = 0; k < outNumVecs - 1; ++k)
756  os << index[k] << ", ";
757  os << index[outNumVecs-1] << "}): There are " << outNumVecs
758  << " indices to copy, but only " << inNumVecs << " columns of mv.";
759  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
760  }
761 #ifdef TEUCHOS_DEBUG
762  // In debug mode, we perform more expensive tests of the index
763  // vector, to ensure all the elements are in range.
764  // Dereferencing the iterator is valid because index has length
765  // > 0.
766  const int minIndex = *std::min_element (index.begin(), index.end());
767  const int maxIndex = *std::max_element (index.begin(), index.end());
768 
769  if (minIndex < 0)
770  {
771  std::ostringstream os;
772  os << "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::"
773  "CloneCopy(mv, index = {";
774  for (int k = 0; k < outNumVecs - 1; ++k)
775  os << index[k] << ", ";
776  os << index[outNumVecs-1] << "}): Indices must be nonnegative, but "
777  "the smallest index " << minIndex << " is negative.";
778  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
779  }
780  if (maxIndex >= inNumVecs)
781  {
782  std::ostringstream os;
783  os << "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::"
784  "CloneCopy(mv, index = {";
785  for (int k = 0; k < outNumVecs - 1; ++k)
786  os << index[k] << ", ";
787  os << index[outNumVecs-1] << "}): Indices must be strictly less than "
788  "the number of vectors " << inNumVecs << " in mv; the largest index "
789  << maxIndex << " is out of bounds.";
790  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
791  }
792 #endif // TEUCHOS_DEBUG
793  // Cast to nonconst, because Epetra_MultiVector's constructor
794  // wants a nonconst int array argument. It doesn't actually
795  // change the entries of the array.
796  std::vector<int>& tmpind = const_cast< std::vector<int>& > (index);
797  return Teuchos::rcp (new Epetra_MultiVector (Epetra_DataAccess::Copy, mv, &tmpind[0], index.size()));
798  }
799 
801  CloneCopy (const Epetra_MultiVector& mv, const Teuchos::Range1D& index)
802  {
803  const int inNumVecs = GetNumberVecs (mv);
804  const int outNumVecs = index.size();
805  const bool validRange = outNumVecs > 0 && index.lbound() >= 0 &&
806  index.ubound() < inNumVecs;
807  if (! validRange)
808  {
809  std::ostringstream os;
810  os << "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::Clone(mv,"
811  "index=[" << index.lbound() << ", " << index.ubound() << "]): ";
812  TEUCHOS_TEST_FOR_EXCEPTION(outNumVecs == 0, std::invalid_argument,
813  os.str() << "Column index range must be nonempty.");
814  TEUCHOS_TEST_FOR_EXCEPTION(index.lbound() < 0, std::invalid_argument,
815  os.str() << "Column index range must be nonnegative.");
816  TEUCHOS_TEST_FOR_EXCEPTION(index.ubound() >= inNumVecs, std::invalid_argument,
817  os.str() << "Column index range must not exceed "
818  "number of vectors " << inNumVecs << " in the "
819  "input multivector.");
820  }
821  return Teuchos::rcp (new Epetra_MultiVector (Epetra_DataAccess::Copy, mv, index.lbound(), index.size()));
822  }
823 
830  CloneViewNonConst (Epetra_MultiVector& mv, const std::vector<int>& index)
831  {
832  const int inNumVecs = GetNumberVecs (mv);
833  const int outNumVecs = index.size();
834 
835  // Simple, inexpensive tests of the index vector.
836  TEUCHOS_TEST_FOR_EXCEPTION(outNumVecs == 0, std::invalid_argument,
837  "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::"
838  "CloneViewNonConst(mv, index = {}): The output view "
839  "must have at least one column.");
840  if (outNumVecs > inNumVecs)
841  {
842  std::ostringstream os;
843  os << "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::"
844  "CloneViewNonConst(mv, index = {";
845  for (int k = 0; k < outNumVecs - 1; ++k)
846  os << index[k] << ", ";
847  os << index[outNumVecs-1] << "}): There are " << outNumVecs
848  << " indices to view, but only " << inNumVecs << " columns of mv.";
849  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
850  }
851 #ifdef TEUCHOS_DEBUG
852  // In debug mode, we perform more expensive tests of the index
853  // vector, to ensure all the elements are in range.
854  // Dereferencing the iterator is valid because index has length
855  // > 0.
856  const int minIndex = *std::min_element (index.begin(), index.end());
857  const int maxIndex = *std::max_element (index.begin(), index.end());
858 
859  if (minIndex < 0)
860  {
861  std::ostringstream os;
862  os << "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::"
863  "CloneViewNonConst(mv, index = {";
864  for (int k = 0; k < outNumVecs - 1; ++k)
865  os << index[k] << ", ";
866  os << index[outNumVecs-1] << "}): Indices must be nonnegative, but "
867  "the smallest index " << minIndex << " is negative.";
868  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
869  }
870  if (maxIndex >= inNumVecs)
871  {
872  std::ostringstream os;
873  os << "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::"
874  "CloneViewNonConst(mv, index = {";
875  for (int k = 0; k < outNumVecs - 1; ++k)
876  os << index[k] << ", ";
877  os << index[outNumVecs-1] << "}): Indices must be strictly less than "
878  "the number of vectors " << inNumVecs << " in mv; the largest index "
879  << maxIndex << " is out of bounds.";
880  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
881  }
882 #endif // TEUCHOS_DEBUG
883  // Cast to nonconst, because Epetra_MultiVector's constructor
884  // wants a nonconst int array argument. It doesn't actually
885  // change the entries of the array.
886  std::vector<int>& tmpind = const_cast< std::vector<int>& > (index);
887  return Teuchos::rcp (new Epetra_MultiVector (Epetra_DataAccess::View, mv, &tmpind[0], index.size()));
888  }
889 
892  {
893  const bool validRange = index.size() > 0 &&
894  index.lbound() >= 0 &&
895  index.ubound() < mv.NumVectors();
896  if (! validRange)
897  {
898  std::ostringstream os;
899  os << "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::CloneView"
900  "NonConst(mv,index=[" << index.lbound() << ", " << index.ubound()
901  << "]): ";
902  TEUCHOS_TEST_FOR_EXCEPTION(index.size() == 0, std::invalid_argument,
903  os.str() << "Column index range must be nonempty.");
904  TEUCHOS_TEST_FOR_EXCEPTION(index.lbound() < 0, std::invalid_argument,
905  os.str() << "Column index range must be nonnegative.");
907  std::invalid_argument,
908  os.str() << "Column index range must not exceed "
909  "number of vectors " << mv.NumVectors() << " in "
910  "the input multivector.");
911  }
912  return Teuchos::rcp (new Epetra_MultiVector (Epetra_DataAccess::View, mv, index.lbound(), index.size()));
913  }
914 
921  CloneView (const Epetra_MultiVector& mv, const std::vector<int>& index)
922  {
923  const int inNumVecs = GetNumberVecs (mv);
924  const int outNumVecs = index.size();
925 
926  // Simple, inexpensive tests of the index vector.
927  TEUCHOS_TEST_FOR_EXCEPTION(outNumVecs == 0, std::invalid_argument,
928  "Belos::MultiVecTraits<double,Epetra_MultiVector>::"
929  "CloneView(mv, index = {}): The output view "
930  "must have at least one column.");
931  if (outNumVecs > inNumVecs)
932  {
933  std::ostringstream os;
934  os << "Belos::MultiVecTraits<double,Epetra_MultiVector>::"
935  "CloneView(mv, index = {";
936  for (int k = 0; k < outNumVecs - 1; ++k)
937  os << index[k] << ", ";
938  os << index[outNumVecs-1] << "}): There are " << outNumVecs
939  << " indices to view, but only " << inNumVecs << " columns of mv.";
940  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
941  }
942 #ifdef TEUCHOS_DEBUG
943  // In debug mode, we perform more expensive tests of the index
944  // vector, to ensure all the elements are in range.
945  // Dereferencing the iterator is valid because index has length
946  // > 0.
947  const int minIndex = *std::min_element (index.begin(), index.end());
948  const int maxIndex = *std::max_element (index.begin(), index.end());
949 
950  if (minIndex < 0)
951  {
952  std::ostringstream os;
953  os << "Belos::MultiVecTraits<double,Epetra_MultiVector>::"
954  "CloneView(mv, index = {";
955  for (int k = 0; k < outNumVecs - 1; ++k)
956  os << index[k] << ", ";
957  os << index[outNumVecs-1] << "}): Indices must be nonnegative, but "
958  "the smallest index " << minIndex << " is negative.";
959  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
960  }
961  if (maxIndex >= inNumVecs)
962  {
963  std::ostringstream os;
964  os << "Belos::MultiVecTraits<double,Epetra_MultiVector>::"
965  "CloneView(mv, index = {";
966  for (int k = 0; k < outNumVecs - 1; ++k)
967  os << index[k] << ", ";
968  os << index[outNumVecs-1] << "}): Indices must be strictly less than "
969  "the number of vectors " << inNumVecs << " in mv; the largest index "
970  << maxIndex << " is out of bounds.";
971  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
972  }
973 #endif // TEUCHOS_DEBUG
974  // Cast to nonconst, because Epetra_MultiVector's constructor
975  // wants a nonconst int array argument. It doesn't actually
976  // change the entries of the array.
977  std::vector<int>& tmpind = const_cast< std::vector<int>& > (index);
978  return Teuchos::rcp (new Epetra_MultiVector (Epetra_DataAccess::View, mv, &tmpind[0], index.size()));
979  }
980 
982  CloneView (const Epetra_MultiVector& mv, const Teuchos::Range1D& index)
983  {
984  const bool validRange = index.size() > 0 &&
985  index.lbound() >= 0 &&
986  index.ubound() < mv.NumVectors();
987  if (! validRange)
988  {
989  std::ostringstream os;
990  os << "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::CloneView"
991  "(mv,index=[" << index.lbound() << ", " << index.ubound()
992  << "]): ";
993  TEUCHOS_TEST_FOR_EXCEPTION(index.size() == 0, std::invalid_argument,
994  os.str() << "Column index range must be nonempty.");
995  TEUCHOS_TEST_FOR_EXCEPTION(index.lbound() < 0, std::invalid_argument,
996  os.str() << "Column index range must be nonnegative.");
998  std::invalid_argument,
999  os.str() << "Column index range must not exceed "
1000  "number of vectors " << mv.NumVectors() << " in "
1001  "the input multivector.");
1002  }
1003  return Teuchos::rcp (new Epetra_MultiVector(Epetra_DataAccess::View, mv, index.lbound(), index.size()));
1004  }
1005 
1007 
1009 
1010 
1012  static ptrdiff_t GetGlobalLength( const Epetra_MultiVector& mv )
1013  {
1014  if (mv.Map().GlobalIndicesLongLong())
1015  return static_cast<ptrdiff_t>( mv.GlobalLength64() );
1016  else
1017  return static_cast<ptrdiff_t>( mv.GlobalLength() );
1018  }
1019 
1021  static int GetNumberVecs( const Epetra_MultiVector& mv )
1022  { return mv.NumVectors(); }
1023 
1024  static bool HasConstantStride( const Epetra_MultiVector& mv )
1025  { return mv.ConstantStride(); }
1027 
1029 
1030 
1033  static void MvTimesMatAddMv( double alpha, const Epetra_MultiVector& A,
1035  double beta, Epetra_MultiVector& mv )
1036  {
1037  Epetra_LocalMap LocalMap(B.numRows(), 0, mv.Map().Comm());
1038  Epetra_MultiVector B_Pvec(Epetra_DataAccess::View, LocalMap, B.values(), B.stride(), B.numCols());
1039 
1040  TEUCHOS_TEST_FOR_EXCEPTION( mv.Multiply( 'N', 'N', alpha, A, B_Pvec, beta )!=0, EpetraMultiVecFailure,
1041  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvTimesMatAddMv call to Epetra_MultiVector::Multiply() returned a nonzero value.");
1042  }
1043 
1046  static void MvAddMv( double alpha, const Epetra_MultiVector& A, double beta, const Epetra_MultiVector& B, Epetra_MultiVector& mv )
1047  {
1048  // epetra mv.Update(alpha,A,beta,B,gamma) will check
1049  // alpha == 0.0
1050  // and
1051  // beta == 0.0
1052  // and based on this will call
1053  // mv.Update(beta,B,gamma)
1054  // or
1055  // mv.Update(alpha,A,gamma)
1056  //
1057  // mv.Update(alpha,A,gamma)
1058  // will then check for one of
1059  // gamma == 0
1060  // or
1061  // gamma == 1
1062  // or
1063  // alpha == 1
1064  // in that order. however, it will not look for the combination
1065  // alpha == 1 and gamma = 0
1066  // which is a common use case when we wish to assign
1067  // mv = A (in which case alpha == 1, beta == gamma == 0)
1068  // or
1069  // mv = B (in which case beta == 1, alpha == gamma == 0)
1070  //
1071  // therefore, we will check for these use cases ourselves
1072  if (beta == 0.0) {
1073  if (alpha == 1.0) {
1074  // assign
1075  mv = A;
1076  }
1077  else {
1078  // single update
1079  TEUCHOS_TEST_FOR_EXCEPTION( mv.Update( alpha, A, 0.0 )!=0, EpetraMultiVecFailure,
1080  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvAddMv call to Epetra_MultiVector::Update(alpha,A,0.0) returned a nonzero value.");
1081  }
1082  }
1083  else if (alpha == 0.0) {
1084  if (beta == 1.0) {
1085  // assign
1086  mv = B;
1087  }
1088  else {
1089  // single update
1091  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvAddMv call to Epetra_MultiVector::Update(beta,B,0.0) returned a nonzero value.");
1092  }
1093  }
1094  else {
1095  // double update
1096  TEUCHOS_TEST_FOR_EXCEPTION( mv.Update( alpha, A, beta, B, 0.0 )!=0, EpetraMultiVecFailure,
1097  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvAddMv call to Epetra_MultiVector::Update(alpha,A,beta,B,0.0) returned a nonzero value.");
1098  }
1099  }
1100 
1104 #ifdef HAVE_ANASAZI_EXPERIMENTAL
1105  , ConjType conj = Anasazi::CONJ
1106 #endif
1107  )
1108  {
1109  Epetra_LocalMap LocalMap(B.numRows(), 0, mv.Map().Comm());
1110  Epetra_MultiVector B_Pvec(Epetra_DataAccess::View, LocalMap, B.values(), B.stride(), B.numCols());
1111 
1112  TEUCHOS_TEST_FOR_EXCEPTION( B_Pvec.Multiply( 'T', 'N', alpha, A, mv, 0.0 )!=0, EpetraMultiVecFailure,
1113  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvTransMv call to Epetra_MultiVector::Multiply() returned a nonzero value.");
1114  }
1115 
1118  static void MvDot( const Epetra_MultiVector& A, const Epetra_MultiVector& B, std::vector<double> &b
1119 #ifdef HAVE_ANASAZI_EXPERIMENTAL
1120  , ConjType conj = Anasazi::CONJ
1121 #endif
1122  )
1123  {
1124 #ifdef TEUCHOS_DEBUG
1125  TEUCHOS_TEST_FOR_EXCEPTION(A.NumVectors() != B.NumVectors(),std::invalid_argument,
1126  "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::MvDot(A,B,b): A and B must have the same number of vectors.");
1127  TEUCHOS_TEST_FOR_EXCEPTION(b.size() != (unsigned int)A.NumVectors(),std::invalid_argument,
1128  "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::MvDot(A,B,b): b must have room for all dot products.");
1129 #endif
1131  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvDot(A,B,b) call to Epetra_MultiVector::Dot() returned a nonzero value.");
1132  }
1133 
1135 
1137 
1141  static void MvNorm( const Epetra_MultiVector& mv, std::vector<double> &normvec )
1142  {
1143 #ifdef TEUCHOS_DEBUG
1144  TEUCHOS_TEST_FOR_EXCEPTION((unsigned int)mv.NumVectors() != normvec.size(),std::invalid_argument,
1145  "Anasazi::MultiVecTraits<double,Epetra_MultiVector>::MvNorm(mv,normvec): normvec must be the same size of mv.");
1146 #endif
1148  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvNorm call to Epetra_MultiVector::Norm2() returned a nonzero value.");
1149  }
1150 
1152 
1154 
1155 
1157  static void
1159  const std::vector<int>& index,
1160  Epetra_MultiVector& mv)
1161  {
1162  const int inNumVecs = GetNumberVecs (A);
1163  const int outNumVecs = index.size();
1164 
1165  // FIXME (mfh 13 Jan 2011) Belos allows A to have more columns
1166  // than index.size(), in which case we just take the first
1167  // index.size() columns of A. Anasazi requires that A have the
1168  // same number of columns as index.size(). Changing Anasazi's
1169  // behavior should not break existing Anasazi solvers, but the
1170  // tests need to be done.
1171  if (inNumVecs != outNumVecs)
1172  {
1173  std::ostringstream os;
1174  os << "Belos::MultiVecTraits<double,Epetra_MultiVector>::"
1175  "SetBlock(A, mv, index = {";
1176  if (outNumVecs > 0)
1177  {
1178  for (int k = 0; k < outNumVecs - 1; ++k)
1179  os << index[k] << ", ";
1180  os << index[outNumVecs-1];
1181  }
1182  os << "}): A has only " << inNumVecs << " columns, but there are "
1183  << outNumVecs << " indices in the index vector.";
1184  TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument, os.str());
1185  }
1186  // Make a view of the columns of mv indicated by the index std::vector.
1188 
1189  // View of columns [0, outNumVecs-1] of the source multivector A.
1190  // If A has fewer columns than mv_view, then create a view of
1191  // the first outNumVecs columns of A.
1193  if (outNumVecs == inNumVecs)
1194  A_view = Teuchos::rcpFromRef (A); // Const, non-owning RCP
1195  else
1196  A_view = CloneView (A, Teuchos::Range1D(0, outNumVecs - 1));
1197 
1198  // Assignment calls Epetra_MultiVector::Assign(), which deeply
1199  // copies the data directly, ignoring the underlying
1200  // Epetra_Map(s). If A and mv don't have the same data
1201  // distribution (Epetra_Map), this may result in incorrect or
1202  // undefined behavior. Epetra_MultiVector::Update() also
1203  // ignores the Epetra_Maps, so we might as well just use the
1204  // (perhaps slightly cheaper) Assign() method via operator=().
1205  *mv_view = *A_view;
1206  }
1207 
1208  static void
1209  SetBlock (const Epetra_MultiVector& A,
1210  const Teuchos::Range1D& index,
1211  Epetra_MultiVector& mv)
1212  {
1213  const int numColsA = A.NumVectors();
1214  const int numColsMv = mv.NumVectors();
1215  // 'index' indexes into mv; it's the index set of the target.
1216  const bool validIndex = index.lbound() >= 0 && index.ubound() < numColsMv;
1217  // We can't take more columns out of A than A has.
1218  const bool validSource = index.size() <= numColsA;
1219 
1220  if (! validIndex || ! validSource)
1221  {
1222  std::ostringstream os;
1223  os << "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::SetBlock"
1224  "(A, index=[" << index.lbound() << ", " << index.ubound() << "], "
1225  "mv): ";
1226  TEUCHOS_TEST_FOR_EXCEPTION(index.lbound() < 0, std::invalid_argument,
1227  os.str() << "Range lower bound must be nonnegative.");
1228  TEUCHOS_TEST_FOR_EXCEPTION(index.ubound() >= numColsMv, std::invalid_argument,
1229  os.str() << "Range upper bound must be less than "
1230  "the number of columns " << numColsA << " in the "
1231  "'mv' output argument.");
1232  TEUCHOS_TEST_FOR_EXCEPTION(index.size() > numColsA, std::invalid_argument,
1233  os.str() << "Range must have no more elements than"
1234  " the number of columns " << numColsA << " in the "
1235  "'A' input argument.");
1236  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Should never get here!");
1237  }
1238 
1239  // View of columns [index.lbound(), index.ubound()] of the
1240  // target multivector mv. We avoid view creation overhead by
1241  // only creating a view if the index range is different than [0,
1242  // (# columns in mv) - 1].
1244  if (index.lbound() == 0 && index.ubound()+1 == numColsMv)
1245  mv_view = Teuchos::rcpFromRef (mv); // Non-const, non-owning RCP
1246  else
1247  mv_view = CloneViewNonConst (mv, index);
1248 
1249  // View of columns [0, index.size()-1] of the source multivector
1250  // A. If A has fewer columns than mv_view, then create a view
1251  // of the first index.size() columns of A.
1253  if (index.size() == numColsA)
1254  A_view = Teuchos::rcpFromRef (A); // Const, non-owning RCP
1255  else
1256  A_view = CloneView (A, Teuchos::Range1D(0, index.size()-1));
1257 
1258  // Assignment calls Epetra_MultiVector::Assign(), which deeply
1259  // copies the data directly, ignoring the underlying
1260  // Epetra_Map(s). If A and mv don't have the same data
1261  // distribution (Epetra_Map), this may result in incorrect or
1262  // undefined behavior. Epetra_MultiVector::Update() also
1263  // ignores the Epetra_Maps, so we might as well just use the
1264  // (perhaps slightly cheaper) Assign() method via operator=().
1265  *mv_view = *A_view;
1266  }
1267 
1268  static void
1269  Assign (const Epetra_MultiVector& A,
1270  Epetra_MultiVector& mv)
1271  {
1272  const int numColsA = GetNumberVecs (A);
1273  const int numColsMv = GetNumberVecs (mv);
1274  if (numColsA > numColsMv)
1275  {
1276  std::ostringstream os;
1277  os << "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::Assign"
1278  "(A, mv): ";
1279  TEUCHOS_TEST_FOR_EXCEPTION(numColsA > numColsMv, std::invalid_argument,
1280  os.str() << "Input multivector 'A' has "
1281  << numColsA << " columns, but output multivector "
1282  "'mv' has only " << numColsMv << " columns.");
1283  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error, "Should never get here!");
1284  }
1285  // View of the first [0, numColsA-1] columns of mv.
1287  if (numColsMv == numColsA)
1288  mv_view = Teuchos::rcpFromRef (mv); // Non-const, non-owning RCP
1289  else // numColsMv > numColsA
1290  mv_view = CloneView (mv, Teuchos::Range1D(0, numColsA - 1));
1291 
1292  // Assignment calls Epetra_MultiVector::Assign(), which deeply
1293  // copies the data directly, ignoring the underlying
1294  // Epetra_Map(s). If A and mv don't have the same data
1295  // distribution (Epetra_Map), this may result in incorrect or
1296  // undefined behavior. Epetra_MultiVector::Update() also
1297  // ignores the Epetra_Maps, so we might as well just use the
1298  // (perhaps slightly cheaper) Assign() method via operator=().
1299  *mv_view = A;
1300  }
1301 
1304  static void MvScale ( Epetra_MultiVector& mv, double alpha )
1305  {
1307  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvScale call to Epetra_MultiVector::Scale(mv,double alpha) returned a nonzero value.");
1308  }
1309 
1312  static void MvScale ( Epetra_MultiVector& mv, const std::vector<double>& alpha )
1313  {
1314  // Check to make sure the vector is as long as the multivector has columns.
1315  int numvecs = mv.NumVectors();
1316 #ifdef TEUCHOS_DEBUG
1317  TEUCHOS_TEST_FOR_EXCEPTION( alpha.size() != (unsigned int)numvecs, std::invalid_argument,
1318  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvScale(mv,vector alpha): size of alpha inconsistent with number of vectors in mv.")
1319 #endif
1320  for (int i=0; i<numvecs; i++) {
1321  TEUCHOS_TEST_FOR_EXCEPTION( mv(i)->Scale(alpha[i])!=0, EpetraMultiVecFailure,
1322  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvScale call to Epetra_MultiVector::Scale() returned a nonzero value.");
1323  }
1324  }
1325 
1328  static void MvRandom( Epetra_MultiVector& mv )
1329  {
1331  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvRandom call to Epetra_MultiVector::Random() returned a nonzero value.");
1332  }
1333 
1337  {
1339  "Anasazi::MultiVecTraits<double, Epetra_MultiVector>::MvInit call to Epetra_MultiVector::PutScalar() returned a nonzero value.");
1340  }
1341 
1343 
1345 
1346 
1349  static void MvPrint( const Epetra_MultiVector& mv, std::ostream& os )
1350  { os << mv << std::endl; }
1351 
1353 
1354 #if defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
1355 # if defined(HAVE_TPETRA_EPETRA)
1356  typedef Epetra::TsqrAdaptor tsqr_adaptor_type;
1362 # endif // defined(HAVE_TPETRA_EPETRA)
1363 #endif // defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
1364  };
1365 
1367  //
1368  // Implementation of the Anasazi::OperatorTraits for Epetra::Operator.
1369  //
1371 
1383  template <>
1385  {
1386  public:
1387 
1391  static void Apply ( const Epetra_Operator& Op,
1392  const Epetra_MultiVector& x,
1393  Epetra_MultiVector& y )
1394  {
1395 #ifdef TEUCHOS_DEBUG
1396  TEUCHOS_TEST_FOR_EXCEPTION(x.NumVectors() != y.NumVectors(),std::invalid_argument,
1397  "Anasazi::OperatorTraits<double,Epetra_MultiVector,Epetra_Operator>::Apply(Op,x,y): x and y must have the same number of columns.");
1398 #endif
1399  int ret = Op.Apply(x,y);
1401  "Anasazi::OperatorTraits<double,Epetra_Multivector,Epetra_Operator>::Apply(): Error in Epetra_Operator::Apply(). Code " << ret);
1402  }
1403 
1404  };
1405 
1406 } // end of Anasazi namespace
1407 
1408 #endif
1409 // end of file ANASAZI_EPETRA_ADAPTER_HPP
int Norm2(double *Result) const
void MvRandom()
Fill the vectors in *this with random numbers.
const Epetra_BlockMap & Map() const
int Dot(const Epetra_MultiVector &A, double *Result) const
Adapter class for creating an operators often used in solving generalized eigenproblems.
EpetraMultiVecAccessor is an interfaceto allow any Anasazi::MultiVec implementation that is based on ...
const Epetra_Comm & Comm() const
Returns the Epetra_Comm communicator associated with this operator.
ScalarType * values() const
bool ConstantStride() const
static void MvAddMv(double alpha, const Epetra_MultiVector &A, double beta, const Epetra_MultiVector &B, Epetra_MultiVector &mv)
Replace mv with .
void MvInit(double alpha)
Replace each element of the vectors in *this with alpha.
static void SetBlock(const Epetra_MultiVector &A, const std::vector< int > &index, Epetra_MultiVector &mv)
Copy the vectors in A to a set of vectors in mv indicated by the indices given in index...
virtual ~EpetraMultiVecAccessor()
Destructor.
Adapter class for creating a weighted symmetric operator from an Epetra_MultiVector and Epetra_Operat...
ptrdiff_t GetGlobalLength() const
The number of rows in the multivector.
static void MvInit(Epetra_MultiVector &mv, double alpha=Teuchos::ScalarTraits< double >::zero())
Replace each element of the vectors in mv with alpha.
int GlobalLength() const
int PutScalar(double ScalarConstant)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Virtual base class which defines basic traits for the operator type.
const char * Label() const
Returns a character string describing the operator.
virtual Epetra_MultiVector * GetEpetraMultiVec()
Return the pointer to the Epetra_MultiVector object.
static void MvPrint(const Epetra_MultiVector &mv, std::ostream &os)
Print the mv multi-vector to the os output stream.
static void MvRandom(Epetra_MultiVector &mv)
Replace the vectors in mv with random vectors.
static void MvTransMv(double alpha, const Epetra_MultiVector &A, const Epetra_MultiVector &mv, Teuchos::SerialDenseMatrix< int, double > &B)
Compute a dense matrix B through the matrix-matrix multiply .
static void Assign(const MV &A, MV &mv)
mv := A
bool UseTranspose() const
Returns the current UseTranspose setting [always false for this operator].
An exception class parent to all Anasazi exceptions.
double NormInf() const
Returns the infinity norm of the global matrix [not functional for this operator].
Interface for multivectors used by Anasazi&#39; linear solvers.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
Basic adapter class for Anasazi::Operator that uses Epetra_Operator.
static void MvDot(const Epetra_MultiVector &A, const Epetra_MultiVector &B, std::vector< double > &b)
Compute a vector b where the components are the individual dot-products of the i-th columns of A and ...
bool HasNormInf() const
Returns true if this object can provide an approximate inf-norm [always false for this operator]...
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const=0
double NormInf() const
Returns the infinity norm of the global matrix [not functional for this operator].
int Scale(double ScalarValue)
const Epetra_Comm & Comm() const
Returns the Epetra_Comm communicator associated with this operator.
ConjType
Enumerated types used to specify conjugation arguments.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
OrdinalType numRows() const
bool UseTranspose() const
Returns the current UseTranspose setting [always false for this operator].
static Teuchos::RCP< Epetra_MultiVector > CloneCopy(const Epetra_MultiVector &mv, const std::vector< int > &index)
Creates a new Epetra_MultiVector and copies the selected contents of mv into the new vector (deep cop...
Epetra_MultiVector * GetEpetraMultiVec()
Return the pointer to the Epetra_MultiVector object.
int GetNumberVecs() const
The number of vectors (i.e., columns) in the multivector.
const char * Label() const
Returns a character string describing the operator.
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
int NumVectors() const
static void MvScale(Epetra_MultiVector &mv, const std::vector< double > &alpha)
Scale each element of the i-th vector in mv with alpha[i].
static void MvTimesMatAddMv(double alpha, const Epetra_MultiVector &A, const Teuchos::SerialDenseMatrix< int, double > &B, double beta, Epetra_MultiVector &mv)
Update mv with .
Traits class which defines basic operations on multivectors.
static Teuchos::RCP< MV > CloneCopy(const MV &mv)
Creates a new MV and copies contents of mv into the new vector (deep copy).
static Teuchos::RCP< const Epetra_MultiVector > CloneView(const Epetra_MultiVector &mv, const std::vector< int > &index)
Creates a new const Epetra_MultiVector that shares the selected contents of mv (shallow copy)...
Adapter class for creating a weighted operator from an Epetra_MultiVector and Epetra_Operator.
virtual const Epetra_MultiVector * GetEpetraMultiVec() const
Return the pointer to the Epetra_MultiVector object.
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Ordinal ubound() const
const Epetra_Comm & Comm() const
static Teuchos::RCP< Epetra_MultiVector > Clone(const Epetra_MultiVector &mv, const int outNumVecs)
Creates a new empty Epetra_MultiVector containing numVecs columns.
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
void MvPrint(std::ostream &os) const
Print *this EpetraMultiVec.
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
Creates a new MV that shares the selected contents of mv (shallow copy).
Ordinal lbound() const
static ptrdiff_t GetGlobalLength(const Epetra_MultiVector &mv)
Obtain the vector length of mv.
int SetUseTranspose(bool)
If set true, the transpose of this operator will be applied [not functional for this operator]...
Adapter class for creating a symmetric operator from an Epetra_Operator.
static Teuchos::RCP< const MV > CloneView(const MV &mv, const std::vector< int > &index)
Creates a new const MV that shares the selected contents of mv (shallow copy).
const Epetra_MultiVector * GetEpetraMultiVec() const
Return the pointer to the Epetra_MultiVector object.
void MvScale(double alpha)
Scale each element of the vectors in *this with alpha.
static void MvScale(Epetra_MultiVector &mv, double alpha)
Scale each element of the vectors in mv with alpha.
static void SetBlock(const MV &A, const std::vector< int > &index, MV &mv)
Copy the vectors in A to a set of vectors in mv indicated by the indices given in index...
static void Apply(const Epetra_Operator &Op, const Epetra_MultiVector &x, Epetra_MultiVector &y)
This method takes the Epetra_MultiVector x and applies the Epetra_Operator Op to it resulting in the ...
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Templated virtual class for creating operators that can interface with the Anasazi::OperatorTraits cl...
int Multiply(char TransA, char TransB, double ScalarAB, const Epetra_MultiVector &A, const Epetra_MultiVector &B, double ScalarThis)
static Teuchos::RCP< Epetra_MultiVector > CloneViewNonConst(Epetra_MultiVector &mv, const std::vector< int > &index)
Creates a new Epetra_MultiVector that shares the selected contents of mv (shallow copy)...
Ordinal size() const
void MvNorm(std::vector< double > &normvec) const
Compute the 2-norm of each individual vector of *this. Upon return, normvec[i] holds the 2-norm of t...
EpetraMultiVecFailure is thrown when a return value from an Epetra call on an Epetra_MultiVector is n...
Types and exceptions used within Anasazi solvers and interfaces.
OrdinalType stride() const
Epetra_DataAccess
OrdinalType numCols() const
bool GlobalIndicesLongLong() const
Interface for multivectors used by Anasazi&#39;s linear solvers.
Adapter class for creating a symmetric operator from an Epetra_MultiVector.
static void MvNorm(const Epetra_MultiVector &mv, std::vector< double > &normvec)
Compute the 2-norm of each individual vector of mv. Upon return, normvec[i] holds the value of ...
static int GetNumberVecs(const Epetra_MultiVector &mv)
Obtain the number of vectors in mv.
static Teuchos::RCP< Epetra_MultiVector > CloneCopy(const Epetra_MultiVector &mv)
Creates a new Epetra_MultiVector and copies contents of mv into the new vector (deep copy)...
Anasazi&#39;s templated virtual class for constructing an operator that can interface with the OperatorTr...
virtual ~EpetraMultiVec()
Destructor.
int SetUseTranspose(bool)
If set true, the transpose of this operator will be applied [not functional for this operator]...
EpetraOpFailure is thrown when a return value from an Epetra call on an Epetra_Operator is non-zero...
Exceptions thrown to signal error in operator application.
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
Basic adapter class for Anasazi::MultiVec that uses Epetra_MultiVector.
bool HasNormInf() const
Returns true if this object can provide an approximate inf-norm [always false for this operator]...