10 #ifndef ANASAZI_RTR_SOLMGR_HPP
11 #define ANASAZI_RTR_SOLMGR_HPP
38 #include "Teuchos_FancyOStream.hpp"
51 template<
class ScalarType,
class MV,
class OP>
105 return Teuchos::tuple(_timerSolve);
136 MagnitudeType convtol_;
151 template<
class ScalarType,
class MV,
class OP>
158 convtol_(
MT::prec()),
162 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
163 _timerSolve(Teuchos::TimeMonitor::getNewTimer(
"Anasazi: RTRSolMgr::solve()")),
170 TEUCHOS_TEST_FOR_EXCEPTION(problem_->getInitVec() == Teuchos::null,std::invalid_argument,
"Problem does not contain initial vectors to clone from.");
174 whch_ = pl_.
get(
"Which",
"SR");
176 std::invalid_argument,
"Anasazi::RTRSolMgr: Invalid sorting string. RTR solvers compute only LR or SR.");
179 convtol_ = pl_.
get(
"Convergence Tolerance",convtol_);
180 relconvtol_ = pl_.
get(
"Relative Convergence Tolerance",relconvtol_);
181 strtmp = pl_.
get(
"Convergence Norm",std::string(
"2"));
183 convNorm_ = RES_2NORM;
185 else if (strtmp ==
"M") {
186 convNorm_ = RES_ORTH;
190 "Anasazi::RTRSolMgr: Invalid Convergence Norm.");
195 maxIters_ = pl_.
get(
"Maximum Iterations",maxIters_);
198 skinny_ = pl_.
get(
"Skinny Solver",skinny_);
201 numICGS_ = pl_.
get(
"Num ICGS",2);
204 blkSize_ = pl_.
get(
"Block Size", problem_->getNEV());
208 int osProc = pl.
get(
"Output Processor", 0);
214 osp = Teuchos::getParameter<Teuchos::RCP<Teuchos::FancyOStream> >(pl,
"Output Stream");
222 if (Teuchos::isParameterType<int>(pl_,
"Verbosity")) {
223 verbosity = pl_.
get(
"Verbosity", verbosity);
225 verbosity = (int)Teuchos::getParameter<Anasazi::MsgType>(pl_,
"Verbosity");
234 template<
class ScalarType,
class MV,
class OP>
242 const int nev = problem_->getNEV();
249 out = Teuchos::getFancyOStream(Teuchos::rcpFromRef(printer_->stream(
Debug)));
251 *out <<
"Entering Anasazi::RTRSolMgr::solve()\n";
270 maxtest = Teuchos::null;
280 if (maxtest != Teuchos::null) alltests.
push_back(maxtest);
285 if ( printer_->isVerbosity(
Debug) ) {
300 bool leftMost =
true;
301 if (whch_ ==
"LR" || whch_ ==
"LM") {
304 pl_.set<
bool>(
"Leftmost",leftMost);
306 if (skinny_ ==
false) {
316 if (probauxvecs != Teuchos::null) {
321 "Anasazi::RTRSolMgr requires block size >= requested number of eigenvalues.");
325 std::vector<MagnitudeType> foundvals;
329 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
332 rtr_solver->iterate();
333 numIters_ = rtr_solver->getNumIters();
335 catch (
const std::exception &e) {
337 printer_->stream(
Anasazi::Errors) <<
"Exception: " << e.what() << endl;
340 problem_->setSolution(sol);
345 if (convtest->getStatus() ==
Passed || (maxtest != Teuchos::null && maxtest->getStatus() ==
Passed))
347 int num = convtest->howMany();
349 std::vector<int> ind = convtest->whichVecs();
351 foundvecs = MVT::CloneCopy(*rtr_solver->getRitzVectors(),ind);
353 foundvals.resize(num);
354 std::vector<Value<ScalarType> > all = rtr_solver->getRitzValues();
355 for (
int i=0; i<num; i++) {
356 foundvals[i] = all[ind[i]].realpart;
362 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"Anasazi::RTRSolMgr::solve(): solver returned without satisfy status test.");
368 sol.
Evecs = foundvecs;
371 for (
int i=0; i<sol.
numVecs; i++) {
372 sol.
Evals[i].realpart = foundvals[i];
375 sol.
index.resize(numfound,0);
378 rtr_solver->currentStatus(printer_->stream(
FinalSummary));
381 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
388 problem_->setSolution(sol);
389 printer_->stream(
Debug) <<
"Returning " << sol.
numVecs <<
" eigenpairs to eigenproblem." << endl;
Pure virtual base class which describes the basic interface for a solver manager. ...
std::vector< Value< ScalarType > > Evals
The computed eigenvalues.
ResType
Enumerated type used to specify which residual norm used by residual norm status tests.
A special StatusTest for printing other status tests.
This class defines the interface required by an eigensolver and status test class to compute solution...
RTRSolMgr(const Teuchos::RCP< Eigenproblem< ScalarType, MV, OP > > &problem, Teuchos::ParameterList &pl)
Basic constructor for RTRSolMgr.
An implementation of the Anasazi::SortManager that performs a collection of common sorting techniques...
basic_FancyOStream & setShowProcRank(const bool showProcRank)
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Virtual base class which defines basic traits for the operator type.
Teuchos::RCP< MV > Evecs
The computed eigenvectors.
An implementation of the Anasazi::GenOrthoManager that performs orthogonalization using iterated clas...
Status test for forming logical combinations of other status tests.
The Anasazi::SolverManager is a templated virtual base class that defines the basic interface that an...
The Anasazi::RTRSolMgr provides a simple solver manager over the RTR eigensolver. For more informatio...
virtual ~RTRSolMgr()
Destructor.
Basic implementation of the Anasazi::SortManager class.
int getNumIters() const
Get the iteration count for the most recent call to solve.
Output managers remove the need for the eigensolver to know any information about the required output...
A status test for testing the norm of the eigenvectors residuals along with a set of auxiliary eigenv...
bool isParameter(const std::string &name) const
int numVecs
The number of computed eigenpairs.
ReturnType solve()
This method performs possibly repeated calls to the underlying eigensolver's iterate() routine until ...
Teuchos::RCP< MV > Espace
An orthonormal basis for the computed eigenspace.
Abstract class definition for Anasazi Output Managers.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Abstract base class which defines the interface required by an eigensolver and status test class to c...
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="", const bool ignoreZeroTimers=false)
ReturnType
Enumerated type used to pass back information from a solver manager.
Output managers remove the need for the eigensolver to know any information about the required output...
A status test for testing the norm of the eigenvectors residuals.
Traits class which defines basic operations on multivectors.
std::vector< int > index
An index into Evecs to allow compressed storage of eigenvectors for real, non-Hermitian problems...
basic_FancyOStream & setShowAllFrontMatter(const bool showAllFrontMatter)
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
Struct for storing an eigenproblem solution.
const Eigenproblem< ScalarType, MV, OP > & getProblem() const
Return the eigenvalue problem.
A status test for testing the number of iterations.
Status test for testing the number of iterations.
void push_back(const value_type &x)
Special StatusTest for printing status tests.
A status test for testing the norm of the eigenvectors residuals along with a set of auxiliary eigenv...
Status test for forming logical combinations of other status tests.
Types and exceptions used within Anasazi solvers and interfaces.
Abstract class definition for Anasazi output stream.
Teuchos::Array< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return the timers for this object.
A status test for testing the norm of the eigenvectors residuals.
Basic implementation of the Anasazi::OrthoManager class.
Class which provides internal utilities for the Anasazi solvers.