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
24#include "Teuchos_ScalarTraits.hpp"
25
28
29#include "Teuchos_LAPACK.hpp"
30#include "Teuchos_BLAS.hpp"
31#include "Teuchos_SerialDenseMatrix.hpp"
32#include "Teuchos_SerialDenseSolver.hpp"
33#include "Teuchos_ParameterList.hpp"
34#include "Teuchos_TimeMonitor.hpp"
35
36// TODO: TraceMin performs some unnecessary computations upon restarting. Fix it!
37
38namespace Anasazi {
39namespace Experimental {
91 template <class ScalarType, class MV, class OP>
92 class TraceMin : public TraceMinBase<ScalarType,MV,OP> {
93 public:
95
96
137 TraceMin( const Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> > &problem,
138 const Teuchos::RCP<SortManager<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &sorter,
139 const Teuchos::RCP<OutputManager<ScalarType> > &printer,
140 const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &tester,
141 const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho,
142 Teuchos::ParameterList &params
143 );
144
145 private:
146 //
147 // Convenience typedefs
148 //
152 typedef Teuchos::ScalarTraits<ScalarType> SCT;
153 typedef typename SCT::magnitudeType MagnitudeType;
154 const MagnitudeType ONE;
155 const MagnitudeType ZERO;
156 const MagnitudeType NANVAL;
157
158 // TraceMin specific methods
159 void addToBasis(const Teuchos::RCP<const MV> Delta);
160
161 void harmonicAddToBasis(const Teuchos::RCP<const MV> Delta);
162 };
163
166 //
167 // Implementations
168 //
171
172
174 // Constructor
175 template <class ScalarType, class MV, class OP>
177 const Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> > &problem,
178 const Teuchos::RCP<SortManager<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> > &sorter,
179 const Teuchos::RCP<OutputManager<ScalarType> > &printer,
180 const Teuchos::RCP<StatusTest<ScalarType,MV,OP> > &tester,
181 const Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > &ortho,
182 Teuchos::ParameterList &params
183 ) :
185 ONE(Teuchos::ScalarTraits<MagnitudeType>::one()),
186 ZERO(Teuchos::ScalarTraits<MagnitudeType>::zero()),
187 NANVAL(Teuchos::ScalarTraits<MagnitudeType>::nan())
188 {
189 }
190
191
192 template <class ScalarType, class MV, class OP>
193 void TraceMin<ScalarType,MV,OP>::addToBasis(const Teuchos::RCP<const MV> Delta)
194 {
195 MVT::MvAddMv(ONE,*this->X_,-ONE,*Delta,*this->V_);
196
197 if(this->hasM_)
198 {
199#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
200 Teuchos::TimeMonitor lcltimer( *this->timerMOp_ );
201#endif
202 this->count_ApplyM_+= this->blockSize_;
203
204 OPT::Apply(*this->MOp_,*this->V_,*this->MV_);
205 }
206
207 int rank;
208 {
209#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
210 Teuchos::TimeMonitor lcltimer( *this->timerOrtho_ );
211#endif
212
213 if(this->numAuxVecs_ > 0)
214 {
215 rank = this->orthman_->projectAndNormalizeMat(*this->V_,this->auxVecs_,
216 Teuchos::tuple(Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > >(Teuchos::null)),
217 Teuchos::null,this->MV_,this->MauxVecs_);
218 }
219 else
220 {
221 rank = this->orthman_->normalizeMat(*this->V_,Teuchos::null,this->MV_);
222 }
223 }
224
225 // FIXME (mfh 07 Oct 2014) This variable is currently unused, but
226 // it would make sense to use it to check whether the block is
227 // rank deficient.
228 (void) rank;
229
230 if(this->Op_ != Teuchos::null)
231 {
232#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
233 Teuchos::TimeMonitor lcltimer( *this->timerOp_ );
234#endif
235 this->count_ApplyOp_+= this->blockSize_;
236 OPT::Apply(*this->Op_,*this->V_,*this->KV_);
237 }
238 }
239
240
241
242 template <class ScalarType, class MV, class OP>
243 void TraceMin<ScalarType,MV,OP>::harmonicAddToBasis(const Teuchos::RCP<const MV> Delta)
244 {
245 // V = X - Delta
246 MVT::MvAddMv(ONE,*this->X_,-ONE,*Delta,*this->V_);
247
248 // Project out auxVecs
249 if(this->numAuxVecs_ > 0)
250 {
251#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
252 Teuchos::TimeMonitor lcltimer( *this->timerOrtho_ );
253#endif
254 this->orthman_->projectMat(*this->V_,this->auxVecs_);
255 }
256
257 // Compute KV
258 if(this->Op_ != Teuchos::null)
259 {
260#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
261 Teuchos::TimeMonitor lcltimer( *this->timerOp_ );
262#endif
263 this->count_ApplyOp_+= this->blockSize_;
264
265 OPT::Apply(*this->Op_,*this->V_,*this->KV_);
266 }
267
268 // Normalize lclKV
269 RCP< Teuchos::SerialDenseMatrix<int,ScalarType> > gamma = rcp(new Teuchos::SerialDenseMatrix<int,ScalarType>(this->blockSize_,this->blockSize_));
270 int rank = this->orthman_->normalizeMat(*this->KV_,gamma);
271 // FIXME (mfh 18 Feb 2015) It would make sense to check the rank.
272 (void) rank;
273
274 // lclV = lclV/gamma
275 Teuchos::SerialDenseSolver<int,ScalarType> SDsolver;
276 SDsolver.setMatrix(gamma);
277 SDsolver.invert();
278 RCP<MV> tempMV = MVT::CloneCopy(*this->V_);
279 MVT::MvTimesMatAddMv(ONE,*tempMV,*gamma,ZERO,*this->V_);
280
281 // Compute MV
282 if(this->hasM_)
283 {
284#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
285 Teuchos::TimeMonitor lcltimer( *this->timerMOp_ );
286#endif
287 this->count_ApplyM_+= this->blockSize_;
288
289 OPT::Apply(*this->MOp_,*this->V_,*this->MV_);
290 }
291 }
292
293}} // End of namespace Anasazi
294
295#endif
296
297// 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 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 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.