Anasazi  Version of the Day
AnasaziBasicEigenproblem.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 
29 #ifndef ANASAZI_BASIC_EIGENPROBLEM_H
30 #define ANASAZI_BASIC_EIGENPROBLEM_H
31 
36 #include "AnasaziEigenproblem.hpp"
39 
45 namespace Anasazi {
46 
47  template<class ScalarType, class MV, class OP>
48  class BasicEigenproblem : public virtual Eigenproblem<ScalarType, MV, OP> {
49 
50  public:
51 
53 
54 
57 
59  BasicEigenproblem( const Teuchos::RCP<const OP>& Op, const Teuchos::RCP<MV>& InitVec );
60 
62  BasicEigenproblem( const Teuchos::RCP<const OP>& Op, const Teuchos::RCP<const OP>& B, const Teuchos::RCP<MV>& InitVec );
63 
66 
68  virtual ~BasicEigenproblem() {};
70 
72 
73 
80  void setOperator( const Teuchos::RCP<const OP>& Op ) { _Op = Op; _isSet=false; };
81 
84  void setA( const Teuchos::RCP<const OP>& A ) { _AOp = A; _isSet=false; };
85 
88  void setM( const Teuchos::RCP<const OP>& M ) { _MOp = M; _isSet=false; };
89 
92  void setPrec( const Teuchos::RCP<const OP>& Prec ) { _Prec = Prec; _isSet=false; };
93 
101  void setInitVec( const Teuchos::RCP<MV>& InitVec ) { _InitVec = InitVec; _isSet=false; };
102 
108  void setAuxVecs( const Teuchos::RCP<const MV>& AuxVecs ) { _AuxVecs = AuxVecs; _isSet=false; };
109 
111  void setNEV( int nev ){ _nev = nev; _isSet=false; };
112 
114 
117  void setHermitian( bool isSym ){ _isSym = isSym; _isSet=false; };
118 
134  bool setProblem();
135 
143 
145 
147 
148 
150  Teuchos::RCP<const OP> getOperator() const { return( _Op ); };
151 
153  Teuchos::RCP<const OP> getA() const { return( _AOp ); };
154 
156  Teuchos::RCP<const OP> getM() const { return( _MOp ); };
157 
159  Teuchos::RCP<const OP> getPrec() const { return( _Prec ); };
160 
162  Teuchos::RCP<const MV> getInitVec() const { return( _InitVec ); };
163 
165  Teuchos::RCP<const MV> getAuxVecs() const { return( _AuxVecs ); };
166 
168  int getNEV() const { return( _nev ); }
169 
171  bool isHermitian() const { return( _isSym ); }
172 
174  bool isProblemSet() const { return( _isSet ); }
175 
181  const Eigensolution<ScalarType,MV> & getSolution() const { return(_sol); }
182 
184 
185  protected:
186 
188  Teuchos::RCP<const OP> _AOp;
189 
191  Teuchos::RCP<const OP> _MOp;
192 
194  Teuchos::RCP<const OP> _Op;
195 
197  Teuchos::RCP<const OP> _Prec;
198 
200  Teuchos::RCP<MV> _InitVec;
201 
203  Teuchos::RCP<const MV> _AuxVecs;
204 
206  int _nev;
207 
209 
212  bool _isSym;
213 
215  bool _isSet;
216 
221 
224  };
225 
226 
227  //=============================================================================
228  // Implementations (Constructors / Destructors)
229  //=============================================================================
230  template <class ScalarType, class MV, class OP>
232  _nev(0),
233  _isSym(false),
234  _isSet(false)
235  {
236  }
237 
238 
239  //=============================================================================
240  template <class ScalarType, class MV, class OP>
241  BasicEigenproblem<ScalarType, MV, OP>::BasicEigenproblem( const Teuchos::RCP<const OP>& Op, const Teuchos::RCP<MV>& InitVec ) :
242  _Op(Op),
243  _InitVec(InitVec),
244  _nev(0),
245  _isSym(false),
246  _isSet(false)
247  {
248  }
249 
250 
251  //=============================================================================
252  template <class ScalarType, class MV, class OP>
253  BasicEigenproblem<ScalarType, MV, OP>::BasicEigenproblem( const Teuchos::RCP<const OP>& Op, const Teuchos::RCP<const OP>& M,
254  const Teuchos::RCP<MV>& InitVec ) :
255  _MOp(M),
256  _Op(Op),
257  _InitVec(InitVec),
258  _nev(0),
259  _isSym(false),
260  _isSet(false)
261  {
262  }
263 
264 
265  //=============================================================================
266  template <class ScalarType, class MV, class OP>
268  _AOp(Problem._AOp),
269  _MOp(Problem._MOp),
270  _Op(Problem._Op),
271  _Prec(Problem._Prec),
272  _InitVec(Problem._InitVec),
273  _nev(Problem._nev),
274  _isSym(Problem._isSym),
275  _isSet(Problem._isSet),
276  _sol(Problem._sol)
277  {
278  }
279 
280 
281  //=============================================================================
282  // SetProblem (sanity check method)
283  //=============================================================================
284  template <class ScalarType, class MV, class OP>
286  {
287  //----------------------------------------------------------------
288  // Sanity Checks
289  //----------------------------------------------------------------
290  // If there is no operator, then we can't proceed.
291  if ( !_AOp.get() && !_Op.get() ) { return false; }
292 
293  // If there is no initial vector, then we don't have anything to clone workspace from.
294  if ( !_InitVec.get() ) { return false; }
295 
296  // If we don't need any eigenvalues, we don't need to continue.
297  if (_nev == 0) { return false; }
298 
299  // If there is an A, but no operator, we can set them equal.
300  if (_AOp.get() && !_Op.get()) { _Op = _AOp; }
301 
302  // Clear the storage from any previous call to setSolution()
304  _sol = emptysol;
305 
306  // mark the problem as set and return no-error
307  _isSet=true;
308  return true;
309  }
310 
311 } // end Anasazi namespace
312 #endif
313 
314 // end AnasaziBasicEigenproblem.hpp
Teuchos::RCP< const MV > getAuxVecs() const
Get a pointer to the auxiliary vector.
Teuchos::RCP< const OP > getOperator() const
Get a pointer to the operator for which eigenvalues will be computed.
bool setProblem()
Specify that this eigenproblem is fully defined.
MultiVecTraits< ScalarType, MV > MVT
Type-definition for the MultiVecTraits class corresponding to the MV type.
int getNEV() const
Get the number of eigenvalues (NEV) that are required by this eigenproblem.
void setInitVec(const Teuchos::RCP< MV > &InitVec)
Set the initial guess.
bool isHermitian() const
Get the symmetry information for this eigenproblem.
This class defines the interface required by an eigensolver and status test class to compute solution...
Declaration of basic traits for the multivector type.
OperatorTraits< ScalarType, MV, OP > OPT
Type-definition for the OperatorTraits class corresponding to the OP type.
Virtual base class which defines basic traits for the operator type.
Teuchos::RCP< const MV > _AuxVecs
Reference-counted pointer for the auxiliary vector of the eigenproblem .
bool _isSym
Symmetry of the eigenvalue problem.
int _nev
Number of eigenvalues requested.
Teuchos::RCP< MV > _InitVec
Reference-counted pointer for the initial vector of the eigenproblem .
Teuchos::RCP< const OP > _Op
Reference-counted pointer for the operator of the eigenproblem .
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
void setAuxVecs(const Teuchos::RCP< const MV > &AuxVecs)
Set auxiliary vectors.
Abstract base class which defines the interface required by an eigensolver and status test class to c...
Teuchos::RCP< const MV > getInitVec() const
Get a pointer to the initial vector.
Teuchos::RCP< const OP > getM() const
Get a pointer to the operator M of the eigenproblem .
Traits class which defines basic operations on multivectors.
Virtual base class which defines basic traits for the operator type.
void setSolution(const Eigensolution< ScalarType, MV > &sol)
Set the solution to the eigenproblem.
bool isProblemSet() const
If the problem has been set, this method will return true.
virtual ~BasicEigenproblem()
Destructor.
Teuchos::RCP< const OP > _MOp
Reference-counted pointer for M of the eigenproblem .
Struct for storing an eigenproblem solution.
Teuchos::RCP< const OP > getA() const
Get a pointer to the operator A of the eigenproblem .
void setPrec(const Teuchos::RCP< const OP > &Prec)
Set the preconditioner for this eigenvalue problem .
const Eigensolution< ScalarType, MV > & getSolution() const
Get the solution to the eigenproblem.
void setHermitian(bool isSym)
Specify the symmetry of this eigenproblem.
This provides a basic implementation for defining standard or generalized eigenvalue problems...
Teuchos::RCP< const OP > _Prec
Reference-counted pointer for the preconditioner of the eigenproblem .
void setM(const Teuchos::RCP< const OP > &M)
Set the operator M of the eigenvalue problem .
BasicEigenproblem()
Empty constructor - allows Anasazi::BasicEigenproblem to be described at a later time through "Set Me...
void setA(const Teuchos::RCP< const OP > &A)
Set the operator A of the eigenvalue problem .
Teuchos::RCP< const OP > _AOp
Reference-counted pointer for A of the eigenproblem .
Teuchos::RCP< const OP > getPrec() const
Get a pointer to the preconditioner of the eigenproblem .
void setNEV(int nev)
Specify the number of eigenvalues (NEV) that are requested.
Eigensolution< ScalarType, MV > _sol
Solution to problem.
void setOperator(const Teuchos::RCP< const OP > &Op)
Set the operator for which eigenvalues will be computed.