12 #ifndef ANASAZI_IRTR_HPP
13 #define ANASAZI_IRTR_HPP
53 template <
class ScalarType,
class MV,
class OP>
119 std::vector<std::string> stopReasons_;
123 const MagnitudeType ZERO;
124 const MagnitudeType ONE;
129 void solveTRSubproblem();
132 MagnitudeType rho_prime_;
135 MagnitudeType normgradf0_;
138 trRetType innerStop_;
141 int innerIters_, totalInnerIters_;
152 template <
class ScalarType,
class MV,
class OP>
161 RTRBase<ScalarType,MV,OP>(problem,sorter,printer,tester,ortho,params,
"IRTR",false),
167 stopReasons_.push_back(
"n/a");
168 stopReasons_.push_back(
"maximum iterations");
169 stopReasons_.push_back(
"negative curvature");
170 stopReasons_.push_back(
"exceeded TR");
171 stopReasons_.push_back(
"kappa convergence");
172 stopReasons_.push_back(
"theta convergence");
174 rho_prime_ = params.
get(
"Rho Prime",0.5);
176 "Anasazi::IRTR::constructor: rho_prime must be in (0,1).");
178 useSA_ = params.
get<
bool>(
"Use SA",
false);
191 template <
class ScalarType,
class MV,
class OP>
202 using Teuchos::tuple;
204 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
211 innerStop_ = MAXIMUM_ITERATIONS;
213 const int n = MVT::GetGlobalLength(*this->eta_);
214 const int p = this->blockSize_;
215 const int d = n*p - (p*p+p)/2;
229 const double D2 = ONE/rho_prime_ - ONE;
231 std::vector<MagnitudeType> d_Hd(p), alpha(p), beta(p), z_r(p), zold_rold(p);
232 std::vector<MagnitudeType> eBe(p), eBd(p), dBd(p), new_eBe(p);
233 MagnitudeType r0_norm;
235 MVT::MvInit(*this->eta_ ,0.0);
236 MVT::MvInit(*this->Aeta_,0.0);
238 MVT::MvInit(*this->Beta_,0.0);
254 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
255 TimeMonitor lcltimer( *this->timerOrtho_ );
257 this->orthman_->projectGen(
259 tuple<PCMV>(this->BV_),tuple<PCMV>(this->V_),
false,
261 null,tuple<PCMV>(null), tuple<PCMV>(this->BV_));
262 if (this->leftMost_) {
263 MVT::MvScale(*this->R_,2.0);
266 MVT::MvScale(*this->R_,-2.0);
270 r0_norm = MAT::squareroot( RTRBase<ScalarType,MV,OP>::ginner(*this->R_) );
275 MagnitudeType kconv = r0_norm * this->conv_kappa_;
278 MagnitudeType tconv = MAT::pow(r0_norm,this->conv_theta_+ONE);
279 if (this->om_->isVerbosity(
Debug)) {
280 this->om_->stream(
Debug)
281 <<
" >> |r0| : " << r0_norm << endl
282 <<
" >> kappa conv : " << kconv << endl
283 <<
" >> theta conv : " << tconv << endl;
291 if (this->hasPrec_ && this->olsenPrec_)
293 std::vector<int> ind(this->blockSize_);
294 for (
int i=0; i<this->blockSize_; ++i) ind[i] = this->numAuxVecs_+i;
297 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
298 TimeMonitor prectimer( *this->timerPrec_ );
300 OPT::Apply(*this->Prec_,*this->BX_,*PBX);
301 this->counterPrec_ += this->blockSize_;
312 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
313 TimeMonitor prectimer( *this->timerPrec_ );
315 OPT::Apply(*this->Prec_,*this->R_,*this->Z_);
316 this->counterPrec_ += this->blockSize_;
318 if (this->olsenPrec_) {
319 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
320 TimeMonitor orthtimer( *this->timerOrtho_ );
322 this->orthman_->projectGen(
324 tuple<PCMV>(this->PBV_),tuple<PCMV>(this->V_),
false,
326 null,tuple<PCMV>(null), tuple<PCMV>(this->BV_));
329 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
330 TimeMonitor orthtimer( *this->timerOrtho_ );
332 this->orthman_->projectGen(
334 tuple<PCMV>(this->BV_),tuple<PCMV>(this->V_),
false,
336 null,tuple<PCMV>(null), tuple<PCMV>(this->BV_));
338 RTRBase<ScalarType,MV,OP>::ginnersep(*this->R_,*this->Z_,z_r);
341 RTRBase<ScalarType,MV,OP>::ginnersep(*this->R_,z_r);
344 if (this->om_->isVerbosity(
Debug )) {
346 typename RTRBase<ScalarType,MV,OP>::CheckList chk;
348 if (this->hasPrec_) chk.checkZ =
true;
349 this->om_->print(
Debug, this->accuracyCheck(chk,
"after computing gradient") );
353 typename RTRBase<ScalarType,MV,OP>::CheckList chk;
355 if (this->hasPrec_) chk.checkZ =
true;
356 this->om_->print(
OrthoDetails, this->accuracyCheck(chk,
"after computing gradient") );
360 MVT::MvAddMv(-ONE,*this->Z_,ZERO,*this->Z_,*this->delta_);
362 if (this->om_->isVerbosity(
Debug)) {
363 RCP<MV> Heta = MVT::Clone(*this->eta_,this->blockSize_);
365 MVT::MvAddMv(ONE,*this->Beta_,ZERO,*this->Beta_,*Heta);
366 std::vector<ScalarType> theta_comp(this->theta_.begin(),this->theta_.end());
367 MVT::MvScale(*Heta,theta_comp);
368 if (this->leftMost_) {
369 MVT::MvAddMv( 2.0,*this->Aeta_,-2.0,*Heta,*Heta);
372 MVT::MvAddMv(-2.0,*this->Aeta_, 2.0,*Heta,*Heta);
376 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
377 TimeMonitor lcltimer( *this->timerOrtho_ );
379 this->orthman_->projectGen(
381 tuple<PCMV>(this->BV_),tuple<PCMV>(this->V_),
false,
383 null,tuple<PCMV>(null), tuple<PCMV>(this->BV_));
386 std::vector<MagnitudeType> eg(this->blockSize_),
387 eHe(this->blockSize_);
388 RTRBase<ScalarType,MV,OP>::ginnersep(*this->eta_,*this->AX_,eg);
389 RTRBase<ScalarType,MV,OP>::ginnersep(*this->eta_,*Heta,eHe);
390 if (this->leftMost_) {
391 for (
int j=0; j<this->blockSize_; ++j) {
392 eg[j] = this->theta_[j] + 2*eg[j] + .5*eHe[j];
396 for (
int j=0; j<this->blockSize_; ++j) {
397 eg[j] = -this->theta_[j] - 2*eg[j] + .5*eHe[j];
400 this->om_->stream(
Debug)
401 <<
" Debugging checks: IRTR inner iteration " << innerIters_ << endl
402 <<
" >> m_X(eta) : " << std::accumulate(eg.begin(),eg.end(),0.0) << endl;
403 for (
int j=0; j<this->blockSize_; ++j) {
404 this->om_->stream(
Debug)
405 <<
" >> m_X(eta_" << j <<
") : " << eg[j] << endl;
412 for (innerIters_=1; innerIters_<=d; ++innerIters_) {
420 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
421 TimeMonitor lcltimer( *this->timerAOp_ );
423 OPT::Apply(*this->AOp_,*this->delta_,*this->Adelta_);
424 this->counterAOp_ += this->blockSize_;
427 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
428 TimeMonitor lcltimer( *this->timerBOp_ );
430 OPT::Apply(*this->BOp_,*this->delta_,*this->Bdelta_);
431 this->counterBOp_ += this->blockSize_;
434 MVT::MvAddMv(ONE,*this->delta_,ZERO,*this->delta_,*this->Bdelta_);
438 RTRBase<ScalarType,MV,OP>::ginnersep(*this->eta_ ,*this->Bdelta_,eBd);
439 RTRBase<ScalarType,MV,OP>::ginnersep(*this->delta_,*this->Bdelta_,dBd);
441 MVT::MvAddMv(ONE,*this->Bdelta_,ZERO,*this->Bdelta_,*this->Hdelta_);
443 std::vector<ScalarType> theta_comp(this->theta_.begin(),this->theta_.end());
444 MVT::MvScale(*this->Hdelta_,theta_comp);
446 if (this->leftMost_) {
447 MVT::MvAddMv( 2.0,*this->Adelta_,-2.0,*this->Hdelta_,*this->Hdelta_);
450 MVT::MvAddMv(-2.0,*this->Adelta_, 2.0,*this->Hdelta_,*this->Hdelta_);
454 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
455 TimeMonitor lcltimer( *this->timerOrtho_ );
457 this->orthman_->projectGen(
459 tuple<PCMV>(this->BV_),tuple<PCMV>(this->V_),
false,
461 null,tuple<PCMV>(null), tuple<PCMV>(this->BV_));
463 RTRBase<ScalarType,MV,OP>::ginnersep(*this->delta_,*this->Hdelta_,d_Hd);
467 for (
unsigned int j=0; j<alpha.size(); ++j)
469 alpha[j] = z_r[j]/d_Hd[j];
473 for (
unsigned int j=0; j<alpha.size(); ++j)
475 new_eBe[j] = eBe[j] + 2*alpha[j]*eBd[j] + alpha[j]*alpha[j]*dBd[j];
478 if (this->om_->isVerbosity(
Debug)) {
479 for (
unsigned int j=0; j<alpha.size(); j++) {
480 this->om_->stream(
Debug)
481 <<
" >> z_r[" << j <<
"] : " << z_r[j]
482 <<
" d_Hd[" << j <<
"] : " << d_Hd[j] << endl
483 <<
" >> eBe[" << j <<
"] : " << eBe[j]
484 <<
" neweBe[" << j <<
"] : " << new_eBe[j] << endl
485 <<
" >> eBd[" << j <<
"] : " << eBd[j]
486 <<
" dBd[" << j <<
"] : " << dBd[j] << endl;
491 std::vector<int> trncstep;
495 bool atleastonenegcur =
false;
496 for (
unsigned int j=0; j<d_Hd.size(); ++j) {
498 trncstep.push_back(j);
499 atleastonenegcur =
true;
501 else if (new_eBe[j] > D2) {
502 trncstep.push_back(j);
506 if (!trncstep.empty())
509 if (this->om_->isVerbosity(
Debug)) {
510 for (
unsigned int j=0; j<trncstep.size(); ++j) {
511 this->om_->stream(
Debug)
512 <<
" >> alpha[" << trncstep[j] <<
"] : " << alpha[trncstep[j]] << endl;
515 for (
unsigned int j=0; j<trncstep.size(); ++j) {
516 int jj = trncstep[j];
517 alpha[jj] = ( -eBd[jj] + MAT::squareroot(eBd[jj]*eBd[jj] + dBd[jj]*(D2-eBe[jj]) ) ) / dBd[jj];
519 if (this->om_->isVerbosity(
Debug)) {
520 for (
unsigned int j=0; j<trncstep.size(); ++j) {
521 this->om_->stream(
Debug)
522 <<
" >> tau[" << trncstep[j] <<
"] : " << alpha[trncstep[j]] << endl;
525 if (atleastonenegcur) {
526 innerStop_ = NEGATIVE_CURVATURE;
529 innerStop_ = EXCEEDED_TR;
538 std::vector<ScalarType> alpha_comp(alpha.begin(),alpha.end());
539 MVT::MvScale(*this->delta_,alpha_comp);
540 MVT::MvScale(*this->Adelta_,alpha_comp);
542 MVT::MvScale(*this->Bdelta_,alpha_comp);
544 MVT::MvScale(*this->Hdelta_,alpha_comp);
546 MVT::MvAddMv(ONE,*this->delta_ ,ONE,*this->eta_ ,*this->eta_);
547 MVT::MvAddMv(ONE,*this->Adelta_,ONE,*this->Aeta_,*this->Aeta_);
549 MVT::MvAddMv(ONE,*this->Bdelta_,ONE,*this->Beta_,*this->Beta_);
557 if (this->om_->isVerbosity(
Debug)) {
558 RCP<MV> Heta = MVT::Clone(*this->eta_,this->blockSize_);
560 MVT::MvAddMv(ONE,*this->Beta_,ZERO,*this->Beta_,*Heta);
562 std::vector<ScalarType> theta_comp(this->theta_.begin(),this->theta_.end());
563 MVT::MvScale(*Heta,theta_comp);
565 if (this->leftMost_) {
566 MVT::MvAddMv( 2.0,*this->Aeta_,-2.0,*Heta,*Heta);
569 MVT::MvAddMv(-2.0,*this->Aeta_, 2.0,*Heta,*Heta);
573 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
574 TimeMonitor lcltimer( *this->timerOrtho_ );
576 this->orthman_->projectGen(
578 tuple<PCMV>(this->BV_),tuple<PCMV>(this->V_),
false,
580 null,tuple<PCMV>(null), tuple<PCMV>(this->BV_));
583 std::vector<MagnitudeType> eg(this->blockSize_),
584 eHe(this->blockSize_);
585 RTRBase<ScalarType,MV,OP>::ginnersep(*this->eta_,*this->AX_,eg);
586 RTRBase<ScalarType,MV,OP>::ginnersep(*this->eta_,*Heta,eHe);
587 if (this->leftMost_) {
588 for (
int j=0; j<this->blockSize_; ++j) {
589 eg[j] = this->theta_[j] + 2*eg[j] + .5*eHe[j];
593 for (
int j=0; j<this->blockSize_; ++j) {
594 eg[j] = -this->theta_[j] - 2*eg[j] + .5*eHe[j];
597 this->om_->stream(
Debug)
598 <<
" Debugging checks: IRTR inner iteration " << innerIters_ << endl
599 <<
" >> m_X(eta) : " << std::accumulate(eg.begin(),eg.end(),0.0) << endl;
600 for (
int j=0; j<this->blockSize_; ++j) {
601 this->om_->stream(
Debug)
602 <<
" >> m_X(eta_" << j <<
") : " << eg[j] << endl;
608 if (!trncstep.empty()) {
616 MVT::MvAddMv(ONE,*this->Hdelta_,ONE,*this->R_,*this->R_);
619 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
620 TimeMonitor lcltimer( *this->timerOrtho_ );
622 this->orthman_->projectGen(
624 tuple<PCMV>(this->BV_),tuple<PCMV>(this->V_),
false,
626 null,tuple<PCMV>(null), tuple<PCMV>(this->BV_));
631 MagnitudeType r_norm = MAT::squareroot(RTRBase<ScalarType,MV,OP>::ginner(*this->R_,*this->R_));
639 if (this->om_->isVerbosity(
Debug)) {
640 this->om_->stream(
Debug)
641 <<
" >> |r" << innerIters_ <<
"| : " << r_norm << endl;
643 if ( r_norm <= ANASAZI_MIN(tconv,kconv) ) {
644 if (tconv <= kconv) {
645 innerStop_ = THETA_CONVERGENCE;
648 innerStop_ = KAPPA_CONVERGENCE;
660 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
661 TimeMonitor prectimer( *this->timerPrec_ );
663 OPT::Apply(*this->Prec_,*this->R_,*this->Z_);
664 this->counterPrec_ += this->blockSize_;
666 if (this->olsenPrec_) {
667 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
668 TimeMonitor orthtimer( *this->timerOrtho_ );
670 this->orthman_->projectGen(
672 tuple<PCMV>(this->PBV_),tuple<PCMV>(this->V_),
false,
674 null,tuple<PCMV>(null), tuple<PCMV>(this->BV_));
677 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
678 TimeMonitor orthtimer( *this->timerOrtho_ );
680 this->orthman_->projectGen(
682 tuple<PCMV>(this->BV_),tuple<PCMV>(this->V_),
false,
684 null,tuple<PCMV>(null), tuple<PCMV>(this->BV_));
686 RTRBase<ScalarType,MV,OP>::ginnersep(*this->R_,*this->Z_,z_r);
689 RTRBase<ScalarType,MV,OP>::ginnersep(*this->R_,z_r);
705 for (
unsigned int j=0; j<beta.size(); ++j) {
706 beta[j] = z_r[j]/(zold_rold[j]*alpha[j]);
709 std::vector<ScalarType> beta_comp(beta.begin(),beta.end());
710 MVT::MvScale(*this->delta_,beta_comp);
712 MVT::MvAddMv(-ONE,*this->Z_,ONE,*this->delta_,*this->delta_);
718 if (innerIters_ > d) innerIters_ = d;
720 this->om_->stream(
Debug)
721 <<
" >> stop reason is " << stopReasons_[innerStop_] << endl
729 template <
class ScalarType,
class MV,
class OP>
734 using Teuchos::tuple;
735 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
745 if (this->initialized_ ==
false) {
750 if (useSA_ ==
true) {
751 AA.
reshape(2*this->blockSize_,2*this->blockSize_);
752 BB.
reshape(2*this->blockSize_,2*this->blockSize_);
753 S.
reshape(2*this->blockSize_,2*this->blockSize_);
756 AA.
reshape(this->blockSize_,this->blockSize_);
757 BB.
reshape(this->blockSize_,this->blockSize_);
758 S.
reshape(this->blockSize_,this->blockSize_);
763 innerStop_ = UNINITIALIZED;
766 while (this->tester_->checkStatus(
this) !=
Passed) {
769 if (this->om_->isVerbosity(
Debug)) {
770 this->currentStatus( this->om_->stream(
Debug) );
781 totalInnerIters_ += innerIters_;
784 if (this->om_->isVerbosity(
Debug ) ) {
789 chk.checkAEta =
true;
790 chk.checkBEta =
true;
791 this->om_->print(
Debug, this->accuracyCheck(chk,
"in iterate() after solveTRSubproblem()") );
792 this->om_->stream(
Debug)
797 if (useSA_ ==
false) {
801 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
802 TimeMonitor lcltimer( *this->timerLocalUpdate_ );
804 MVT::MvAddMv(ONE,*this->X_,ONE,*this->eta_,*this->delta_);
805 MVT::MvAddMv(ONE,*this->AX_,ONE,*this->Aeta_,*this->Adelta_);
807 MVT::MvAddMv(ONE,*this->BX_,ONE,*this->Beta_,*this->Bdelta_);
811 if (this->om_->isVerbosity(
Debug ) ) {
816 E(this->blockSize_,this->blockSize_);
817 MVT::MvTransMv(ONE,*this->delta_,*this->Bdelta_,XE);
818 MVT::MvTransMv(ONE,*this->eta_,*this->Beta_,E);
819 this->om_->stream(
Debug)
820 <<
" >> Error in AX+AEta == A(X+Eta) : " << Utils::errorEquality(*this->delta_,*this->Adelta_,this->AOp_) << endl
821 <<
" >> Error in BX+BEta == B(X+Eta) : " << Utils::errorEquality(*this->delta_,*this->Bdelta_,this->BOp_) << endl
822 <<
" >> norm( (X+Eta)^T B (X+Eta) ) : " << XE.normFrobenius() << endl
832 MagnitudeType oldfx = this->fx_;
833 std::vector<MagnitudeType> oldtheta(this->theta_), newtheta(AA.
numRows());
836 if (useSA_ ==
true) {
837 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
838 TimeMonitor lcltimer( *this->timerLocalProj_ );
841 AA12(
Teuchos::View,AA,this->blockSize_,this->blockSize_,0,this->blockSize_),
842 AA22(
Teuchos::View,AA,this->blockSize_,this->blockSize_,this->blockSize_,this->blockSize_);
844 BB12(
Teuchos::View,BB,this->blockSize_,this->blockSize_,0,this->blockSize_),
845 BB22(
Teuchos::View,BB,this->blockSize_,this->blockSize_,this->blockSize_,this->blockSize_);
846 MVT::MvTransMv(ONE,*this->X_ ,*this->AX_ ,AA11);
847 MVT::MvTransMv(ONE,*this->X_ ,*this->Aeta_,AA12);
848 MVT::MvTransMv(ONE,*this->eta_,*this->Aeta_,AA22);
849 MVT::MvTransMv(ONE,*this->X_ ,*this->BX_ ,BB11);
850 MVT::MvTransMv(ONE,*this->X_ ,*this->Beta_,BB12);
851 MVT::MvTransMv(ONE,*this->eta_,*this->Beta_,BB22);
854 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
855 TimeMonitor lcltimer( *this->timerLocalProj_ );
857 MVT::MvTransMv(ONE,*this->delta_,*this->Adelta_,AA);
858 MVT::MvTransMv(ONE,*this->delta_,*this->Bdelta_,BB);
860 this->om_->stream(
Debug) <<
"AA: " << std::endl <<
printMat(AA) << std::endl;;
861 this->om_->stream(
Debug) <<
"BB: " << std::endl <<
printMat(BB) << std::endl;;
863 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
864 TimeMonitor lcltimer( *this->timerDS_ );
866 ret = Utils::directSolver(AA.
numRows(),AA,Teuchos::rcpFromRef(BB),S,newtheta,rank,1);
868 this->om_->stream(
Debug) <<
"S: " << std::endl <<
printMat(S) << std::endl;;
869 TEUCHOS_TEST_FOR_EXCEPTION(ret != 0,std::logic_error,
"Anasazi::IRTR::iterate(): failure solving projected eigenproblem after retraction. ret == " << ret);
876 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
877 TimeMonitor lcltimer( *this->timerSort_ );
879 std::vector<int> order(newtheta.size());
881 this->sm_->sort(newtheta, Teuchos::rcpFromRef(order), -1);
883 Utils::permuteVectors(order,S);
887 std::copy(newtheta.begin(), newtheta.begin()+this->blockSize_, this->theta_.begin());
890 this->fx_ = std::accumulate(this->theta_.begin(),this->theta_.end(),ZERO);
894 if (this->om_->isVerbosity(
Debug ) ) {
905 MagnitudeType rhonum, rhoden, mxeta;
906 std::vector<MagnitudeType> eBe(this->blockSize_);
910 rhonum = oldfx - this->fx_;
915 for (
int i=0; i<this->blockSize_; ++i) {
916 rhoden += eBe[i]*oldtheta[i];
918 mxeta = oldfx - rhoden;
919 this->rho_ = rhonum / rhoden;
920 this->om_->stream(
Debug)
921 <<
" >> old f(x) is : " << oldfx << endl
922 <<
" >> new f(x) is : " << this->fx_ << endl
923 <<
" >> m_x(eta) is : " << mxeta << endl
924 <<
" >> rhonum is : " << rhonum << endl
925 <<
" >> rhoden is : " << rhoden << endl
926 <<
" >> rho is : " << this->rho_ << endl;
928 for (
int j=0; j<this->blockSize_; ++j) {
929 this->om_->stream(
Debug)
930 <<
" >> rho[" << j <<
"] : " << 1.0/(1.0+eBe[j]) << endl;
941 this->X_ = Teuchos::null;
942 this->BX_ = Teuchos::null;
943 std::vector<int> ind(this->blockSize_);
944 for (
int i=0; i<this->blockSize_; ++i) ind[i] = this->numAuxVecs_+i;
946 X = MVT::CloneViewNonConst(*this->V_,ind);
948 BX = MVT::CloneViewNonConst(*this->BV_,ind);
950 if (useSA_ ==
false) {
954 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
955 TimeMonitor lcltimer( *this->timerLocalUpdate_ );
957 MVT::MvTimesMatAddMv(ONE,*this->delta_,S,ZERO,*X);
958 MVT::MvTimesMatAddMv(ONE,*this->Adelta_,S,ZERO,*this->AX_);
960 MVT::MvTimesMatAddMv(ONE,*this->Bdelta_,S,ZERO,*BX);
969 Se(
Teuchos::View,S,this->blockSize_,this->blockSize_,this->blockSize_,0);
970 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
971 TimeMonitor lcltimer( *this->timerLocalUpdate_ );
974 MVT::MvTimesMatAddMv(ONE,* X ,Sx,ZERO,*this->delta_);
975 MVT::MvTimesMatAddMv(ONE,*this->eta_,Se,ONE ,*this->delta_);
976 MVT::MvAddMv(ONE,*this->delta_,ZERO,*this->delta_,*X);
978 MVT::MvTimesMatAddMv(ONE,*this->AX_ ,Sx,ZERO,*this->delta_);
979 MVT::MvTimesMatAddMv(ONE,*this->Aeta_,Se,ONE ,*this->delta_);
980 MVT::MvAddMv(ONE,*this->delta_,ZERO,*this->delta_,*this->AX_);
983 MVT::MvTimesMatAddMv(ONE,* BX ,Sx,ZERO,*this->delta_);
984 MVT::MvTimesMatAddMv(ONE,*this->Beta_,Se,ONE ,*this->delta_);
985 MVT::MvAddMv(ONE,*this->delta_,ZERO,*this->delta_,*BX);
991 this->X_ = MVT::CloneView(static_cast<const MV&>(*this->V_ ),ind);
992 this->BX_ = MVT::CloneView(static_cast<const MV&>(*this->BV_),ind);
998 #ifdef ANASAZI_TEUCHOS_TIME_MONITOR
999 TimeMonitor lcltimer( *this->timerCompRes_ );
1001 MVT::MvAddMv( ONE, *this->BX_, ZERO, *this->BX_, *this->R_ );
1002 std::vector<ScalarType> theta_comp(this->theta_.begin(),this->theta_.end());
1003 MVT::MvScale( *this->R_, theta_comp );
1004 MVT::MvAddMv( ONE, *this->AX_, -ONE, *this->R_, *this->R_ );
1008 this->Rnorms_current_ =
false;
1009 this->R2norms_current_ =
false;
1014 if (this->om_->isVerbosity(
Debug ) ) {
1021 this->om_->print(
Debug, this->accuracyCheck(chk,
"after local update") );
1027 this->om_->print(
OrthoDetails, this->accuracyCheck(chk,
"after local update") );
1037 template <
class ScalarType,
class MV,
class OP>
1042 os.setf(std::ios::scientific, std::ios::floatfield);
1045 os <<
"================================================================================" << endl;
1047 os <<
" IRTR Solver Status" << endl;
1049 os <<
"The solver is "<<(this->initialized_ ?
"initialized." :
"not initialized.") << endl;
1050 os <<
"The number of iterations performed is " << this->iter_ << endl;
1051 os <<
"The current block size is " << this->blockSize_ << endl;
1052 os <<
"The number of auxiliary vectors is " << this->numAuxVecs_ << endl;
1053 os <<
"The number of operations A*x is " << this->counterAOp_ << endl;
1054 os <<
"The number of operations B*x is " << this->counterBOp_ << endl;
1055 os <<
"The number of operations B*x by the orthomanager is " << this->orthman_->getOpCounter() << endl;
1056 os <<
"The number of operations Prec*x is " << this->counterPrec_ << endl;
1057 os <<
"Parameter rho_prime is " << rho_prime_ << endl;
1058 os <<
"Inner stopping condition was " << stopReasons_[innerStop_] << endl;
1059 os <<
"Number of inner iterations was " << innerIters_ << endl;
1060 os <<
"Total number of inner iterations is " << totalInnerIters_ << endl;
1061 os <<
"f(x) is " << this->fx_ << endl;
1063 os.setf(std::ios_base::right, std::ios_base::adjustfield);
1065 if (this->initialized_) {
1067 os <<
"CURRENT EIGENVALUE ESTIMATES "<<endl;
1068 os << std::setw(20) <<
"Eigenvalue"
1069 << std::setw(20) <<
"Residual(B)"
1070 << std::setw(20) <<
"Residual(2)"
1072 os <<
"--------------------------------------------------------------------------------"<<endl;
1073 for (
int i=0; i<this->blockSize_; i++) {
1074 os << std::setw(20) << this->theta_[i];
1075 if (this->Rnorms_current_) os << std::setw(20) << this->Rnorms_[i];
1076 else os << std::setw(20) <<
"not current";
1077 if (this->R2norms_current_) os << std::setw(20) << this->R2norms_[i];
1078 else os << std::setw(20) <<
"not current";
1082 os <<
"================================================================================" << endl;
1089 #endif // ANASAZI_IRTR_HPP
This class defines the interface required by an eigensolver and status test class to compute solution...
Base class for Implicit Riemannian Trust-Region solvers.
SerialBandDenseMatrixPrinter< OrdinalType, ScalarType > printMat(const SerialBandDenseMatrix< OrdinalType, ScalarType > &obj)
Declaration of basic traits for the multivector type.
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
This class is an abstract base class for Implicit Riemannian Trust-Region based eigensolvers. The class provides the interfaces shared by the IRTR solvers (e.g., getState() and initialize()) as well as the shared implementations (e.g., inner products).
Virtual base class which defines basic traits for the operator type.
ScalarTraits< ScalarType >::magnitudeType normFrobenius() const
Pure virtual base class which describes the basic interface to the iterative eigensolver.
Anasazi's templated, static class providing utilities for the solvers.
Output managers remove the need for the eigensolver to know any information about the required output...
IRTR(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< GenOrthoManager< ScalarType, MV, OP > > &ortho, Teuchos::ParameterList ¶ms)
IRTR constructor with eigenproblem, solver utilities, and parameter list of solver options...
Traits class which defines basic operations on multivectors.
Virtual base class which defines basic traits for the operator type.
void iterate()
Impemements Eigensolver. The outer IRTR iteration. See RTRBase::iterate().
int reshape(OrdinalType numRows, OrdinalType numCols)
Types and exceptions used within Anasazi solvers and interfaces.
virtual ~IRTR()
IRTR destructor
Anasazi's templated pure virtual class for managing the sorting of approximate eigenvalues computed b...
Common interface of stopping criteria for Anasazi's solvers.
RTRRitzFailure is thrown when the RTR solver is unable to continue a call to RTRBase::iterate() due t...
OrdinalType numRows() const
void currentStatus(std::ostream &os)
Impemements Eigensolver. This method requests that the solver print out its current status to screen...