150        Teuchos::ParameterList &pl ) :
 
  160  TEUCHOS_TEST_FOR_EXCEPTION(problem_ == Teuchos::null,              std::invalid_argument, 
"Problem not given to solver manager.");
 
  161  TEUCHOS_TEST_FOR_EXCEPTION(!problem_->isProblemSet(),              std::invalid_argument, 
"Problem not set.");
 
  162  TEUCHOS_TEST_FOR_EXCEPTION(!problem_->isHermitian(),               std::invalid_argument, 
"Problem not symmetric.");
 
  163  TEUCHOS_TEST_FOR_EXCEPTION(problem_->getInitVec() == Teuchos::null,std::invalid_argument, 
"Problem does not contain initial vectors to clone from.");
 
  165  whch_ = pl.get(
"Which",
"SR");
 
  166  TEUCHOS_TEST_FOR_EXCEPTION(whch_ != 
"SM" && whch_ != 
"LM" && whch_ != 
"SR" && whch_ != 
"LR",
 
  168                     "SimpleLOBPCGSolMgr: \"Which\" parameter must be SM, LM, SR or LR.");
 
  170  tol_ = pl.get(
"Convergence Tolerance",tol_);
 
  171  TEUCHOS_TEST_FOR_EXCEPTION(tol_ <= 0,
 
  173                     "SimpleLOBPCGSolMgr: \"Tolerance\" parameter must be strictly postiive.");
 
  177  osProc_ = pl.get(
"Output Processor", osProc_);
 
  180  if (pl.isParameter(
"Output Stream")) {
 
  181    osp_ = Teuchos::getParameter<Teuchos::RCP<Teuchos::FancyOStream> >(pl,
"Output Stream");
 
  188  if (pl.isParameter(
"Verbosity")) {
 
  189    if (Teuchos::isParameterType<int>(pl,
"Verbosity")) {
 
  190      verb_ = pl.get(
"Verbosity", verb_);
 
  192      verb_ = (int)Teuchos::getParameter<Anasazi::MsgType>(pl,
"Verbosity");
 
  197  blockSize_= pl.get(
"Block Size",problem_->getNEV());
 
  198  TEUCHOS_TEST_FOR_EXCEPTION(blockSize_ <= 0,
 
  200                     "SimpleLOBPCGSolMgr: \"Block Size\" parameter must be strictly positive.");
 
  202  maxIters_ = pl.get(
"Maximum Iterations",maxIters_);
 
 
  217  Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP> > max;
 
  224  Teuchos::RCP<StatusTestResNorm<ScalarType,MV,OP> > norm
 
  226  Teuchos::Array< Teuchos::RCP<StatusTest<ScalarType,MV,OP> > > alltests;
 
  227  alltests.push_back(norm);
 
  228  if (max != Teuchos::null) alltests.push_back(max);
 
  229  Teuchos::RCP<StatusTestCombo<ScalarType,MV,OP> > combo
 
  234  Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP> > outputtest
 
  237  Teuchos::RCP<SVQBOrthoManager<ScalarType,MV,OP> > ortho
 
  240  Teuchos::ParameterList plist;
 
  241  plist.set(
"Block Size",blockSize_);
 
  242  plist.set(
"Full Ortho",
true);
 
  245  Teuchos::RCP<LOBPCG<ScalarType,MV,OP> > lobpcg_solver
 
  248  if (problem_->getAuxVecs() != Teuchos::null) {
 
  249    lobpcg_solver->setAuxVecs( Teuchos::tuple<Teuchos::RCP<const MV> >(problem_->getAuxVecs()) );
 
  253  int nev = problem_->getNEV();
 
  254  Teuchos::Array< Teuchos::RCP<MV> > foundvecs;
 
  255  Teuchos::Array< Teuchos::RCP< std::vector<MagnitudeType> > > foundvals;
 
  256  while (numfound < nev) {
 
  258    if (nev - numfound < blockSize_) {
 
  259      norm->setQuorum(nev-numfound);
 
  264      lobpcg_solver->iterate();
 
  266    catch (
const std::exception &e) {
 
  268      printer->stream(
Anasazi::Errors) << 
"Exception: " << e.what() << std::endl;
 
  271      problem_->setSolution(sol);
 
  276    if (norm->getStatus() == 
Passed) {
 
  278      int num = norm->howMany();
 
  280      TEUCHOS_TEST_FOR_EXCEPTION(num < blockSize_ && num+numfound < nev,
 
  282                         "Anasazi::SimpleLOBPCGSolMgr::solve(): logic error.");
 
  283      std::vector<int> ind = norm->whichVecs();
 
  285      if (num + numfound > nev) {
 
  286        num = nev - numfound;
 
  291      Teuchos::RCP<MV> newvecs = MVT::CloneCopy(*lobpcg_solver->getRitzVectors(),ind);
 
  293      foundvecs.push_back(newvecs);
 
  295      Teuchos::Array<Teuchos::RCP<const MV> > auxvecs = lobpcg_solver->getAuxVecs();
 
  296      auxvecs.push_back(newvecs);
 
  298      lobpcg_solver->setAuxVecs(auxvecs);
 
  301      Teuchos::RCP<std::vector<MagnitudeType> > newvals = Teuchos::rcp( 
new std::vector<MagnitudeType>(num) );
 
  302      std::vector<Value<ScalarType> > all = lobpcg_solver->getRitzValues();
 
  303      for (
int i=0; i<num; i++) {
 
  304        (*newvals)[i] = all[ind[i]].realpart;
 
  306      foundvals.push_back(newvals);
 
  310    else if (max != Teuchos::null && max->getStatus() == 
Passed) {
 
  312      int num = norm->howMany();
 
  313      std::vector<int> ind = norm->whichVecs();
 
  317        Teuchos::RCP<MV> newvecs = MVT::CloneCopy(*lobpcg_solver->getRitzVectors(),ind);
 
  319        foundvecs.push_back(newvecs);
 
  323        Teuchos::RCP<std::vector<MagnitudeType> > newvals = Teuchos::rcp( 
new std::vector<MagnitudeType>(num) );
 
  324        std::vector<Value<ScalarType> > all = lobpcg_solver->getRitzValues();
 
  325        for (
int i=0; i<num; i++) {
 
  326          (*newvals)[i] = all[ind[i]].realpart;
 
  328        foundvals.push_back(newvals);
 
  335      TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"Anasazi::SimpleLOBPCGSolMgr::solve(): solver returned without satisfy status test.");
 
  339  TEUCHOS_TEST_FOR_EXCEPTION(foundvecs.size() != foundvals.size(),std::logic_error,
"Anasazi::SimpleLOBPCGSolMgr::solve(): inconsistent array sizes");
 
  346    sol.
Evecs = MVT::Clone(*problem_->getInitVec(),numfound);
 
  349    sol.
Evecs = Teuchos::null;
 
  353  std::vector<MagnitudeType> vals(numfound);
 
  354  sol.
Evals.resize(numfound);
 
  356  sol.
index.resize(numfound,0);
 
  359  for (
unsigned int i=0; i<foundvals.size(); i++) {
 
  360    TEUCHOS_TEST_FOR_EXCEPTION((
signed int)(foundvals[i]->size()) != MVT::GetNumberVecs(*foundvecs[i]), std::logic_error, 
"Anasazi::SimpleLOBPCGSolMgr::solve(): inconsistent sizes");
 
  361    unsigned int lclnum = foundvals[i]->size();
 
  362    std::vector<int> lclind(lclnum);
 
  363    for (
unsigned int j=0; j<lclnum; j++) lclind[j] = curttl+j;
 
  365    MVT::SetBlock(*foundvecs[i],lclind,*sol.
Evecs);
 
  367    std::copy( foundvals[i]->begin(), foundvals[i]->end(), vals.begin()+curttl );
 
  371  TEUCHOS_TEST_FOR_EXCEPTION( curttl != sol.
numVecs, std::logic_error, 
"Anasazi::SimpleLOBPCGSolMgr::solve(): inconsistent sizes");
 
  375    std::vector<int> order(sol.
numVecs);
 
  376    sorter->sort(vals,Teuchos::rcpFromRef(order),sol.
numVecs);
 
  378    for (
int i=0; i<sol.
numVecs; i++) {
 
  379      sol.
Evals[i].realpart = vals[i];
 
  380      sol.
Evals[i].imagpart = MT::zero();
 
  388  lobpcg_solver->currentStatus(printer->stream(
FinalSummary));
 
  391#ifdef ANASAZI_TEUCHOS_TIME_MONITOR 
  393    Teuchos::TimeMonitor::summarize( printer->stream( 
TimingDetails ) );
 
  398  problem_->setSolution(sol);
 
  399  printer->stream(
Debug) << 
"Returning " << sol.
numVecs << 
" eigenpairs to eigenproblem." << std::endl;
 
  402  numIters_ = lobpcg_solver->getNumIters();