15 #ifndef BELOS_ICGS_ORTHOMANAGER_HPP 
   16 #define BELOS_ICGS_ORTHOMANAGER_HPP 
   33 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
   35 #endif // BELOS_TEUCHOS_TIME_MONITOR 
   40   template<
class ScalarType, 
class MV, 
class OP>
 
   44   template<
class ScalarType, 
class MV, 
class OP>
 
   47   template<
class ScalarType, 
class MV, 
class OP>
 
   69       max_ortho_steps_( max_ortho_steps ),
 
   71       sing_tol_( sing_tol ),
 
   74 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
   76       ss << label_ + 
": ICGS[" << max_ortho_steps_ << 
"]";
 
   78       std::string orthoLabel = ss.str() + 
": Orthogonalization";
 
   81       std::string updateLabel = ss.str() + 
": Ortho (Update)";
 
   84       std::string normLabel = ss.str() + 
": Ortho (Norm)";
 
   87       std::string ipLabel = ss.str() + 
": Ortho (Inner Product)";
 
   94                       const std::string& label = 
"Belos",
 
  104 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
  105       std::stringstream ss;
 
  106       ss << label_ + 
": ICGS[" << max_ortho_steps_ << 
"]";
 
  108       std::string orthoLabel = ss.str() + 
": Orthogonalization";
 
  111       std::string updateLabel = ss.str() + 
": Ortho (Update)";
 
  114       std::string normLabel = ss.str() + 
": Ortho (Norm)";
 
  117       std::string ipLabel = ss.str() + 
": Ortho (Inner Product)";
 
  134       using Teuchos::parameterList;
 
  138       RCP<ParameterList> params;
 
  140         params = parameterList (*defaultParams);
 
  155       int maxNumOrthogPasses;
 
  156       MagnitudeType blkTol;
 
  157       MagnitudeType singTol;
 
  160         maxNumOrthogPasses = params->
get<
int> (
"maxNumOrthogPasses");
 
  161       } 
catch (InvalidParameterName&) {
 
  162         maxNumOrthogPasses = defaultParams->get<
int> (
"maxNumOrthogPasses");
 
  163         params->set (
"maxNumOrthogPasses", maxNumOrthogPasses);
 
  174         blkTol = params->get<MagnitudeType> (
"blkTol");
 
  175       } 
catch (InvalidParameterName&) {
 
  177           blkTol = params->get<MagnitudeType> (
"depTol");
 
  180           params->remove (
"depTol");
 
  181         } 
catch (InvalidParameterName&) {
 
  182           blkTol = defaultParams->get<MagnitudeType> (
"blkTol");
 
  184         params->set (
"blkTol", blkTol);
 
  188         singTol = params->get<MagnitudeType> (
"singTol");
 
  189       } 
