Anasazi  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
AnasaziTraceMin.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 
00033 #ifndef ANASAZI_TRACEMIN_HPP
00034 #define ANASAZI_TRACEMIN_HPP
00035 
00036 #include "AnasaziTypes.hpp"
00037 #include "AnasaziBasicSort.hpp"
00038 #include "AnasaziTraceMinBase.hpp"
00039 
00040 #include "Epetra_Operator.h"
00041 
00042 #include "AnasaziEigensolver.hpp"
00043 #include "AnasaziMultiVecTraits.hpp"
00044 #include "AnasaziOperatorTraits.hpp"
00045 #include "Teuchos_ScalarTraits.hpp"
00046 
00047 #include "AnasaziMatOrthoManager.hpp"
00048 #include "AnasaziSolverUtils.hpp"
00049 
00050 #include "Teuchos_LAPACK.hpp"
00051 #include "Teuchos_BLAS.hpp"
00052 #include "Teuchos_SerialDenseMatrix.hpp"
00053 #include "Teuchos_SerialDenseSolver.hpp"
00054 #include "Teuchos_ParameterList.hpp"
00055 #include "Teuchos_TimeMonitor.hpp"
00056 
00057 // TODO: TraceMin performs some unnecessary computations upon restarting.  Fix it!
00058   enum SaddleSolType {SCHUR, PROJ};
00059 
00060 namespace Anasazi {
00061 namespace Experimental {
00113   template <class ScalarType, class MV, class OP>
00114   class TraceMin : public TraceMinBase<ScalarType,MV,OP> {
00115   public:
00117 
00118 
00159     TraceMin( const Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> >    &problem,
00160                    const Teuchos::RCP<SortManager<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &sorter,
00161                    const Teuchos::RCP<OutputManager<ScalarType> >         &printer,
00162                    const Teuchos::RCP<StatusTest<ScalarType,MV,OP> >      &tester,
00163                    const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho,
00164                    Teuchos::ParameterList &params
00165                  );
00166 
00167   private:
00168     //
00169     // Convenience typedefs
00170     //
00171     typedef SolverUtils<ScalarType,MV,OP> Utils;
00172     typedef MultiVecTraits<ScalarType,MV> MVT;
00173     typedef OperatorTraits<ScalarType,MV,OP> OPT;
00174     typedef Teuchos::ScalarTraits<ScalarType> SCT;
00175     typedef typename SCT::magnitudeType MagnitudeType;
00176     const MagnitudeType ONE;
00177     const MagnitudeType ZERO;
00178     const MagnitudeType NANVAL;
00179 
00180     // TraceMin specific methods
00181     void addToBasis(const Teuchos::RCP<const MV> Delta);
00182   };
00183 
00186   //
00187   // Implementations
00188   //
00191 
00192 
00194   // Constructor
00195   template <class ScalarType, class MV, class OP>
00196   TraceMin<ScalarType,MV,OP>::TraceMin(
00197         const Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> >    &problem,
00198         const Teuchos::RCP<SortManager<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &sorter,
00199         const Teuchos::RCP<OutputManager<ScalarType> >         &printer,
00200         const Teuchos::RCP<StatusTest<ScalarType,MV,OP> >      &tester,
00201         const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho,
00202         Teuchos::ParameterList &params
00203         ) :
00204     TraceMinBase<ScalarType,MV,OP>(problem,sorter,printer,tester,ortho,params),
00205     ONE(Teuchos::ScalarTraits<MagnitudeType>::one()),
00206     ZERO(Teuchos::ScalarTraits<MagnitudeType>::zero()),
00207     NANVAL(Teuchos::ScalarTraits<MagnitudeType>::nan())
00208   {
00209   }
00210 
00211 
00212   template <class ScalarType, class MV, class OP>
00213   void TraceMin<ScalarType,MV,OP>::addToBasis(const Teuchos::RCP<const MV> Delta)
00214   {
00215     MVT::MvAddMv(ONE,*this->X_,-ONE,*Delta,*this->V_);
00216 
00217     if(this->hasM_)
00218     {
00219 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
00220       Teuchos::TimeMonitor lcltimer( *this->timerMOp_ );
00221 #endif
00222       this->count_ApplyM_+= this->blockSize_;
00223 
00224       OPT::Apply(*this->MOp_,*this->V_,*this->MV_);
00225     }
00226 
00227     int rank;
00228     {
00229 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
00230       Teuchos::TimeMonitor lcltimer( *this->timerOrtho_ );
00231 #endif
00232 
00233       if(this->numAuxVecs_ > 0)
00234       {
00235         rank = this->orthman_->projectAndNormalizeMat(*this->V_,this->auxVecs_,
00236                Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > >(Teuchos::null)),
00237                Teuchos::null,this->MV_,this->MauxVecs_);
00238       }
00239       else
00240       {
00241         rank = this->orthman_->normalizeMat(*this->V_,Teuchos::null,this->MV_);
00242       }
00243     }
00244 
00245     // FIXME (mfh 07 Oct 2014) This variable is currently unused, but
00246     // it would make sense to use it to check whether the block is
00247     // rank deficient.
00248     (void) rank;
00249 
00250     if(this->Op_ != Teuchos::null)
00251     {
00252 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
00253       Teuchos::TimeMonitor lcltimer( *this->timerOp_ );
00254 #endif
00255       this->count_ApplyOp_+= this->blockSize_;
00256       OPT::Apply(*this->Op_,*this->V_,*this->KV_);
00257     }
00258   }
00259 
00260 }} // End of namespace Anasazi
00261 
00262 #endif
00263 
00264 // End of file AnasaziTraceMin.hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends