Anasazi Version of the Day
AnasaziBasicEigenproblem.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //                 Anasazi: Block Eigensolvers Package
00005 //                 Copyright (2004) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef ANASAZI_BASIC_EIGENPROBLEM_H
00030 #define ANASAZI_BASIC_EIGENPROBLEM_H
00031 
00036 #include "AnasaziEigenproblem.hpp"
00037 #include "AnasaziMultiVecTraits.hpp"
00038 #include "AnasaziOperatorTraits.hpp"
00039 
00045 namespace Anasazi {
00046   
00047   template<class ScalarType, class MV, class OP>
00048   class BasicEigenproblem : public virtual Eigenproblem<ScalarType, MV, OP> {
00049     
00050   public:
00051     
00053 
00054     
00056     BasicEigenproblem();
00057     
00059     BasicEigenproblem( const Teuchos::RCP<const OP>& Op, const Teuchos::RCP<MV>& InitVec );
00060     
00062     BasicEigenproblem( const Teuchos::RCP<const OP>& Op, const Teuchos::RCP<const OP>& B, const Teuchos::RCP<MV>& InitVec );
00063     
00065     BasicEigenproblem( const BasicEigenproblem<ScalarType, MV, OP>& Problem );
00066     
00068     virtual ~BasicEigenproblem() {};
00070     
00072 
00073     
00080     void setOperator( const Teuchos::RCP<const OP>& Op ) { _Op = Op; _isSet=false; };
00081     
00084     void setA( const Teuchos::RCP<const OP>& A ) { _AOp = A; _isSet=false; };
00085     
00088     void setM( const Teuchos::RCP<const OP>& M ) { _MOp = M; _isSet=false; };
00089     
00092     void setPrec( const Teuchos::RCP<const OP>& Prec ) { _Prec = Prec; _isSet=false; };
00093     
00101     void setInitVec( const Teuchos::RCP<MV>& InitVec ) { _InitVec = InitVec; _isSet=false; };
00102     
00108     void setAuxVecs( const Teuchos::RCP<const MV>& AuxVecs ) { _AuxVecs = AuxVecs; _isSet=false; };
00109 
00111     void setNEV( int nev ){ _nev = nev; _isSet=false; };
00112 
00114 
00117     void setHermitian( bool isSym ){ _isSym = isSym; _isSet=false; };
00118 
00134     bool setProblem();
00135 
00142     void setSolution(const Eigensolution<ScalarType,MV> &sol) {_sol = sol;}
00143 
00145     
00147 
00148     
00150     Teuchos::RCP<const OP> getOperator() const { return( _Op ); };
00151     
00153     Teuchos::RCP<const OP> getA() const { return( _AOp ); };
00154     
00156     Teuchos::RCP<const OP> getM() const { return( _MOp ); };
00157     
00159     Teuchos::RCP<const OP> getPrec() const { return( _Prec ); };
00160     
00162     Teuchos::RCP<const MV> getInitVec() const { return( _InitVec ); };
00163     
00165     Teuchos::RCP<const MV> getAuxVecs() const { return( _AuxVecs ); };
00166     
00168     int getNEV() const { return( _nev ); }
00169 
00171     bool isHermitian() const { return( _isSym ); }
00172     
00174     bool isProblemSet() const { return( _isSet ); }
00175 
00181     const Eigensolution<ScalarType,MV> & getSolution() const { return(_sol); }
00182 
00184     
00185   protected:
00186     
00188     Teuchos::RCP<const OP> _AOp;
00189 
00191     Teuchos::RCP<const OP> _MOp; 
00192 
00194     Teuchos::RCP<const OP> _Op;
00195 
00197     Teuchos::RCP<const OP> _Prec;
00198 
00200     Teuchos::RCP<MV> _InitVec;
00201 
00203     Teuchos::RCP<const MV> _AuxVecs;
00204 
00206     int _nev;
00207 
00209 
00212     bool _isSym;
00213 
00215     bool _isSet;
00216 
00218     typedef MultiVecTraits<ScalarType,MV> MVT;
00220     typedef OperatorTraits<ScalarType,MV,OP> OPT;
00221 
00223     Eigensolution<ScalarType,MV> _sol;
00224   };
00225 
00226 
00227   //=============================================================================
00228   //     Implementations (Constructors / Destructors)
00229   //=============================================================================
00230   template <class ScalarType, class MV, class OP>
00231   BasicEigenproblem<ScalarType, MV, OP>::BasicEigenproblem() : 
00232     _nev(0), 
00233     _isSym(false),
00234     _isSet(false)
00235   {
00236   }
00237 
00238 
00239   //=============================================================================
00240   template <class ScalarType, class MV, class OP>
00241   BasicEigenproblem<ScalarType, MV, OP>::BasicEigenproblem( const Teuchos::RCP<const OP>& Op, const Teuchos::RCP<MV>& InitVec ) :    
00242     _Op(Op), 
00243     _InitVec(InitVec), 
00244     _nev(0), 
00245     _isSym(false),
00246     _isSet(false)
00247   {
00248   }
00249 
00250 
00251   //=============================================================================
00252   template <class ScalarType, class MV, class OP>
00253   BasicEigenproblem<ScalarType, MV, OP>::BasicEigenproblem( const Teuchos::RCP<const OP>& Op, const Teuchos::RCP<const OP>& M,
00254                                                             const Teuchos::RCP<MV>& InitVec ) :
00255     _MOp(M), 
00256     _Op(Op), 
00257     _InitVec(InitVec), 
00258     _nev(0), 
00259     _isSym(false),
00260     _isSet(false)
00261   {
00262   }
00263 
00264 
00265   //=============================================================================
00266   template <class ScalarType, class MV, class OP>
00267   BasicEigenproblem<ScalarType, MV, OP>::BasicEigenproblem( const BasicEigenproblem<ScalarType,MV,OP>& Problem ) :
00268     _AOp(Problem._AOp), 
00269     _MOp(Problem._MOp), 
00270     _Op(Problem._Op), 
00271     _Prec(Problem._Prec), 
00272     _InitVec(Problem._InitVec), 
00273     _nev(Problem._nev), 
00274     _isSym(Problem._isSym),
00275     _isSet(Problem._isSet),
00276     _sol(Problem._sol)
00277   {
00278   }
00279 
00280 
00281   //=============================================================================
00282   //    SetProblem (sanity check method)
00283   //=============================================================================
00284   template <class ScalarType, class MV, class OP>
00285   bool BasicEigenproblem<ScalarType, MV, OP>::setProblem() 
00286   {
00287     //----------------------------------------------------------------
00288     // Sanity Checks
00289     //----------------------------------------------------------------
00290     // If there is no operator, then we can't proceed.
00291     if ( !_AOp.get() && !_Op.get() ) { return false; }
00292     
00293     // If there is no initial vector, then we don't have anything to clone workspace from.
00294     if ( !_InitVec.get() ) { return false; }
00295     
00296     // If we don't need any eigenvalues, we don't need to continue.
00297     if (_nev == 0) { return false; }
00298     
00299     // If there is an A, but no operator, we can set them equal.
00300     if (_AOp.get() && !_Op.get()) { _Op = _AOp; }
00301     
00302     // Clear the storage from any previous call to setSolution()
00303     Eigensolution<ScalarType,MV> emptysol;
00304     _sol = emptysol;
00305     
00306     // mark the problem as set and return no-error
00307     _isSet=true;
00308     return true;
00309   }        
00310   
00311 } // end Anasazi namespace
00312 #endif
00313 
00314 // end AnasaziBasicEigenproblem.hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends