Anasazi Version of the Day
Loading...
Searching...
No Matches
AnasaziTraceMin.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Anasazi: Block Eigensolvers Package
4//
5// Copyright 2004 NTESS and the Anasazi contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
14#ifndef ANASAZI_TRACEMIN_HPP
15#define ANASAZI_TRACEMIN_HPP
16
17#include "AnasaziTypes.hpp"
18#include "AnasaziBasicSort.hpp"
20
21#ifdef HAVE_ANASAZI_EPETRA
22 #include "Epetra_Operator.h"
23#endif
24
28#include "Teuchos_ScalarTraits.hpp"
29
32
33#include "Teuchos_LAPACK.hpp"
34#include "Teuchos_BLAS.hpp"
35#include "Teuchos_SerialDenseMatrix.hpp"
36#include "Teuchos_SerialDenseSolver.hpp"
37#include "Teuchos_ParameterList.hpp"
38#include "Teuchos_TimeMonitor.hpp"
39
40// TODO: TraceMin performs some unnecessary computations upon restarting. Fix it!
41
42namespace Anasazi {
43namespace Experimental {
95 template <class ScalarType, class MV, class OP>
96 class TraceMin : public TraceMinBase<ScalarType,MV,OP> {
97 public:
99
100
141 TraceMin( const Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> > &problem,
142 const Teuchos::RCP<SortManager<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &sorter,
143 const Teuchos::RCP<OutputManager<ScalarType> > &printer,
144 const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &tester,
145 const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho,
146 Teuchos::ParameterList &params
147 );
148
149 private:
150 //
151 // Convenience typedefs
152 //
153 typedef SolverUtils<ScalarType,MV,OP> Utils;
156 typedef Teuchos::ScalarTraits<ScalarType> SCT;
157 typedef typename SCT::magnitudeType MagnitudeType;
158 const MagnitudeType ONE;
159 const MagnitudeType ZERO;
160 const MagnitudeType NANVAL;
161
162 // TraceMin specific methods
163 void addToBasis(const Teuchos::RCP<const MV> Delta);
164
165 void harmonicAddToBasis(const Teuchos::RCP<const MV> Delta);
166 };
167
170 //
171 // Implementations
172 //
175
176
178 // Constructor
179 template <class ScalarType, class MV, class OP>
181 const Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> > &problem,
182 const Teuchos::RCP<SortManager<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &sorter,
183 const Teuchos::RCP<OutputManager<ScalarType> > &printer,
184 const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &tester,
185 const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho,
186 Teuchos::ParameterList &params
187 ) :
188 TraceMinBase<ScalarType,MV,OP>(problem,sorter,printer,tester,ortho,params),
189 ONE(Teuchos::ScalarTraits<MagnitudeType>::one()),
190 ZERO(Teuchos::ScalarTraits<MagnitudeType>::zero()),
191 NANVAL(Teuchos::ScalarTraits<MagnitudeType>::nan())
192 {
193 }
194
195
196 template <class ScalarType, class MV, class OP>
197 void TraceMin<ScalarType,MV,OP>::addToBasis(const Teuchos::RCP<const MV> Delta)
198 {
199 MVT::MvAddMv(ONE,*this->X_,-ONE,*Delta,*this->V_);
200
201 if(this->hasM_)
202 {
203#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
204 Teuchos::TimeMonitor lcltimer( *this->timerMOp_ );
205#endif
206 this->count_ApplyM_+= this->blockSize_;
207
208 OPT::Apply(*this->MOp_,*this->V_,*this->MV_);
209 }
210
211 int rank;
212 {
213#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
214 Teuchos::TimeMonitor lcltimer( *this->timerOrtho_ );
215#endif
216
217 if(this->numAuxVecs_ > 0)
218 {
219 rank = this->orthman_->projectAndNormalizeMat(*this->V_,this->auxVecs_,
220 Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > >(Teuchos::null)),
221 Teuchos::null,this->MV_,this->MauxVecs_);
222 }
223 else
224 {
225 rank = this->orthman_->normalizeMat(*this->V_,Teuchos::null,this->MV_);
226 }
227 }
228
229 // FIXME (mfh 07 Oct 2014) This variable is currently unused, but
230 // it would make sense to use it to check whether the block is
231 // rank deficient.
232 (void) rank;
233
234 if(this->Op_ != Teuchos::null)
235 {
236#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
237 Teuchos::TimeMonitor lcltimer( *this->timerOp_ );
238#endif
239 this->count_ApplyOp_+= this->blockSize_;
240 OPT::Apply(*this->Op_,*this->V_,*this->KV_);
241 }
242 }
243
244
245
246 template <class ScalarType, class MV, class OP>
247 void TraceMin<ScalarType,MV,OP>::harmonicAddToBasis(const Teuchos::RCP<const MV> Delta)
248 {
249 // V = X - Delta
250 MVT::MvAddMv(ONE,*this->X_,-ONE,*Delta,*this->V_);
251
252 // Project out auxVecs
253 if(this->numAuxVecs_ > 0)
254 {
255#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
256 Teuchos::TimeMonitor lcltimer( *this->timerOrtho_ );
257#endif
258 this->orthman_->projectMat(*this->V_,this->auxVecs_);
259 }
260
261 // Compute KV
262 if(this->Op_ != Teuchos::null)
263 {
264#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
265 Teuchos::TimeMonitor lcltimer( *this->timerOp_ );
266#endif
267 this->count_ApplyOp_+= this->blockSize_;
268
269 OPT::Apply(*this->Op_,*this->V_,*this->KV_);
270 }
271
272 // Normalize lclKV
273 RCP< Teuchos::SerialDenseMatrix<int,ScalarType> > gamma = rcp(new Teuchos::SerialDenseMatrix<int,ScalarType>(this->blockSize_,this->blockSize_));
274 int rank = this->orthman_->normalizeMat(*this->KV_,gamma);
275 // FIXME (mfh 18 Feb 2015) It would make sense to check the rank.
276 (void) rank;
277
278 // lclV = lclV/gamma
279 Teuchos::SerialDenseSolver<int,ScalarType> SDsolver;
280 SDsolver.setMatrix(gamma);
281 SDsolver.invert();
282 RCP<MV> tempMV = MVT::CloneCopy(*this->V_);
283 MVT::MvTimesMatAddMv(ONE,*tempMV,*gamma,ZERO,*this->V_);
284
285 // Compute MV
286 if(this->hasM_)
287 {
288#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
289 Teuchos::TimeMonitor lcltimer( *this->timerMOp_ );
290#endif
291 this->count_ApplyM_+= this->blockSize_;
292
293 OPT::Apply(*this->MOp_,*this->V_,*this->MV_);
294 }
295 }
296
297}} // End of namespace Anasazi
298
299#endif
300
301// End of file AnasaziTraceMin.hpp
Basic implementation of the Anasazi::SortManager class.
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.
Class which provides internal utilities for the Anasazi solvers.
Abstract base class for trace minimization eigensolvers.
Types and exceptions used within Anasazi solvers and interfaces.
This class defines the interface required by an eigensolver and status test class to compute solution...
This is an abstract base class for the trace minimization eigensolvers.
This class implements a TraceMIN iteration, a preconditioned iteration for solving linear symmetric p...
TraceMin(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 &params)
TraceMin constructor with eigenproblem, solver utilities, and parameter list of solver options.
Anasazi's templated virtual class for providing routines for orthogonalization and orthonormalization...
Traits class which defines basic operations on multivectors.
Virtual base class which defines basic traits for the operator type.
Output managers remove the need for the eigensolver to know any information about the required output...
Anasazi's templated, static class providing utilities for the solvers.
Anasazi's templated pure virtual class for managing the sorting of approximate eigenvalues computed b...
Common interface of stopping criteria for Anasazi's solvers.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.