50 #ifndef BELOS_TFQMR_ITER_HPP
51 #define BELOS_TFQMR_ITER_HPP
94 template <
class ScalarType,
class MV>
106 Rtilde(Teuchos::null),
D(Teuchos::null),
V(Teuchos::null)
142 template <
class ScalarType,
class MV,
class OP>
229 state.solnUpdate = solnUpdate_;
270 "Belos::TFQMRIter::setBlockSize(): Cannot use a block size that is not one.");
300 std::vector<ScalarType> alpha_, rho_, rho_old_;
301 std::vector<MagnitudeType> tau_, cs_, theta_;
314 bool stateStorageInitialized_;
338 template <
class ScalarType,
class MV,
class OP>
354 stateStorageInitialized_(false),
361 template <
class ScalarType,
class MV,
class OP>
369 return Teuchos::null;
375 template <
class ScalarType,
class MV,
class OP>
378 if (!stateStorageInitialized_) {
383 if (lhsMV == Teuchos::null && rhsMV == Teuchos::null) {
384 stateStorageInitialized_ =
false;
391 if (R_ == Teuchos::null) {
395 "Belos::TFQMRIter::setStateSize(): linear problem does not specify multivectors to clone from.");
396 R_ = MVT::Clone( *tmp, 1 );
397 D_ = MVT::Clone( *tmp, 1 );
398 V_ = MVT::Clone( *tmp, 1 );
399 solnUpdate_ = MVT::Clone( *tmp, 1 );
403 stateStorageInitialized_ =
true;
410 template <
class ScalarType,
class MV,
class OP>
414 if (!stateStorageInitialized_)
418 "Belos::TFQMRIter::initialize(): Cannot initialize state storage!");
422 std::string errstr(
"Belos::TFQMRIter::initialize(): Specified multivectors must have a consistent length and width.");
427 if (newstate.
R != Teuchos::null) {
430 std::invalid_argument, errstr );
432 std::invalid_argument, errstr );
435 if (newstate.
R != R_) {
437 MVT::Assign( *newstate.
R, *R_ );
443 W_ = MVT::CloneCopy( *R_ );
444 U_ = MVT::CloneCopy( *R_ );
445 Rtilde_ = MVT::CloneCopy( *R_ );
447 MVT::MvInit( *solnUpdate_ );
451 lp_->apply( *U_, *V_ );
452 AU_ = MVT::CloneCopy( *V_ );
457 MVT::MvNorm( *R_, tau_ );
458 MVT::MvDot( *R_, *Rtilde_, rho_old_ );
463 "Belos::TFQMRIter::initialize(): TFQMRIterState does not have initial residual.");
473 template <
class ScalarType,
class MV,
class OP>
479 if (initialized_ ==
false) {
488 ScalarType eta = STzero, beta = STzero;
497 "Belos::TFQMRIter::iterate(): current linear system has more than one vector!" );
503 while (stest_->checkStatus(
this) !=
Passed) {
505 for (
int iIter=0; iIter<2; iIter++)
513 MVT::MvDot( *V_, *Rtilde_, alpha_ );
514 alpha_[0] = rho_old_[0]/alpha_[0];
522 MVT::MvAddMv( STone, *W_, -alpha_[0], *AU_, *W_ );
529 MVT::MvAddMv( STone, *U_, (theta_[0]*theta_[0]/alpha_[0])*eta, *D_, *D_ );
540 MVT::MvAddMv( STone, *U_, -alpha_[0], *V_, *U_ );
543 lp_->apply( *U_, *AU_ );
550 MVT::MvNorm( *W_, theta_ );
551 theta_[0] /= tau_[0];
554 tau_[0] *= theta_[0]*cs_[0];
555 eta = cs_[0]*cs_[0]*alpha_[0];
562 MVT::MvAddMv( STone, *solnUpdate_, eta, *D_, *solnUpdate_ );
567 if ( tau_[0] == MTzero ) {
577 MVT::MvDot( *W_, *Rtilde_, rho_ );
578 beta = rho_[0]/rho_old_[0];
579 rho_old_[0] = rho_[0];
586 MVT::MvAddMv( STone, *W_, beta, *U_, *U_ );
589 MVT::MvAddMv( STone, *AU_, beta, *V_, *V_ );
592 lp_->apply( *U_, *AU_ );
595 MVT::MvAddMv( STone, *AU_, beta, *V_, *V_ );
608 #endif // BELOS_TFQMR_ITER_HPP