Anasazi  Version of the Day
AnasaziSpecializedEpetraAdapter.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 // USA
24 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
25 //
26 // ***********************************************************************
27 // @HEADER
28 
33 #ifndef ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
34 #define ANASAZI_SPECIALIZED_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 #include "AnasaziEpetraAdapter.hpp"
42 
43 #include "Teuchos_Assert.hpp"
45 #include "Teuchos_RCP.hpp"
46 #include "Epetra_MultiVector.h"
47 #include "Epetra_Vector.h"
48 #include "Epetra_Operator.h"
49 #include "Epetra_Map.h"
50 #include "Epetra_LocalMap.h"
51 
52 #if defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
53 # include <Tpetra_ConfigDefs.hpp> // HAVE_TPETRA_EPETRA
54 # if defined(HAVE_TPETRA_EPETRA)
55 # include <Epetra_TsqrAdaptor.hpp>
56 # endif // defined(HAVE_TPETRA_EPETRA)
57 #endif // defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
58 
59 namespace Anasazi {
60 
62 
63 
68  EpetraSpecializedMultiVecFailure(const std::string& what_arg) : AnasaziError(what_arg)
69  {}};
70 
72 
74  //
75  //--------template class AnasaziEpetraOpMultiVec-----------------
76  //
78 
85  class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraOpMultiVec : public MultiVec<double>, public EpetraMultiVecAccessor {
86  public:
88 
89 
91 
97  EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, const int numvecs);
98 
100 
109  EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, double * array, const int numvecs, const int stride=0);
110 
112 
118  EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, Epetra_DataAccess CV, const Epetra_MultiVector& P_vec, const std::vector<int>& index);
119 
121  EpetraOpMultiVec(const EpetraOpMultiVec& P_vec);
122 
124  virtual ~EpetraOpMultiVec() {};
125 
127 
129 
130 
135  MultiVec<double> * Clone ( const int numvecs ) const;
136 
142  MultiVec<double> * CloneCopy () const;
143 
151  MultiVec<double> * CloneCopy ( const std::vector<int>& index ) const;
152 
160  MultiVec<double> * CloneViewNonConst ( const std::vector<int>& index );
161 
169  const MultiVec<double> * CloneView ( const std::vector<int>& index ) const;
170 
172 
174  Teuchos::RCP<Epetra_MultiVector> GetEpetraMultiVector() { return Epetra_MV; }
175 
177 
178 
180  int GetVecLength () const { return Epetra_MV->GlobalLength(); }
181 
184  ptrdiff_t GetGlobalLength () const
185  {
186  if ( Epetra_MV->Map().GlobalIndicesLongLong() )
187  return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength64() );
188  else
189  return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength() );
190  }
191 
193  int GetNumberVecs () const { return Epetra_MV->NumVectors(); }
194 
196 
198 
199 
201  void MvTimesMatAddMv ( double alpha, const MultiVec<double>& A,
203  double beta );
204 
207  void MvAddMv ( double alpha, const MultiVec<double>& A,
208  double beta, const MultiVec<double>& B);
209 
212  void MvTransMv ( double alpha, const MultiVec<double>& A, Teuchos::SerialDenseMatrix<int,double>& B
213 #ifdef HAVE_ANASAZI_EXPERIMENTAL
214  , ConjType conj = Anasazi::CONJ
215 #endif
216  ) const;
217 
220  void MvDot ( const MultiVec<double>& A, std::vector<double> &b
221 #ifdef HAVE_ANASAZI_EXPERIMENTAL
222  , ConjType conj = Anasazi::CONJ
223 #endif
224  ) const;
225 
228  void MvScale ( double alpha ) {
229  TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Scale( alpha )!=0, EpetraSpecializedMultiVecFailure,
230  "Anasazi::EpetraOpMultiVec::MvScale call to Epetra_MultiVector::Scale() returned a nonzero value.");
231  }
232 
235  void MvScale ( const std::vector<double>& alpha );
236 
238 
240 
244  void MvNorm ( std::vector<double> & normvec ) const;
245 
247 
249 
250 
255  void SetBlock ( const MultiVec<double>& A, const std::vector<int>& index );
256 
259  void MvRandom() {
261  "Anasazi::EpetraOpMultiVec::MvRandom call to Epetra_MultiVector::Random() returned a nonzero value.");
262  }
263 
266  void MvInit ( double alpha ) {
267  TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->PutScalar( alpha )!=0, EpetraSpecializedMultiVecFailure,
268  "Anasazi::EpetraOpMultiVec::MvInit call to Epetra_MultiVector::PutScalar() returned a nonzero value.");
269  }
270 
272 
273 
275  Epetra_MultiVector* GetEpetraMultiVec() { return &*Epetra_MV; };
276 
278  const Epetra_MultiVector* GetEpetraMultiVec() const { return &*Epetra_MV; };
279 
281 
283 
285 
287  void MvPrint( std::ostream& os ) const { Epetra_MV->Print( os ); }
288 
290 
291  private:
292 //use pragmas to disable some false-positive warnings for windows
293 // sharedlibs export
294 #ifdef _MSC_VER
295 #pragma warning(push)
296 #pragma warning(disable:4251)
297 #endif
300  Teuchos::RCP<Epetra_MultiVector> Epetra_MV_Temp;
301 #ifdef _MSC_VER
302 #pragma warning(pop)
303 #endif
304  };
305 
306 
307 } // end of Anasazi namespace
308 
309 #endif // end of file ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
EpetraMultiVecAccessor is an interfaceto allow any Anasazi::MultiVec implementation that is based on ...
EpetraSpecializedMultiVecFailure is thrown when a return value from an Epetra call on an Epetra_Multi...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void MvInit(double alpha)
Replace each element of the vectors in *this with alpha.
int GetNumberVecs() const
Obtain the vector length of *this.
An exception class parent to all Anasazi exceptions.
Interface for multivectors used by Anasazi&#39; linear solvers.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
ConjType
Enumerated types used to specify conjugation arguments.
void MvScale(double alpha)
Scale each element of the vectors in *this with alpha.
Specialized adapter class for Anasazi::MultiVec that uses Epetra_MultiVector and Epetra_Operator to d...
const Epetra_MultiVector * GetEpetraMultiVec() const
Return the pointer to the Epetra_MultiVector object.
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
void MvPrint(std::ostream &os) const
Print *this EpetraOpMultiVec.
Epetra_MultiVector * GetEpetraMultiVec()
Return the pointer to the Epetra_MultiVector object.
Templated virtual class for creating operators that can interface with the Anasazi::OperatorTraits cl...
Types and exceptions used within Anasazi solvers and interfaces.
void MvRandom()
Fill the vectors in *this with random numbers.
int GetVecLength() const
Obtain the number of vectors in *this.
Interface for multivectors used by Anasazi&#39;s linear solvers.
Declarations of Anasazi multi-vector and operator classes using Epetra_MultiVector and Epetra_Operato...