130 typedef Teuchos::ScalarTraits<ScalarType> SCT;
131 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
132 typedef Teuchos::ScalarTraits<MagnitudeType> MT;
160 Teuchos::ParameterList &
pl );
182 std::vector<Value<ScalarType> >
ret( ritzValues_ );
192 Teuchos::Array<Teuchos::RCP<Teuchos::Time> >
getTimers()
const {
193 return Teuchos::tuple(timerSolve_, timerRestarting_);
236 Teuchos::RCP<Eigenproblem<ScalarType,MV,OP> > problem_;
237 Teuchos::RCP<SortManager<MagnitudeType> > sort_;
239 std::string whch_, ortho_;
240 MagnitudeType ortho_kappa_;
242 MagnitudeType convtol_;
244 bool relconvtol_,conjSplit_;
245 int blockSize_, numBlocks_, stepSize_, nevBlocks_, xtra_nevBlocks_;
248 bool inSituRestart_, dynXtraNev_;
251 std::vector<Value<ScalarType> > ritzValues_;
254 Teuchos::RCP<Teuchos::Time> timerSolve_, timerRestarting_;
256 Teuchos::RCP<Teuchos::FancyOStream> osp_;
258 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > globalTest_;
259 Teuchos::RCP<StatusTest<ScalarType,MV,OP> > debugTest_;
268 Teuchos::ParameterList &
pl ) :
284 inSituRestart_(
false),
295 TEUCHOS_TEST_FOR_EXCEPTION(problem_->getInitVec() == Teuchos::null, std::invalid_argument,
"Problem does not contain initial vectors to clone from.");
297 const int nev = problem_->getNEV();
300 convtol_ =
pl.get(
"Convergence Tolerance",MT::prec());
301 relconvtol_ =
pl.get(
"Relative Convergence Tolerance",relconvtol_);
304 maxRestarts_ =
pl.get(
"Maximum Restarts",maxRestarts_);
307 blockSize_ =
pl.get(
"Block Size",1);
309 "Anasazi::BlockKrylovSchurSolMgr: \"Block Size\" must be strictly positive.");
312 xtra_nevBlocks_ =
pl.get(
"Extra NEV Blocks",0);
313 if (
nev%blockSize_) {
314 nevBlocks_ =
nev/blockSize_ + 1;
316 nevBlocks_ =
nev/blockSize_;
322 if (
pl.isParameter(
"Dynamic Extra NEV")) {
323 if (Teuchos::isParameterType<bool>(
pl,
"Dynamic Extra NEV")) {
324 dynXtraNev_ =
pl.get(
"Dynamic Extra NEV",dynXtraNev_);
326 dynXtraNev_ = ( Teuchos::getParameter<int>(
pl,
"Dynamic Extra NEV") != 0 );
330 numBlocks_ =
pl.get(
"Num Blocks",3*nevBlocks_);
332 "Anasazi::BlockKrylovSchurSolMgr: \"Num Blocks\" must be strictly positive and large enough to compute the requested eigenvalues.");
335 std::invalid_argument,
336 "Anasazi::BlockKrylovSchurSolMgr: Potentially impossible orthogonality requests. Reduce basis size.");
340 stepSize_ =
pl.get(
"Step Size", (maxRestarts_+1)*(numBlocks_+1));
342 stepSize_ =
pl.get(
"Step Size", numBlocks_+1);
345 "Anasazi::BlockKrylovSchurSolMgr: \"Step Size\" must be strictly positive.");
348 if (
pl.isParameter(
"Sort Manager")) {
349 sort_ = Teuchos::getParameter<Teuchos::RCP<Anasazi::SortManager<MagnitudeType> > >(
pl,
"Sort Manager");
352 whch_ =
pl.get(
"Which",whch_);
353 TEUCHOS_TEST_FOR_EXCEPTION(whch_ !=
"SM" && whch_ !=
"LM" && whch_ !=
"SR" && whch_ !=
"LR" && whch_ !=
"SI" && whch_ !=
"LI",
354 std::invalid_argument,
"Invalid sorting string.");
359 ortho_ =
pl.get(
"Orthogonalization",ortho_);
360 if (ortho_ !=
"DGKS" && ortho_ !=
"SVQB" && ortho_ !=
"ICGS") {
365 ortho_kappa_ =
pl.get(
"Orthogonalization Constant",ortho_kappa_);
369 osProc_ =
pl.get(
"Output Processor", osProc_);
372 if (
pl.isParameter(
"Output Stream")) {
373 osp_ = Teuchos::getParameter<Teuchos::RCP<Teuchos::FancyOStream> >(
pl,
"Output Stream");
380 if (
pl.isParameter(
"Verbosity")) {
381 if (Teuchos::isParameterType<int>(
pl,
"Verbosity")) {
382 verbosity_ =
pl.get(
"Verbosity", verbosity_);
384 verbosity_ = (
int)Teuchos::getParameter<Anasazi::MsgType>(
pl,
"Verbosity");
389 if (
pl.isParameter(
"In Situ Restarting")) {
390 if (Teuchos::isParameterType<bool>(
pl,
"In Situ Restarting")) {
391 inSituRestart_ =
pl.get(
"In Situ Restarting",inSituRestart_);
393 inSituRestart_ = ( Teuchos::getParameter<int>(
pl,
"In Situ Restarting") != 0 );
397 printNum_ =
pl.get<
int>(
"Print Number of Ritz Values",printNum_);
406 const int nev = problem_->getNEV();
407 ScalarType
one = Teuchos::ScalarTraits<ScalarType>::one();
408 ScalarType
zero = Teuchos::ScalarTraits<ScalarType>::zero();
410 Teuchos::BLAS<int,ScalarType>
blas;
411 Teuchos::LAPACK<int,ScalarType>
lapack;
421 Teuchos::RCP<StatusTest<ScalarType,MV,OP> >
convtest;
422 if (globalTest_ == Teuchos::null) {
428 Teuchos::RCP<StatusTestWithOrdering<ScalarType,MV,OP> >
ordertest
431 Teuchos::Array<Teuchos::RCP<StatusTest<ScalarType,MV,OP> > >
alltests;
434 if (debugTest_ != Teuchos::null)
alltests.push_back(debugTest_);
436 Teuchos::RCP<StatusTestCombo<ScalarType,MV,OP> >
combotest
439 Teuchos::RCP<StatusTestOutput<ScalarType,MV,OP> >
outputtest;
449 Teuchos::RCP<OrthoManager<ScalarType,MV> >
ortho;
450 if (ortho_==
"SVQB") {
452 }
else if (ortho_==
"DGKS") {
453 if (ortho_kappa_ <= 0) {
458 }
else if (ortho_==
"ICGS") {
461 TEUCHOS_TEST_FOR_EXCEPTION(ortho_!=
"SVQB"&&ortho_!=
"DGKS"&&ortho_!=
"ICGS",std::logic_error,
"Anasazi::BlockKrylovSchurSolMgr::solve(): Invalid orthogonalization type.");
466 Teuchos::ParameterList
plist;
467 plist.set(
"Block Size",blockSize_);
468 plist.set(
"Num Blocks",numBlocks_);
469 plist.set(
"Step Size",stepSize_);
470 if (printNum_ == -1) {
471 plist.set(
"Print Number of Ritz Values",nevBlocks_*blockSize_);
474 plist.set(
"Print Number of Ritz Values",printNum_);
479 Teuchos::RCP<BlockKrylovSchur<ScalarType,MV,OP> >
bks_solver
482 Teuchos::RCP< const MV >
probauxvecs = problem_->getAuxVecs();
498 if (maxRestarts_ > 0) {
499 if (inSituRestart_==
true) {
501 workMV = MVT::Clone( *problem_->getInitVec(), 1 );
504 if (problem_->isHermitian()) {
505 workMV = MVT::Clone( *problem_->getInitVec(), (nevBlocks_+
maxXtraBlocks)*blockSize_ + blockSize_ );
508 workMV = MVT::Clone( *problem_->getInitVec(), (nevBlocks_+
maxXtraBlocks)*blockSize_ + 1 + blockSize_ );
518 problem_->setSolution(
sol);
525#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
526 Teuchos::TimeMonitor
slvtimer(*timerSolve_);
558 (!problem_->isHermitian() && !conjSplit_ && (
bks_solver->getCurSubspaceDim()+1 ==
bks_solver->getMaxSubspaceDim())) ) {
574#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
575 Teuchos::TimeMonitor
restimer(*timerRestarting_);
586 else if ( xtra_nevBlocks_ )
595 printer->stream(
Debug) <<
" Performing restart number " <<
numRestarts <<
" of " << maxRestarts_ << std::endl << std::endl;
596 printer->stream(
Debug) <<
" - Current NEV blocks is " <<
cur_nevBlocks <<
", the minimum is " << nevBlocks_*blockSize_ << std::endl;
618 if (problem_->isHermitian() && conjSplit_)
621 <<
" Eigenproblem is Hermitian, complex eigenvalues have been detected, and eigenvalues of interest split a conjugate pair!!!"
623 <<
" Block Krylov-Schur eigensolver cannot guarantee correct behavior in this situation, please turn Hermitian flag off!!!"
633 std::vector<int>
curind( curDim );
645 Teuchos::RCP<MV>
newF;
646 if (inSituRestart_) {
650 Teuchos::SerialDenseMatrix<int,ScalarType>
copyQnev(Teuchos::Copy,
Qnev);
657 "Anasazi::BlockKrylovSchurSolMgr::solve(): error calling GEQRF during restarting.");
665 for (
int j=0;
j<R.numCols();
j++) {
666 R(
j,
j) = SCT::magnitude(R(
j,
j)) - 1.0;
667 for (
int i=
j+1;
i<R.numRows();
i++) {
671 printer->stream(
Debug) <<
"||Triangular factor of Su - I||: " << R.normFrobenius() << std::endl;
689 MVT::MvScale(*
newV,
d);
692 curind.resize(blockSize_);
705 curind.resize(blockSize_);
711 curind.resize(blockSize_);
712 for (
int i=0;
i<blockSize_;
i++) {
curind[
i] = curDim +
i; }
714 for (
int i=0;
i<blockSize_;
i++) {
curind[
i] =
i; }
716 newF = Teuchos::null;
722 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> >
newH =
726 Teuchos::SerialDenseMatrix<int,ScalarType>
oldB(Teuchos::View, *(
oldState.H), blockSize_, blockSize_, curDim, curDim-blockSize_);
729 Teuchos::SerialDenseMatrix<int,ScalarType>
subQ(Teuchos::View, *(
oldState.Q), blockSize_,
cur_nevBlocks, curDim-blockSize_);
742 if (inSituRestart_) {
759 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
"Anasazi::BlockKrylovSchurSolMgr::solve(): Invalid return from bks_solver::iterate().");
764 <<
"Anasazi::BlockKrylovSchurSolMgr::solve() caught unexpected exception from Anasazi::BlockKrylovSchur::iterate() at iteration " <<
bks_solver->getNumIters() << std::endl
765 <<
err.what() << std::endl
766 <<
"Anasazi::BlockKrylovSchurSolMgr::solve() returning Unconverged with no solutions." << std::endl;
779 printer->stream(
Debug) <<
"ordertest->howMany() : " <<
sol.numVecs << std::endl;
780 std::vector<int> whichVecs =
ordertest->whichVecs();
783 if (
sol.numVecs > 0) {
787 for (
int i=0;
i<(
int)ritzValues_.size(); ++
i) {
788 printer->stream(
Debug) << ritzValues_[
i].realpart <<
" + i " << ritzValues_[
i].imagpart <<
", Index = " <<
tmpIndex[
i] << std::endl;
790 printer->stream(
Debug) <<
"Number of converged eigenpairs (before) = " <<
sol.numVecs << std::endl;
791 for (
int i=0;
i<
sol.numVecs; ++
i) {
792 printer->stream(
Debug) <<
"whichVecs[" <<
i <<
"] = " << whichVecs[
i] <<
", tmpIndex[" << whichVecs[
i] <<
"] = " <<
tmpIndex[whichVecs[
i]] << std::endl;
795 printer->stream(
Debug) <<
"There is a conjugate pair on the boundary, resizing sol.numVecs" << std::endl;
796 whichVecs.push_back(whichVecs[
sol.numVecs-1]+1);
798 for (
int i=0;
i<
sol.numVecs; ++
i) {
799 printer->stream(
Debug) <<
"whichVecs[" <<
i <<
"] = " << whichVecs[
i] <<
", tmpIndex[" << whichVecs[
i] <<
"] = " <<
tmpIndex[whichVecs[
i]] << std::endl;
805 printer->stream(
Debug) <<
"Number of converged eigenpairs (after) = " <<
sol.numVecs << std::endl;
806 printer->stream(
Debug) <<
"whichVecs[sol.numVecs-1] > sol.numVecs-1 : " << whichVecs[
sol.numVecs-1] <<
" > " <<
sol.numVecs-1 << std::endl;
807 if (whichVecs[
sol.numVecs-1] > (
sol.numVecs-1)) {
823 sol.Evecs = MVT::CloneCopy( *(
bks_solver->getRitzVectors()) );
828 sol.Evals.resize(
sol.numVecs);
829 sol.index.resize(
sol.numVecs);
838 sol.Evecs = MVT::CloneCopy( *(
bks_solver->getRitzVectors()), whichVecs );
850#ifdef ANASAZI_TEUCHOS_TIME_MONITOR
856 problem_->setSolution(
sol);
857 printer->stream(
Debug) <<
"Returning " <<
sol.numVecs <<
" eigenpairs to eigenproblem." << std::endl;
static void applyHouse(int k, MV &V, const Teuchos::SerialDenseMatrix< int, ScalarType > &H, const std::vector< ScalarType > &tau, Teuchos::RCP< MV > workMV=Teuchos::null)
Apply a sequence of Householder reflectors (from GEQRF) to a multivector, using minimal workspace.