154 Teuchos::ParameterList &pl ) :
158 convtol_(MT::prec()),
162#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
163 _timerSolve(Teuchos::TimeMonitor::getNewTimer(
"Anasazi: RTRSolMgr::solve()")),
167 TEUCHOS_TEST_FOR_EXCEPTION(problem_ == Teuchos::null, std::invalid_argument,
"Problem not given to solver manager.");
168 TEUCHOS_TEST_FOR_EXCEPTION(!problem_->isProblemSet(), std::invalid_argument,
"Problem not set.");
169 TEUCHOS_TEST_FOR_EXCEPTION(!problem_->isHermitian(), std::invalid_argument,
"Problem not symmetric.");
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");
175 TEUCHOS_TEST_FOR_EXCEPTION(whch_ !=
"SR" && whch_ !=
"LR",
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;
189 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
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);
211 Teuchos::RCP<Teuchos::FancyOStream> osp;
213 if (pl.isParameter(
"Output Stream")) {
214 osp = Teuchos::getParameter<Teuchos::RCP<Teuchos::FancyOStream> >(pl,
"Output Stream");
221 if (pl_.isParameter(
"Verbosity")) {
222 if (Teuchos::isParameterType<int>(pl_,
"Verbosity")) {
223 verbosity = pl_.get(
"Verbosity", verbosity);
225 verbosity = (int)Teuchos::getParameter<Anasazi::MsgType>(pl_,
"Verbosity");
242 const int nev = problem_->getNEV();
248 Teuchos::RCP<Teuchos::FancyOStream>
249 out = Teuchos::getFancyOStream(Teuchos::rcpFromRef(printer_->stream(
Debug)));
250 out->setShowAllFrontMatter(
false).setShowProcRank(
true);
251 *out <<
"Entering Anasazi::RTRSolMgr::solve()\n";
261 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > maxtest;
262 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > ordertest;
263 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > combotest;
264 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > convtest;
270 maxtest = Teuchos::null;
278 Teuchos::Array<Teuchos::RCP<StatusTest<ScalarType,MV,OP> > > alltests;
279 alltests.push_back(ordertest);
280 if (maxtest != Teuchos::null) alltests.push_back(maxtest);
284 Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP> > outputtest;
285 if ( printer_->isVerbosity(
Debug) ) {
294 Teuchos::RCP<ICGSOrthoManager<ScalarType,MV,OP> > ortho
300 bool leftMost =
true;
301 if (whch_ ==
"LR" || whch_ ==
"LM") {
304 pl_.set<
bool>(
"Leftmost",leftMost);
305 Teuchos::RCP<RTRBase<ScalarType,MV,OP> > rtr_solver;
306 if (skinny_ ==
false) {
315 Teuchos::RCP< const MV > probauxvecs = problem_->getAuxVecs();
316 if (probauxvecs != Teuchos::null) {
317 rtr_solver->setAuxVecs( Teuchos::tuple< Teuchos::RCP<const MV> >(probauxvecs) );
320 TEUCHOS_TEST_FOR_EXCEPTION(rtr_solver->getBlockSize() < problem_->getNEV(),std::logic_error,
321 "Anasazi::RTRSolMgr requires block size >= requested number of eigenvalues.");
324 Teuchos::RCP<MV> foundvecs;
325 std::vector<MagnitudeType> foundvals;
329#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
330 Teuchos::TimeMonitor slvtimer(*_timerSolve);
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
383 Teuchos::TimeMonitor::summarize( printer_->stream(
TimingDetails ) );
388 problem_->setSolution(sol);
389 printer_->stream(
Debug) <<
"Returning " << sol.
numVecs <<
" eigenpairs to eigenproblem." << endl;