14#ifndef ANASAZI_TRACEMIN_DAVIDSON_HPP
15#define ANASAZI_TRACEMIN_DAVIDSON_HPP
24#include "Teuchos_ScalarTraits.hpp"
25#include "Teuchos_SerialDenseMatrix.hpp"
26#include "Teuchos_ParameterList.hpp"
27#include "Teuchos_TimeMonitor.hpp"
47 template <
class ScalarType,
class MV,
class OP>
60 const Teuchos::RCP<
SortManager<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &
sorter,
64 Teuchos::ParameterList &
params
73 typedef Teuchos::ScalarTraits<ScalarType> SCT;
74 typedef typename SCT::magnitudeType MagnitudeType;
77 void addToBasis(
const Teuchos::RCP<const MV>
Delta);
79 void harmonicAddToBasis(
const Teuchos::RCP<const MV>
Delta);
94 template <
class ScalarType,
class MV,
class OP>
97 const Teuchos::RCP<
SortManager<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &
sorter,
101 Teuchos::ParameterList &
params
113 template <
class ScalarType,
class MV,
class OP>
118 "Anasazi::TraceMinDavidson::addToBasis(): Delta does not have blockSize_ columns");
122 std::vector<int>
curind(this->curDim_),
newind(this->blockSize_);
126 Teuchos::Array< Teuchos::RCP<const MV> >
projVecs = this->auxVecs_;
129 for(
int i=0;
i<this->curDim_;
i++)
131 lclV = MVT::CloneViewNonConst(*this->V_,
curind);
135 for (
int i=0;
i<this->blockSize_; ++
i)
137 lclV = MVT::CloneViewNonConst(*this->V_,
newind);
141 this->curDim_ += this->blockSize_;
147 Teuchos::Array< Teuchos::RCP<const MV> >
MprojVecs = this->MauxVecs_;
154 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
155 Teuchos::TimeMonitor
lcltimer( *this->timerMOp_ );
157 this->count_ApplyM_+= this->blockSize_;
162 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
163 Teuchos::TimeMonitor
lcltimer( *this->timerOrtho_ );
168 Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > >(Teuchos::null)),
172 MprojVecs.pop_back();
176 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
177 Teuchos::TimeMonitor lcltimer( *this->timerOrtho_ );
181 rank = this->orthman_->projectAndNormalizeMat(*lclV,projVecs);
186 TEUCHOS_TEST_FOR_EXCEPTION(rank != this->blockSize_,TraceMinBaseOrthoFailure,
187 "Anasazi::TraceMinDavidson::addToBasis(): Couldn't generate basis of full rank.");
190 if(this->Op_ != Teuchos::null)
192 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
193 Teuchos::TimeMonitor lcltimer( *this->timerOp_ );
195 this->count_ApplyOp_+= this->blockSize_;
197 lclKV = MVT::CloneViewNonConst(*this->KV_,newind);
198 OPT::Apply(*this->Op_,*lclV,*lclKV);
209 template <
class ScalarType,
class MV,
class OP>
210 void TraceMinDavidson<ScalarType,MV,OP>::harmonicAddToBasis(Teuchos::RCP<const MV> Delta)
213 TEUCHOS_TEST_FOR_EXCEPTION(MVT::GetNumberVecs(*Delta) != this->blockSize_, std::invalid_argument,
214 "Anasazi::TraceMinDavidson::addToBasis(): Delta does not have blockSize_ columns");
218 std::vector<int> curind(this->curDim_), newind(this->blockSize_);
220 Teuchos::RCP<MV> lclV, lclKV, lclMV, projVecs, KprojVecs;
224 for(
int i=0; i<this->curDim_; i++)
226 projVecs = MVT::CloneViewNonConst(*this->V_,curind);
228 if(this->Op_ != Teuchos::null)
230 lclKV = MVT::CloneViewNonConst(*this->KV_,curind);
235 for (
int i=0; i<this->blockSize_; ++i)
236 newind[i] = this->curDim_ + i;
237 lclV = MVT::CloneViewNonConst(*this->V_,newind);
240 MVT::SetBlock(*Delta,newind,*this->V_);
241 this->curDim_ += this->blockSize_;
244 if(this->auxVecs_.size() > 0)
245 this->orthman_->projectMat(*lclV,this->auxVecs_);
248 if(this->Op_ != Teuchos::null)
250 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
251 Teuchos::TimeMonitor lcltimer( *this->timerOp_ );
253 this->count_ApplyOp_+= this->blockSize_;
255 lclKV = MVT::CloneViewNonConst(*this->KV_,newind);
256 OPT::Apply(*this->Op_,*lclV,*lclKV);
262 int nauxVecs = MVT::GetNumberVecs(*projVecs);
263 RCP< Teuchos::SerialDenseMatrix<int,ScalarType> > gamma = rcp(
new Teuchos::SerialDenseMatrix<int,ScalarType>(nauxVecs,this->blockSize_));
265 this->orthman_->innerProdMat(*KprojVecs,*lclKV,*gamma);
268 MVT::MvTimesMatAddMv(-this->ONE,*KprojVecs,*gamma,this->ONE,*lclKV);
271 MVT::MvTimesMatAddMv(-this->ONE,*projVecs,*gamma,this->ONE,*lclV);
274 RCP< Teuchos::SerialDenseMatrix<int,ScalarType> > gamma2 = rcp(
new Teuchos::SerialDenseMatrix<int,ScalarType>(this->blockSize_,this->blockSize_));
275 rank = this->orthman_->normalizeMat(*lclKV,gamma2);
278 Teuchos::SerialDenseSolver<int,ScalarType> SDsolver;
279 SDsolver.setMatrix(gamma2);
281 RCP<MV> tempMV = MVT::CloneCopy(*lclV);
282 MVT::MvTimesMatAddMv(this->ONE,*tempMV,*gamma2,this->ZERO,*lclV);
284 TEUCHOS_TEST_FOR_EXCEPTION(rank != this->blockSize_,TraceMinBaseOrthoFailure,
285 "Anasazi::TraceMinDavidson::addToBasis(): Couldn't generate basis of full rank.");
290 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
291 Teuchos::TimeMonitor lcltimer( *this->timerMOp_ );
293 this->count_ApplyM_+= this->blockSize_;
295 lclMV = MVT::CloneViewNonConst(*this->MV_,newind);
296 OPT::Apply(*this->MOp_,*lclV,*lclMV);
Anasazi header file which uses auto-configuration information to include necessary C++ headers.
Pure virtual base class which describes the basic interface to the iterative eigensolver.
Templated virtual class for providing orthogonalization/orthonormalization methods with matrix-based ...
Declaration of basic traits for the multivector type.
Virtual base class which defines basic traits for the operator type.
Abstract base class for trace minimization eigensolvers.
This is an abstract base class for the trace minimization eigensolvers.
This class implements a TraceMin-Davidson iteration for solving symmetric generalized eigenvalue prob...
TraceMinDavidson(const Teuchos::RCP< Eigenproblem< ScalarType, MV, OP > > &problem, const Teuchos::RCP< SortManager< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > > &sorter, const Teuchos::RCP< OutputManager< ScalarType > > &printer, const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &tester, const Teuchos::RCP< MatOrthoManager< ScalarType, MV, OP > > &ortho, Teuchos::ParameterList ¶ms)
TraceMinBase constructor with eigenproblem, solver utilities, and parameter list of solver options.
Anasazi's templated virtual class for constructing an operator that can interface with the OperatorTr...
Anasazi's templated pure virtual class for managing the sorting of approximate eigenvalues computed b...
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.