packages/Alea/mc_solvers/GmresPolynomial.cc
//---------------------------------------------------------------------------//
// Build GMRES coefficients from QR solution of (K*A)c=b
//---------------------------------------------------------------------------//
Build GMRES coefficients from QR solution of (K*A)c=b
Build GMRES coefficients from QR solution of ( K * A ) c = b
void GmresPolynomial::buildGmresPolyFromQrDecomp()
{
    Teuchos::RCP<const MV> b = computeInitialKrylovVector();
    Teuchos::RCP<MV> K = computeKrylovStandardBasis(b_m+1, b);
    std::vector<int> inds(b_m+1);
    for( int i=0; i<b_m+1; ++i )
        inds[i]=i+1;
    Teuchos::RCP<MV> AK = MVT::CloneViewNonConst(*K,inds);
    Anasazi::BasicOrthoManager<SCALAR,MV,OP> orthoman;
    Teuchos::RCP<SDM> R( new SDM(b_m+1,b_m+1) );
    int rank = orthoman.normalizeMat(*AK,R);
    CHECK( rank == b_m+1 );
    SDM Q_trans_b(b_m+1,1);
    MVT::MvTransMv(1.0,*AK,*b,Q_trans_b);
    Teuchos::LAPACK<LO,SCALAR> lapack;
    int info;
    lapack.TRTRS('U','N','N',b_m+1,1,R->values(),R->stride(),
        Q_trans_b.values(),Q_trans_b.stride(),&info);
    CHECK( info == 0 );
    b_coeffs.resize(b_m+1);
    std::copy( Q_trans_b.values(), Q_trans_b.values()+b_m+1,
               b_coeffs.begin() );
}
void GmresPolynomial :: buildGmresPolyFromQrDecomp ( ) { Teuchos :: RCP < const MV > b = computeInitialKrylovVector ( ) ; Teuchos :: RCP < MV > K = computeKrylovStandardBasis ( b_m + 1 , b ) ; std :: vector < int > inds ( b_m + 1 ) ; for ( int i = 0 ; i < b_m + 1 ; ++ i ) inds [ i ] = i + 1 ; Teuchos :: RCP < MV > AK = MVT :: CloneViewNonConst ( * K , inds ) ; Anasazi :: BasicOrthoManager < SCALAR , MV , OP > orthoman ; Teuchos :: RCP < SDM > R ( new SDM ( b_m + 1 , b_m + 1 ) ) ; int rank = orthoman . normalizeMat ( * AK , R ) ; CHECK ( rank == b_m + 1 ) ; SDM Q_trans_b ( b_m + 1 , 1 ) ; MVT :: MvTransMv ( 1.0 , * AK , * b , Q_trans_b ) ; Teuchos :: LAPACK < LO , SCALAR > lapack ; int info ; lapack . TRTRS ( ' ' , ' ' , ' ' , b_m + 1 , 1 , R -> values ( ) , R -> stride ( ) , Q_trans_b . values ( ) , Q_trans_b . stride ( ) , & info ) ; CHECK ( info == 0 ) ; b_coeffs . resize ( b_m + 1 ) ; std :: copy ( Q_trans_b . values ( ) , Q_trans_b . values ( ) + b_m + 1 , b_coeffs . begin ( ) ) ; }
Build GMRES coefficients from QR solution of (K*A)c=b
Build GMRES coefficients from QR solution of ( K * A ) c = b
// Get standard basis for Krylov subspace // Discard first vector (b) // Perform QR factorization of AK // Compute Q^T * b // R^{-1} (Q^T * b) // Solve using LAPACK triangular solve // Copy coefficients into array in base class