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., 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_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"
44 #include "Teuchos_SerialDenseMatrix.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  ptrdiff_t GetGlobalLength () const
181  {
182  if ( Epetra_MV->Map().GlobalIndicesLongLong() )
183  return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength64() );
184  else
185  return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength() );
186  }
187 
189  int GetNumberVecs () const { return Epetra_MV->NumVectors(); }
190 
192 
194 
195 
197  void MvTimesMatAddMv ( double alpha, const MultiVec<double>& A,
198  const Teuchos::SerialDenseMatrix<int,double>& B,
199  double beta );
200 
203  void MvAddMv ( double alpha, const MultiVec<double>& A,
204  double beta, const MultiVec<double>& B);
205 
208  void MvTransMv ( double alpha, const MultiVec<double>& A, Teuchos::SerialDenseMatrix<int,double>& B
209 #ifdef HAVE_ANASAZI_EXPERIMENTAL
210  , ConjType conj = Anasazi::CONJ
211 #endif
212  ) const;
213 
216  void MvDot ( const MultiVec<double>& A, std::vector<double> &b
217 #ifdef HAVE_ANASAZI_EXPERIMENTAL
218  , ConjType conj = Anasazi::CONJ
219 #endif
220  ) const;
221 
224  void MvScale ( double alpha ) {
225  TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Scale( alpha )!=0, EpetraSpecializedMultiVecFailure,
226  "Anasazi::EpetraOpMultiVec::MvScale call to Epetra_MultiVector::Scale() returned a nonzero value.");
227  }
228 
231  void MvScale ( const std::vector<double>& alpha );
232 
234 
236 
240  void MvNorm ( std::vector<double> & normvec ) const;
241 
243 
245 
246 
251  void SetBlock ( const MultiVec<double>& A, const std::vector<int>& index );
252 
255  void MvRandom() {
256  TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Random()!=0, EpetraSpecializedMultiVecFailure,
257  "Anasazi::EpetraOpMultiVec::MvRandom call to Epetra_MultiVector::Random() returned a nonzero value.");
258  }
259 
262  void MvInit ( double alpha ) {
263  TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->PutScalar( alpha )!=0, EpetraSpecializedMultiVecFailure,
264  "Anasazi::EpetraOpMultiVec::MvInit call to Epetra_MultiVector::PutScalar() returned a nonzero value.");
265  }
266 
268 
269 
271  Epetra_MultiVector* GetEpetraMultiVec() { return &*Epetra_MV; };
272 
274  const Epetra_MultiVector* GetEpetraMultiVec() const { return &*Epetra_MV; };
275 
277 
279 
281 
283  void MvPrint( std::ostream& os ) const { Epetra_MV->Print( os ); }
284 
286 
287  private:
288 //use pragmas to disable some false-positive warnings for windows
289 // sharedlibs export
290 #ifdef _MSC_VER
291 #pragma warning(push)
292 #pragma warning(disable:4251)
293 #endif
294  Teuchos::RCP<Epetra_Operator> Epetra_OP;
295  Teuchos::RCP<Epetra_MultiVector> Epetra_MV;
296  Teuchos::RCP<Epetra_MultiVector> Epetra_MV_Temp;
297 #ifdef _MSC_VER
298 #pragma warning(pop)
299 #endif
300  };
301 
302 
303 } // end of Anasazi namespace
304 
305 #endif // end of file ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
EpetraMultiVecAccessor is an interfaceto allow any Anasazi::MultiVec implementation that is based on ...
const Epetra_MultiVector * GetEpetraMultiVec() const
Return the pointer to the Epetra_MultiVector object.
EpetraSpecializedMultiVecFailure is thrown when a return value from an Epetra call on an Epetra_Multi...
void MvInit(double alpha)
Replace each element of the vectors in *this with alpha.
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.
ptrdiff_t GetGlobalLength() const
The number of rows in the multivector.
Specialized adapter class for Anasazi::MultiVec that uses Epetra_MultiVector and Epetra_Operator to d...
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.
Interface for multivectors used by Anasazi&#39;s linear solvers.
Declarations of Anasazi multi-vector and operator classes using Epetra_MultiVector and Epetra_Operato...
int GetNumberVecs() const
Obtain the vector length of *this.