18 #ifndef BELOS_ICGS_ORTHOMANAGER_MP_VECTOR_HPP
19 #define BELOS_ICGS_ORTHOMANAGER_MP_VECTOR_HPP
22 #include "BelosICGSOrthoManager.hpp"
26 template<
class Storage,
class MV,
class OP>
27 class ICGSOrthoManager<Sacado::MP::Vector<Storage>,MV,OP> :
28 public MatOrthoManager<Sacado::MP::Vector<Storage>,MV,OP>
35 typedef MultiVecTraits<ScalarType,MV>
MVT;
36 typedef OperatorTraits<ScalarType,MV,OP>
OPT;
45 const int max_ortho_steps = max_ortho_steps_default_,
49 max_ortho_steps_( max_ortho_steps ),
51 sing_tol_( sing_tol ),
54 #ifdef BELOS_TEUCHOS_TIME_MONITOR
56 ss << label_ +
": ICGS[" << max_ortho_steps_ <<
"]";
58 std::string orthoLabel = ss.str() +
": Orthogonalization";
61 std::string updateLabel = ss.str() +
": Ortho (Update)";
64 std::string normLabel = ss.str() +
": Ortho (Norm)";
67 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
74 const std::string& label =
"Belos",
77 max_ortho_steps_ (max_ortho_steps_default_),
78 blk_tol_ (blk_tol_default_),
79 sing_tol_ (sing_tol_default_),
82 setParameterList (plist);
84 #ifdef BELOS_TEUCHOS_TIME_MONITOR
86 ss << label_ +
": ICGS[" << max_ortho_steps_ <<
"]";
88 std::string orthoLabel = ss.str() +
": Orthogonalization";
91 std::string updateLabel = ss.str() +
": Ortho (Update)";
94 std::string normLabel = ss.str() +
": Ortho (Norm)";
97 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
114 using Teuchos::parameterList;
117 RCP<const ParameterList> defaultParams = getValidParameters();
118 RCP<ParameterList> params;
120 params = parameterList (*defaultParams);
135 int maxNumOrthogPasses;
140 maxNumOrthogPasses = params->
get<
int> (
"maxNumOrthogPasses");
141 }
catch (InvalidParameterName&) {
142 maxNumOrthogPasses = defaultParams->get<
int> (
"maxNumOrthogPasses");
143 params->set (
"maxNumOrthogPasses", maxNumOrthogPasses);
155 }
catch (InvalidParameterName&) {
160 params->remove (
"depTol");
161 }
catch (InvalidParameterName&) {
164 params->set (
"blkTol", blkTol);
169 }
catch (InvalidParameterName&) {
171 params->set (
"singTol", singTol);
174 max_ortho_steps_ = maxNumOrthogPasses;
178 this->setMyParamList (params);
184 if (defaultParams_.is_null()) {
185 defaultParams_ = Belos::getICGSDefaultParameters<ScalarType, MV, OP>();
188 return defaultParams_;
202 using Teuchos::parameterList;
205 RCP<const ParameterList> defaultParams = getValidParameters ();
207 RCP<ParameterList> params = parameterList (*defaultParams);
209 params->set (
"maxNumOrthogPasses", max_ortho_steps_fast_);
210 params->set (
"blkTol", blk_tol_fast_);
211 params->set (
"singTol", sing_tol_fast_);
228 params->
set (
"blkTol", blk_tol);
242 params->
set (
"singTol", sing_tol);
244 sing_tol_ = sing_tol;
379 projectAndNormalizeWithMxImpl (MV &X,
427 void setLabel(
const std::string& label);
431 const std::string&
getLabel()
const {
return label_; }
465 #ifdef BELOS_TEUCHOS_TIME_MONITOR
467 #endif // BELOS_TEUCHOS_TIME_MONITOR
475 bool completeBasis,
int howMany = -1 )
const;
507 template<
class StorageType,
class MV,
class OP>
508 const int ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::max_ortho_steps_default_ = 2;
510 template<
class StorageType,
class MV,
class OP>
511 const typename ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
512 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::blk_tol_default_
516 template<
class StorageType,
class MV,
class OP>
517 const typename ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
518 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::sing_tol_default_
521 template<
class StorageType,
class MV,
class OP>
522 const int ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::max_ortho_steps_fast_ = 1;
524 template<
class StorageType,
class MV,
class OP>
525 const typename ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
526 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::blk_tol_fast_
529 template<
class StorageType,
class MV,
class OP>
530 const typename ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
531 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::sing_tol_fast_
536 template<
class StorageType,
class MV,
class OP>
537 void ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::setLabel(
const std::string& label)
539 if (label != label_) {
541 #ifdef BELOS_TEUCHOS_TIME_MONITOR
542 std::stringstream ss;
543 ss << label_ +
": ICGS[" << max_ortho_steps_ <<
"]";
545 std::string orthoLabel = ss.str() +
": Orthogonalization";
548 std::string updateLabel = ss.str() +
": Ortho (Update)";
551 std::string normLabel = ss.str() +
": Ortho (Norm)";
554 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
562 template<
class StorageType,
class MV,
class OP>
564 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::orthonormError(
const MV &X,
Teuchos::RCP<const MV> MX)
const {
565 const ScalarType ONE = SCT::one();
566 int rank = MVT::GetNumberVecs(X);
568 MatOrthoManager<ScalarType,MV,OP>::innerProd(X,X,MX,xTx);
569 for (
int i=0; i<rank; i++) {
572 return xTx.normFrobenius();
577 template<
class StorageType,
class MV,
class OP>
579 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::orthogError(
const MV &X1,
Teuchos::RCP<const MV> MX1,
const MV &X2)
const {
580 int r1 = MVT::GetNumberVecs(X1);
581 int r2 = MVT::GetNumberVecs(X2);
583 MatOrthoManager<ScalarType,MV,OP>::innerProd(X2,X1,MX1,xTx);
584 return xTx.normFrobenius();
589 template<
class StorageType,
class MV,
class OP>
591 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::
592 projectAndNormalizeWithMxImpl (MV &X,
604 typedef SerialDenseMatrix< int, ScalarType > serial_dense_matrix_type;
605 typedef typename Array< RCP< const MV > >::size_type size_type;
607 #ifdef BELOS_TEUCHOS_TIME_MONITOR
611 ScalarType ONE = SCT::one();
612 const MagnitudeType ZERO = MGT::zero();
615 int xc = MVT::GetNumberVecs( X );
616 ptrdiff_t xr = MVT::GetGlobalLength( X );
623 B =
rcp (
new serial_dense_matrix_type (xc, xc));
633 for (size_type k = 0; k < nq; ++k)
635 const int numRows = MVT::GetNumberVecs (*Q[k]);
636 const int numCols = xc;
639 C[k] =
rcp (
new serial_dense_matrix_type (numRows, numCols));
640 else if (
C[k]->numRows() != numRows ||
C[k]->numCols() != numCols)
642 int err =
C[k]->reshape (numRows, numCols);
644 "IMGS orthogonalization: failed to reshape "
645 "C[" << k <<
"] (the array of block "
646 "coefficients resulting from projecting X "
647 "against Q[1:" << nq <<
"]).");
655 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
656 OPT::Apply(*(this->_Op),X,*MX);
664 int mxc = MVT::GetNumberVecs( *MX );
665 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
668 TEUCHOS_TEST_FOR_EXCEPTION( xc == 0 || xr == 0, std::invalid_argument,
"Belos::ICGSOrthoManager::projectAndNormalize(): X must be non-empty" );
671 for (
int i=0; i<nq; i++) {
672 numbas += MVT::GetNumberVecs( *Q[i] );
677 "Belos::ICGSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of B" );
680 "Belos::ICGSOrthoManager::projectAndNormalize(): MVT returned negative dimensions for X,MX" );
683 "Belos::ICGSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of MX" );
689 bool dep_flg =
false;
695 dep_flg = blkOrtho1( X, MX,
C, Q );
701 std::vector<ScalarType>
diag(xc);
703 #ifdef BELOS_TEUCHOS_TIME_MONITOR
706 MVT::MvDot( X, *MX,
diag );
708 (*B)(0,0) = SCT::squareroot(SCT::magnitude(
diag[0]));
710 ScalarType scale = ONE;
715 MVT::MvScale( X, scale );
718 MVT::MvScale( *MX, scale );
725 tmpX = MVT::CloneCopy(X);
727 tmpMX = MVT::CloneCopy(*MX);
731 dep_flg = blkOrtho( X, MX,
C, Q );
737 rank = blkOrthoSing( *tmpX, tmpMX,
C,
B, Q );
740 MVT::Assign( *tmpX, X );
742 MVT::Assign( *tmpMX, *MX );
747 rank = findBasis( X, MX,
B,
false );
752 rank = blkOrthoSing( *tmpX, tmpMX,
C,
B, Q );
755 MVT::Assign( *tmpX, X );
757 MVT::Assign( *tmpMX, *MX );
765 "Belos::ICGSOrthoManager::projectAndNormalize(): Debug error in rank variable." );
775 template<
class StorageType,
class MV,
class OP>
776 int ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::normalize(
780 #ifdef BELOS_TEUCHOS_TIME_MONITOR
785 return findBasis(X, MX,
B,
true);
792 template<
class StorageType,
class MV,
class OP>
793 void ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::project(
812 #ifdef BELOS_TEUCHOS_TIME_MONITOR
816 int xc = MVT::GetNumberVecs( X );
817 ptrdiff_t xr = MVT::GetGlobalLength( X );
819 std::vector<int> qcs(nq);
821 if (nq == 0 || xc == 0 || xr == 0) {
824 ptrdiff_t qr = MVT::GetGlobalLength ( *Q[0] );
835 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
836 OPT::Apply(*(this->_Op),X,*MX);
843 int mxc = MVT::GetNumberVecs( *MX );
844 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
848 "Belos::ICGSOrthoManager::project(): MVT returned negative dimensions for X,MX" );
851 "Belos::ICGSOrthoManager::project(): Size of X not consistant with MX,Q" );
855 for (
int i=0; i<nq; i++) {
857 "Belos::ICGSOrthoManager::project(): Q lengths not mutually consistant" );
858 qcs[i] = MVT::GetNumberVecs( *Q[i] );
860 "Belos::ICGSOrthoManager::project(): Q has less rows than columns" );
869 "Belos::ICGSOrthoManager::project(): Size of Q not consistant with size of C" );
874 blkOrtho( X, MX,
C, Q );
881 template<
class StorageType,
class MV,
class OP>
883 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::
904 const ScalarType ONE = SCT::one ();
905 const MagnitudeType ZERO = SCT::magnitude (SCT::zero ());
907 const int xc = MVT::GetNumberVecs (X);
908 const ptrdiff_t xr = MVT::GetGlobalLength (X);
923 MX = MVT::Clone(X,xc);
924 OPT::Apply(*(this->_Op),X,*MX);
935 const int mxc = (this->_hasOp) ? MVT::GetNumberVecs( *MX ) : xc;
936 const ptrdiff_t mxr = (this->_hasOp) ? MVT::GetGlobalLength( *MX ) : xr;
940 "Belos::ICGSOrthoManager::findBasis(): X must be non-empty" );
942 "Belos::ICGSOrthoManager::findBasis(): Size of X not consistant with size of B" );
944 "Belos::ICGSOrthoManager::findBasis(): Size of X not consistant with size of MX" );
946 "Belos::ICGSOrthoManager::findBasis(): Size of X not feasible for normalization" );
948 "Belos::ICGSOrthoManager::findBasis(): Invalid howMany parameter" );
953 int xstart = xc - howMany;
955 for (
int j = xstart;
j < xc;
j++) {
964 std::vector<int> index(1);
970 MXj = MVT::CloneViewNonConst( *MX, index );
978 std::vector<int> prev_idx( numX );
983 for (
int i=0; i<numX; i++) {
986 prevX = MVT::CloneView( X, prev_idx );
988 prevMX = MVT::CloneView( *MX, prev_idx );
991 oldMXj = MVT::CloneCopy( *MXj );
996 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1001 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1004 MVT::MvDot( *Xj, *MXj, oldDot );
1008 "Belos::ICGSOrthoManager::findBasis(): Negative definiteness discovered in inner product" );
1014 for (
int i=0; i<max_ortho_steps_; ++i) {
1018 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1021 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*Xj,MXj,P2);
1027 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1030 MVT::MvTimesMatAddMv( -ONE, *prevX, P2, ONE, *Xj );
1038 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1041 MVT::MvTimesMatAddMv( -ONE, *prevMX, P2, ONE, *MXj );
1055 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1058 MVT::MvDot( *Xj, *oldMXj, newDot );
1061 newDot[0] = oldDot[0];
1065 if (completeBasis) {
1069 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(sing_tol_*oldDot[0]) ) {
1074 std::cout <<
"Belos::ICGSOrthoManager::findBasis() --> Random for column " << numX << std::endl;
1079 MVT::MvRandom( *tempXj );
1081 tempMXj = MVT::Clone( X, 1 );
1082 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1088 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1091 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1094 for (
int num_orth=0; num_orth<max_ortho_steps_; num_orth++){
1096 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1099 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*tempXj,tempMXj,product);
1102 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1105 MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *tempXj );
1108 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1111 MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *tempMXj );
1116 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1119 MVT::MvDot( *tempXj, *tempMXj, newDot );
1122 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1124 MVT::Assign( *tempXj, *Xj );
1126 MVT::Assign( *tempMXj, *MXj );
1138 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*blk_tol_) ) {
1146 ScalarType
diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1147 ScalarType scale = ONE;
1149 MVT::MvScale( *Xj, scale );
1152 MVT::MvScale( *MXj, scale );
1165 for (
int i=0; i<numX; i++) {
1166 (*B)(i,
j) = product(i,0);
1177 template<
class StorageType,
class MV,
class OP>
1179 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrtho1 ( MV &X,
Teuchos::RCP<MV> MX,
1184 int xc = MVT::GetNumberVecs( X );
1185 const ScalarType ONE = SCT::one();
1187 std::vector<int> qcs( nq );
1188 for (
int i=0; i<nq; i++) {
1189 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1196 for (
int i=0; i<nq; i++) {
1199 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1202 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,*
C[i]);
1206 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1209 MVT::MvTimesMatAddMv( -ONE, *Q[i], *
C[i], ONE, X );
1215 OPT::Apply( *(this->_Op), X, *MX);
1219 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1220 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1222 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1225 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *
C[i], ONE, *MX );
1232 for (
int j = 1;
j < max_ortho_steps_; ++
j) {
1234 for (
int i=0; i<nq; i++) {
1239 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1242 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,C2);
1246 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1249 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1255 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1259 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1261 else if (xc <= qcs[i]) {
1263 OPT::Apply( *(this->_Op), X, *MX);
1274 template<
class StorageType,
class MV,
class OP>
1276 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrtho ( MV &X,
Teuchos::RCP<MV> MX,
1281 int xc = MVT::GetNumberVecs( X );
1282 bool dep_flg =
false;
1283 const ScalarType ONE = SCT::one();
1285 std::vector<int> qcs( nq );
1286 for (
int i=0; i<nq; i++) {
1287 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1293 std::vector<ScalarType> oldDot( xc );
1295 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1298 MVT::MvDot( X, *MX, oldDot );
1303 for (
int i=0; i<nq; i++) {
1306 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1309 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,*
C[i]);
1313 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1316 MVT::MvTimesMatAddMv( -ONE, *Q[i], *
C[i], ONE, X );
1321 OPT::Apply( *(this->_Op), X, *MX);
1325 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1326 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1328 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1331 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *
C[i], ONE, *MX );
1338 for (
int j = 1;
j < max_ortho_steps_; ++
j) {
1340 for (
int i=0; i<nq; i++) {
1345 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1348 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,C2);
1352 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1355 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1361 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1365 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1367 else if (xc <= qcs[i]) {
1369 OPT::Apply( *(this->_Op), X, *MX);
1376 std::vector<ScalarType> newDot(xc);
1378 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1381 MVT::MvDot( X, *MX, newDot );
1385 for (
int i=0; i<xc; i++){
1386 if (SCT::magnitude(newDot[i]) < SCT::magnitude(oldDot[i] * blk_tol_)) {
1395 template<
class StorageType,
class MV,
class OP>
1397 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrthoSing ( MV &X,
Teuchos::RCP<MV> MX,
1404 const ScalarType ONE = SCT::one();
1405 const ScalarType ZERO = SCT::zero();
1408 int xc = MVT::GetNumberVecs( X );
1409 std::vector<int> indX( 1 );
1410 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1412 std::vector<int> qcs( nq );
1413 for (
int i=0; i<nq; i++) {
1414 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1423 for (
int j=0;
j<xc;
j++) {
1425 bool dep_flg =
false;
1429 std::vector<int> index(
j );
1430 for (
int ind=0; ind<
j; ind++) {
1433 lastQ = MVT::CloneView( X, index );
1436 Q.push_back( lastQ );
1438 qcs.push_back( MVT::GetNumberVecs( *lastQ ) );
1443 Xj = MVT::CloneViewNonConst( X, indX );
1445 MXj = MVT::CloneViewNonConst( *MX, indX );
1453 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1456 MVT::MvDot( *Xj, *MXj, oldDot );
1461 for (
int i=0; i<Q.size(); i++) {
1468 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1471 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*Xj,MXj,tempC);
1474 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1478 MVT::MvTimesMatAddMv( -ONE, *Q[i], tempC, ONE, *Xj );
1483 OPT::Apply( *(this->_Op), *Xj, *MXj);
1487 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1488 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1490 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1493 MVT::MvTimesMatAddMv( -ONE, *MQ[i], tempC, ONE, *MXj );
1500 for (
int num_ortho_steps=1; num_ortho_steps < max_ortho_steps_; ++num_ortho_steps) {
1502 for (
int i=0; i<Q.size(); i++) {
1508 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1511 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*Xj,MXj,C2);
1515 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1518 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, *Xj );
1525 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1528 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MXj );
1530 else if (xc <= qcs[i]) {
1532 OPT::Apply( *(this->_Op), *Xj, *MXj);
1540 if (SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*sing_tol_)) {
1546 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1548 MVT::MvScale( *Xj, ONE/diag );
1551 MVT::MvScale( *MXj, ONE/diag );
1561 MVT::MvRandom( *tempXj );
1563 tempMXj = MVT::Clone( X, 1 );
1564 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1570 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1573 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1576 for (
int num_orth=0; num_orth<max_ortho_steps_; num_orth++) {
1578 for (
int i=0; i<Q.size(); i++) {
1583 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1586 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*tempXj,tempMXj,product);
1589 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1592 MVT::MvTimesMatAddMv( -ONE, *Q[i], product, ONE, *tempXj );
1598 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1602 MVT::MvTimesMatAddMv( -ONE, *MQ[i], product, ONE, *tempMXj );
1604 else if (xc <= qcs[i]) {
1606 OPT::Apply( *(this->_Op), *tempXj, *tempMXj);
1615 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1618 MVT::MvDot( *tempXj, *tempMXj, newDot );
1622 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1623 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1629 MVT::MvAddMv( ONE/diag, *tempXj, ZERO, *tempXj, *Xj );
1631 MVT::MvAddMv( ONE/diag, *tempMXj, ZERO, *tempMXj, *MXj );
1653 #endif // BELOS_ICGS_ORTHOMANAGER_HPP
void setBlkTol(const MagnitudeType blk_tol)
Set parameter for block re-orthogonalization threshhold.
bool is_null(const boost::shared_ptr< T > &p)
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
T & get(ParameterList &l, const std::string &name)
bool is_null(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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.
KOKKOS_INLINE_FUNCTION bool OR(Mask< T > m)
static const MagnitudeType blk_tol_default_
Block reorthogonalization threshold (default).
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
MultiVecTraits< ScalarType, MV > MVT
Teuchos::ScalarTraits< ScalarType > SCT
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
static const int max_ortho_steps_default_
Max number of (re)orthogonalization steps, including the first (default).
KOKKOS_INLINE_FUNCTION MaskedAssign< scalar > mask_assign(bool b, scalar *s)
static const MagnitudeType sing_tol_fast_
Singular block detection threshold (fast).
static const MagnitudeType blk_tol_fast_
Block reorthogonalization threshold (fast).
~ICGSOrthoManager()
Destructor.
std::string label_
Label for timers.
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...
MagnitudeType getSingTol() const
Return parameter for singular block detection.
OperatorTraits< ScalarType, MV, OP > OPT
Teuchos::ScalarTraits< MagnitudeType > MGT
static const int max_ortho_steps_fast_
Max number of (re)orthogonalization steps, including the first (fast).
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool is_null(const RCP< T > &p)
Teuchos::ScalarTraits< ScalarType >::magnitudeType MagnitudeType
MagnitudeType sing_tol_
Singular block detection threshold.
void setSingTol(const MagnitudeType sing_tol)
Set parameter for singular block detection.
Teuchos::RCP< Teuchos::ParameterList > defaultParams_
Default parameter list.
MagnitudeType blk_tol_
Block reorthogonalization threshold.
static const MagnitudeType sing_tol_default_
Singular block detection threshold (default).
TypeTo as(const TypeFrom &t)
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 ...
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.
MagnitudeType getBlkTol() const
Return parameter for block re-orthogonalization threshhold.
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.
Sacado::MP::Vector< Storage > ScalarType
int max_ortho_steps_
Max number of (re)orthogonalization steps, including the first.
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.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters() const
"Fast" but possibly unsafe or less accurate parameters.