catch (InvalidParameterName&) {
 
  190         singTol = defaultParams->get<MagnitudeType> (
"singTol");
 
  191         params->set (
"singTol", singTol);
 
  194       max_ortho_steps_ = maxNumOrthogPasses;
 
  204       if (defaultParams_.
is_null()) {
 
  205         defaultParams_ = Belos::getICGSDefaultParameters<ScalarType, MV, OP>();
 
  208       return defaultParams_;
 
  222       using Teuchos::parameterList;
 
  227       RCP<ParameterList> params = parameterList (*defaultParams);
 
  248         params->
set (
"blkTol", blk_tol);
 
  262         params->
set (
"singTol", sing_tol);
 
  264       sing_tol_ = sing_tol;
 
  447     void setLabel(
const std::string& label);
 
  451     const std::string& 
getLabel()
 const { 
return label_; }
 
  477     int max_ortho_steps_;
 
  479     MagnitudeType blk_tol_;
 
  481     MagnitudeType sing_tol_;
 
  485 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
  487 #endif // BELOS_TEUCHOS_TIME_MONITOR 
  495                   bool completeBasis, 
int howMany = -1 ) 
const;
 
  527   template<
class ScalarType, 
class MV, 
class OP>
 
  530   template<
class ScalarType, 
class MV, 
class OP>
 
  531   const typename ICGSOrthoManager<ScalarType,MV,OP>::MagnitudeType
 
  536   template<
class ScalarType, 
class MV, 
class OP>
 
  537   const typename ICGSOrthoManager<ScalarType,MV,OP>::MagnitudeType
 
  541   template<
class ScalarType, 
class MV, 
class OP>
 
  544   template<
class ScalarType, 
class MV, 
class OP>
 
  545   const typename ICGSOrthoManager<ScalarType,MV,OP>::MagnitudeType
 
  549   template<
class ScalarType, 
class MV, 
class OP>
 
  550   const typename ICGSOrthoManager<ScalarType,MV,OP>::MagnitudeType
 
  556   template<
class ScalarType, 
class MV, 
class OP>
 
  559     if (label != label_) {
 
  561 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
  562       std::stringstream ss;
 
  563       ss << label_ + 
": ICGS[" << max_ortho_steps_ << 
"]";
 
  565       std::string orthoLabel = ss.str() + 
": Orthogonalization";
 
  568       std::string updateLabel = ss.str() + 
": Ortho (Update)";
 
  571       std::string normLabel = ss.str() + 
": Ortho (Norm)";
 
  574       std::string ipLabel = ss.str() + 
": Ortho (Inner Product)";
 
  582   template<
class ScalarType, 
class MV, 
class OP>
 
  585     const ScalarType ONE = SCT::one();
 
  586     int rank = MVT::GetNumberVecs(X);
 
  589     for (
int i=0; i<rank; i++) {
 
  597   template<
class ScalarType, 
class MV, 
class OP>
 
  600     int r1 = MVT::GetNumberVecs(X1);
 
  601     int r2  = MVT::GetNumberVecs(X2);
 
  609   template<
class ScalarType, 
class MV, 
class OP>
 
  625     typedef typename Array< RCP< const MV > >::size_type size_type;
 
  627 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
  631     ScalarType    ONE  = SCT::one();
 
  632     const MagnitudeType ZERO = MGT::zero();
 
  635     int xc = MVT::GetNumberVecs( X );
 
  636     ptrdiff_t xr = MVT::GetGlobalLength( X );
 
  643       B = 
rcp (
new serial_dense_matrix_type (xc, xc));
 
  653     for (size_type k = 0; k < nq; ++k)
 
  655         const int numRows = MVT::GetNumberVecs (*Q[k]);
 
  656         const int numCols = xc; 
 
  659           C[k] = 
rcp (
new serial_dense_matrix_type (numRows, numCols));
 
  660         else if (C[k]->numRows() != numRows || C[k]->numCols() != numCols)
 
  662           int err = C[k]->reshape (numRows, numCols);
 
  664               "IMGS orthogonalization: failed to reshape " 
  665               "C[" << k << 
"] (the array of block " 
  666               "coefficients resulting from projecting X " 
  667               "against Q[1:" << nq << 
"]).");
 
  673       if (MX == Teuchos::null) {
 
  675         MX = MVT::Clone(X,MVT::GetNumberVecs(X));
 
  676         OPT::Apply(*(this->_Op),X,*MX);
 
  684     int mxc = MVT::GetNumberVecs( *MX );
 
  685     ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
 
  688     TEUCHOS_TEST_FOR_EXCEPTION( xc == 0 || xr == 0, std::invalid_argument, 
"Belos::ICGSOrthoManager::projectAndNormalize(): X must be non-empty" );
 
  691     for (
int i=0; i<nq; i++) {
 
  692       numbas += MVT::GetNumberVecs( *Q[i] );
 
  697                         "Belos::ICGSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of B" );
 
  700                         "Belos::ICGSOrthoManager::projectAndNormalize(): MVT returned negative dimensions for X,MX" );
 
  702     TEUCHOS_TEST_FOR_EXCEPTION( xc!=mxc || xr!=mxr, std::invalid_argument,
 
  703                         "Belos::ICGSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of MX" );
 
  709     bool dep_flg = 
false;
 
  715       dep_flg = blkOrtho1( X, MX, C, Q );
 
  718       if ( B == Teuchos::null ) {
 
  721       std::vector<ScalarType> diag(xc);
 
  723 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
  726         MVT::MvDot( X, *MX, diag );
 
  728       (*B)(0,0) = SCT::squareroot(SCT::magnitude(diag[0]));
 
  730       if (SCT::magnitude((*B)(0,0)) > ZERO) {
 
  732         MVT::MvScale( X, ONE/(*B)(0,0) );
 
  735           MVT::MvScale( *MX, ONE/(*B)(0,0) );
 
  743       tmpX = MVT::CloneCopy(X);
 
  745         tmpMX = MVT::CloneCopy(*MX);
 
  749       dep_flg = blkOrtho( X, MX, C, Q );
 
  755         rank = blkOrthoSing( *tmpX, tmpMX, C, B, Q );
 
  758         MVT::Assign( *tmpX, X );
 
  760           MVT::Assign( *tmpMX, *MX );
 
  765         rank = findBasis( X, MX, B, 
false );
 
  770           rank = blkOrthoSing( *tmpX, tmpMX, C, B, Q );
 
  773           MVT::Assign( *tmpX, X );
 
  775             MVT::Assign( *tmpMX, *MX );
 
  782     TEUCHOS_TEST_FOR_EXCEPTION( rank > xc || rank < 0, std::logic_error,
 
  783                         "Belos::ICGSOrthoManager::projectAndNormalize(): Debug error in rank variable." );
 
  793   template<
class ScalarType, 
class MV, 
class OP>
 
  798 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
  803     return findBasis(X, MX, B, 
true);
 
  810   template<
class ScalarType, 
class MV, 
class OP>
 
  830 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
  834     int xc = MVT::GetNumberVecs( X );
 
  835     ptrdiff_t xr = MVT::GetGlobalLength( X );
 
  837     std::vector<int> qcs(nq);
 
  839     if (nq == 0 || xc == 0 || xr == 0) {
 
  842     ptrdiff_t qr = MVT::GetGlobalLength ( *Q[0] );
 
  851       if (MX == Teuchos::null) {
 
  853         MX = MVT::Clone(X,MVT::GetNumberVecs(X));
 
  854         OPT::Apply(*(this->_Op),X,*MX);
 
  861     int mxc = MVT::GetNumberVecs( *MX );
 
  862     ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
 
  866                         "Belos::ICGSOrthoManager::project(): MVT returned negative dimensions for X,MX" );
 
  869                         "Belos::ICGSOrthoManager::project(): Size of X not consistant with MX,Q" );
 
  872     for (
int i=0; i<nq; i++) {
 
  874                           "Belos::ICGSOrthoManager::project(): Q lengths not mutually consistant" );
 
  875       qcs[i] = MVT::GetNumberVecs( *Q[i] );
 
  877                           "Belos::ICGSOrthoManager::project(): Q has less rows than columns" );
 
  880       if ( C[i] == Teuchos::null ) {
 
  885                            "Belos::ICGSOrthoManager::project(): Size of Q not consistant with size of C" );
 
  890     blkOrtho( X, MX, C, Q );
 
  897   template<
class ScalarType, 
class MV, 
class OP>
 
  920     const ScalarType ONE = SCT::one ();
 
  921     const MagnitudeType ZERO = SCT::magnitude (SCT::zero ());
 
  923     const int xc = MVT::GetNumberVecs (X);
 
  924     const ptrdiff_t xr = MVT::GetGlobalLength (X);
 
  937       if (MX == Teuchos::null) {
 
  939         MX = MVT::Clone(X,xc);
 
  940         OPT::Apply(*(this->_Op),X,*MX);
 
  947     if ( B == Teuchos::null ) {
 
  951     const int mxc = (this->_hasOp) ? MVT::GetNumberVecs( *MX ) : xc;
 
  952     const ptrdiff_t mxr = (this->_hasOp) ? MVT::GetGlobalLength( *MX ) : xr;
 
  956                         "Belos::ICGSOrthoManager::findBasis(): X must be non-empty" );
 
  958                         "Belos::ICGSOrthoManager::findBasis(): Size of X not consistant with size of B" );
 
  960                         "Belos::ICGSOrthoManager::findBasis(): Size of X not consistant with size of MX" );
 
  962                         "Belos::ICGSOrthoManager::findBasis(): Size of X not feasible for normalization" );
 
  964                         "Belos::ICGSOrthoManager::findBasis(): Invalid howMany parameter" );
 
  969     int xstart = xc - howMany;
 
  971     for (
int j = xstart; j < xc; j++) {
 
  980       std::vector<int> index(1);
 
  986         MXj = MVT::CloneViewNonConst( *MX, index );
 
  994       std::vector<int> prev_idx( numX );
 
  999         for (
int i=0; i<numX; i++) {
 
 1002         prevX = MVT::CloneView( X, prev_idx );
 
 1004           prevMX = MVT::CloneView( *MX, prev_idx );
 
 1007         oldMXj = MVT::CloneCopy( *MXj );
 
 1012       std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
 
 1017 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1020       MVT::MvDot( *Xj, *MXj, oldDot );
 
 1024           "Belos::ICGSOrthoManager::findBasis(): Negative definiteness discovered in inner product" );
 
 1030         for (
int i=0; i<max_ortho_steps_; ++i) {
 
 1034 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1043 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1046             MVT::MvTimesMatAddMv( -ONE, *prevX, P2, ONE, *Xj );
 
 1054 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1057             MVT::MvTimesMatAddMv( -ONE, *prevMX, P2, ONE, *MXj );
 
 1071 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1074         MVT::MvDot( *Xj, *oldMXj, newDot );
 
 1077         newDot[0] = oldDot[0];
 
 1081       if (completeBasis) {
 
 1085         if ( SCT::magnitude(newDot[0]) < SCT::magnitude(sing_tol_*oldDot[0]) ) {
 
 1090           std::cout << 
"Belos::ICGSOrthoManager::findBasis() --> Random for column " << numX << std::endl;
 
 1095           MVT::MvRandom( *tempXj );
 
 1097             tempMXj = MVT::Clone( X, 1 );
 
 1098             OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
 
 1104 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1107           MVT::MvDot( *tempXj, *tempMXj, oldDot );
 
 1110           for (
int num_orth=0; num_orth<max_ortho_steps_; num_orth++){
 
 1112 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1118 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1121               MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *tempXj );
 
 1124 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1127               MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *tempMXj );
 
 1132 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1135           MVT::MvDot( *tempXj, *tempMXj, newDot );
 
 1138           if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
 
 1140             MVT::Assign( *tempXj, *Xj );
 
 1142               MVT::Assign( *tempMXj, *MXj );
 
 1154         if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*blk_tol_) ) {
 
 1162       ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
 
 1163       if (SCT::magnitude(diag) > ZERO) {
 
 1164         MVT::MvScale( *Xj, ONE/diag );
 
 1167           MVT::MvScale( *MXj, ONE/diag );
 
 1181         for (
int i=0; i<numX; i++) {
 
 1182           (*B)(i,j) = product(i,0);
 
 1193   template<
class ScalarType, 
class MV, 
class OP>
 
 1195   ICGSOrthoManager<ScalarType, MV, OP>::blkOrtho1 ( MV &X, 
Teuchos::RCP<MV> MX,
 
 1200     int xc = MVT::GetNumberVecs( X );
 
 1201     const ScalarType ONE  = SCT::one();
 
 1203     std::vector<int> qcs( nq );
 
 1204     for (
int i=0; i<nq; i++) {
 
 1205       qcs[i] = MVT::GetNumberVecs( *Q[i] );
 
 1212     for (
int i=0; i<nq; i++) {
 
 1215 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1222 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1225         MVT::MvTimesMatAddMv( -ONE, *Q[i], *C[i], ONE, X );
 
 1231           OPT::Apply( *(this->_Op), X, *MX);
 
 1235           MQ[i] = MVT::Clone( *Q[i], qcs[i] );
 
 1236           OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
 
 1238 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1241           MVT::MvTimesMatAddMv( -ONE, *MQ[i], *C[i], ONE, *MX );
 
 1248     for (
int j = 1; j < max_ortho_steps_; ++j) {
 
 1250       for (
int i=0; i<nq; i++) {
 
 1255 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1262 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1265           MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
 
 1271 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1275             MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
 
 1277           else if (xc <= qcs[i]) {
 
 1279             OPT::Apply( *(this->_Op), X, *MX);
 
 1290   template<
class ScalarType, 
class MV, 
class OP>
 
 1292   ICGSOrthoManager<ScalarType, MV, OP>::blkOrtho ( MV &X, 
Teuchos::RCP<MV> MX,
 
 1297     int xc = MVT::GetNumberVecs( X );
 
 1298     bool dep_flg = 
false;
 
 1299     const ScalarType ONE  = SCT::one();
 
 1301     std::vector<int> qcs( nq );
 
 1302     for (
int i=0; i<nq; i++) {
 
 1303       qcs[i] = MVT::GetNumberVecs( *Q[i] );
 
 1309     std::vector<ScalarType> oldDot( xc );
 
 1311 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1314     MVT::MvDot( X, *MX, oldDot );
 
 1319     for (
int i=0; i<nq; i++) {
 
 1322 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1329 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1332         MVT::MvTimesMatAddMv( -ONE, *Q[i], *C[i], ONE, X );
 
 1337           OPT::Apply( *(this->_Op), X, *MX);
 
 1341           MQ[i] = MVT::Clone( *Q[i], qcs[i] );
 
 1342           OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
 
 1344 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1347           MVT::MvTimesMatAddMv( -ONE, *MQ[i], *C[i], ONE, *MX );
 
 1354     for (
int j = 1; j < max_ortho_steps_; ++j) {
 
 1356       for (
int i=0; i<nq; i++) {
 
 1361 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1368 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1371           MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
 
 1377 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1381             MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
 
 1383           else if (xc <= qcs[i]) {
 
 1385             OPT::Apply( *(this->_Op), X, *MX);
 
 1392     std::vector<ScalarType> newDot(xc);
 
 1394 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1397     MVT::MvDot( X, *MX, newDot );
 
 1401     for (
int i=0; i<xc; i++){
 
 1402       if (SCT::magnitude(newDot[i]) < SCT::magnitude(oldDot[i] * blk_tol_)) {
 
 1411   template<
class ScalarType, 
class MV, 
class OP>
 
 1413   ICGSOrthoManager<ScalarType, MV, OP>::blkOrthoSing ( MV &X, 
Teuchos::RCP<MV> MX,
 
 1420     const ScalarType ONE  = SCT::one();
 
 1421     const ScalarType ZERO  = SCT::zero();
 
 1424     int xc = MVT::GetNumberVecs( X );
 
 1425     std::vector<int> indX( 1 );
 
 1426     std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
 
 1428     std::vector<int> qcs( nq );
 
 1429     for (
int i=0; i<nq; i++) {
 
 1430       qcs[i] = MVT::GetNumberVecs( *Q[i] );
 
 1439     for (
int j=0; j<xc; j++) {
 
 1441       bool dep_flg = 
false;
 
 1445         std::vector<int> index( j );
 
 1446         for (
int ind=0; ind<j; ind++) {
 
 1449         lastQ = MVT::CloneView( X, index );
 
 1452         Q.push_back( lastQ );
 
 1454         qcs.push_back( MVT::GetNumberVecs( *lastQ ) );
 
 1459       Xj = MVT::CloneViewNonConst( X, indX );
 
 1461         MXj = MVT::CloneViewNonConst( *MX, indX );
 
 1469 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1472       MVT::MvDot( *Xj, *MXj, oldDot );
 
 1477       for (
int i=0; i<Q.size(); i++) {
 
 1484 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1490 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1494         MVT::MvTimesMatAddMv( -ONE, *Q[i], tempC, ONE, *Xj );
 
 1499             OPT::Apply( *(this->_Op), *Xj, *MXj);
 
 1503             MQ[i] = MVT::Clone( *Q[i], qcs[i] );
 
 1504             OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
 
 1506 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1509             MVT::MvTimesMatAddMv( -ONE, *MQ[i], tempC, ONE, *MXj );
 
 1516       for (
int num_ortho_steps=1; num_ortho_steps < max_ortho_steps_; ++num_ortho_steps) {
 
 1518         for (
int i=0; i<Q.size(); i++) {
 
 1524 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1531 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1534           MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, *Xj );
 
 1541 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1544               MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MXj );
 
 1546             else if (xc <= qcs[i]) {
 
 1548               OPT::Apply( *(this->_Op), *Xj, *MXj);
 
 1557 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1560       MVT::MvDot( *Xj, *MXj, newDot );
 
 1564       if (SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*sing_tol_)) {
 
 1570         ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
 
 1572         MVT::MvScale( *Xj, ONE/diag );
 
 1575           MVT::MvScale( *MXj, ONE/diag );
 
 1585         MVT::MvRandom( *tempXj );
 
 1587           tempMXj = MVT::Clone( X, 1 );
 
 1588           OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
 
 1594 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1597         MVT::MvDot( *tempXj, *tempMXj, oldDot );
 
 1600         for (
int num_orth=0; num_orth<max_ortho_steps_; num_orth++) {
 
 1602           for (
int i=0; i<Q.size(); i++) {
 
 1607 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1613 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1616             MVT::MvTimesMatAddMv( -ONE, *Q[i], product, ONE, *tempXj );
 
 1622 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1626                 MVT::MvTimesMatAddMv( -ONE, *MQ[i], product, ONE, *tempMXj );
 
 1628               else if (xc <= qcs[i]) {
 
 1630                 OPT::Apply( *(this->_Op), *tempXj, *tempMXj);
 
 1639 #ifdef BELOS_TEUCHOS_TIME_MONITOR 
 1642         MVT::MvDot( *tempXj, *tempMXj, newDot );
 
 1646         if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
 
 1647           ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
 
 1653           MVT::MvAddMv( ONE/diag, *tempXj, ZERO, *tempXj, *Xj );
 
 1655             MVT::MvAddMv( ONE/diag, *tempMXj, ZERO, *tempMXj, *MXj );
 
 1675   template<
class ScalarType, 
class MV, 
class OP>
 
 1679     using Teuchos::parameterList;
 
 1682     RCP<ParameterList> params = parameterList (
"ICGS");
 
 1687                  "Maximum number of orthogonalization passes (includes the " 
 1688                  "first).  Default is 2, since \"twice is enough\" for Krylov " 
 1691                  "Block reorthogonalization threshold.");
 
 1693                  "Singular block detection threshold.");
 
 1698   template<
class ScalarType, 
class MV, 
class OP>
 
 1704     RCP<ParameterList> params = getICGSDefaultParameters<ScalarType, MV, OP>();
 
 1706     params->set (
"maxNumOrthogPasses",
 
 1708     params->set (
"blkTol",
 
 1710     params->set (
"singTol",
 
 1718 #endif // BELOS_ICGS_ORTHOMANAGER_HPP 
void setBlkTol(const MagnitudeType blk_tol)
Set parameter for block re-orthogonalization threshhold. 
 
const std::string & getLabel() const 
This method returns the label being used by the timers in the orthogonalization manager. 
 
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
 
bool is_null(const boost::shared_ptr< T > &p)
 
static const MagnitudeType sing_tol_default_
Singular block detection threshold (default). 
 
ICGSOrthoManager(const std::string &label="Belos", Teuchos::RCP< const OP > Op=Teuchos::null, const int max_ortho_steps=max_ortho_steps_default_, const MagnitudeType blk_tol=blk_tol_default_, const MagnitudeType sing_tol=sing_tol_default_)
Constructor specifying re-orthogonalization tolerance. 
 
static const int max_ortho_steps_default_
Max number of (re)orthogonalization steps, including the first (default). 
 
T & get(const std::string &name, T def_value)
 
Teuchos::RCP< Teuchos::ParameterList > getICGSDefaultParameters()
"Default" parameters for robustness and accuracy. 
 
bool is_null(const std::shared_ptr< T > &p)
 
ICGSOrthoManager(const Teuchos::RCP< Teuchos::ParameterList > &plist, const std::string &label="Belos", Teuchos::RCP< const OP > Op=Teuchos::null)
Constructor that takes a list of parameters. 
 
MagnitudeType getBlkTol() const 
Return parameter for block re-orthogonalization threshhold. 
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
Declaration of basic traits for the multivector type. 
 
void setLabel(const std::string &label)
This method sets the label used by the timers in the orthogonalization manager. 
 
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
 
Teuchos::ScalarTraits< ScalarType >::magnitudeType orthogError(const MV &X1, const MV &X2) const 
This method computes the error in orthogonality of two multivectors, measured as the Frobenius norm o...
 
static const MagnitudeType blk_tol_default_
Block reorthogonalization threshold (default). 
 
Class which defines basic traits for the operator type. 
 
ScalarTraits< ScalarType >::magnitudeType normFrobenius() const 
 
Traits class which defines basic operations on multivectors. 
 
static const MagnitudeType sing_tol_fast_
Singular block detection threshold (fast). 
 
void innerProd(const MV &X, const MV &Y, Teuchos::SerialDenseMatrix< int, ScalarType > &Z) const 
Provides the inner product defining the orthogonality concepts, using the provided operator...
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
 
~ICGSOrthoManager()
Destructor. 
 
Teuchos::ScalarTraits< ScalarType >::magnitudeType orthonormError(const MV &X) const 
This method computes the error in orthonormality of a multivector, measured as the Frobenius norm of ...
 
void setMyParamList(const RCP< ParameterList > ¶mList)
 
RCP< ParameterList > getNonconstParameterList()
 
int normalize(MV &X, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B) const 
This method calls normalize(X,Teuchos::null,B); see documentation for that function. 
 
void setSingTol(const MagnitudeType sing_tol)
Set parameter for singular block detection. 
 
MagnitudeType getSingTol() const 
Return parameter for singular block detection. 
 
An implementation of the Belos::MatOrthoManager that performs orthogonalization using multiple steps ...
 
void project(MV &X, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const 
This method calls project(X,Teuchos::null,C,Q); see documentation for that function. 
 
static const MagnitudeType blk_tol_fast_
Block reorthogonalization threshold (fast). 
 
TypeTo as(const TypeFrom &t)
 
virtual int projectAndNormalizeWithMxImpl(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const 
Given a set of bases Q[i] and a multivector X, this method computes an orthonormal basis for ...
 
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters() const 
"Fast" but possibly unsafe or less accurate parameters. 
 
Class which defines basic traits for the operator type. 
 
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
 
static const int max_ortho_steps_fast_
Max number of (re)orthogonalization steps, including the first (fast). 
 
Belos header file which uses auto-configuration information to include necessary C++ headers...
 
void project(MV &X, Teuchos::RCP< MV > MX, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const 
Given a list of (mutually and internally) orthonormal bases Q, this method takes a multivector X and ...
 
int normalize(MV &X, Teuchos::RCP< MV > MX, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B) const 
This method takes a multivector X and attempts to compute an orthonormal basis for ...
 
Teuchos::RCP< Teuchos::ParameterList > getICGSFastParameters()
"Fast" but possibly unsafe or less accurate parameters. 
 
Templated virtual class for providing orthogonalization/orthonormalization methods with matrix-based ...
 
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const