51 #ifndef BELOS_ICGS_ORTHOMANAGER_MP_VECTOR_HPP
52 #define BELOS_ICGS_ORTHOMANAGER_MP_VECTOR_HPP
55 #include "BelosICGSOrthoManager.hpp"
59 template<
class Storage,
class MV,
class OP>
60 class ICGSOrthoManager<Sacado::MP::Vector<Storage>,MV,OP> :
61 public MatOrthoManager<Sacado::MP::Vector<Storage>,MV,OP>
68 typedef MultiVecTraits<ScalarType,MV>
MVT;
69 typedef OperatorTraits<ScalarType,MV,OP>
OPT;
78 const int max_ortho_steps = max_ortho_steps_default_,
82 max_ortho_steps_( max_ortho_steps ),
84 sing_tol_( sing_tol ),
87 #ifdef BELOS_TEUCHOS_TIME_MONITOR
89 ss << label_ +
": ICGS[" << max_ortho_steps_ <<
"]";
91 std::string orthoLabel = ss.str() +
": Orthogonalization";
94 std::string updateLabel = ss.str() +
": Ortho (Update)";
97 std::string normLabel = ss.str() +
": Ortho (Norm)";
100 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
107 const std::string& label =
"Belos",
110 max_ortho_steps_ (max_ortho_steps_default_),
111 blk_tol_ (blk_tol_default_),
112 sing_tol_ (sing_tol_default_),
115 setParameterList (plist);
117 #ifdef BELOS_TEUCHOS_TIME_MONITOR
118 std::stringstream ss;
119 ss << label_ +
": ICGS[" << max_ortho_steps_ <<
"]";
121 std::string orthoLabel = ss.str() +
": Orthogonalization";
124 std::string updateLabel = ss.str() +
": Ortho (Update)";
127 std::string normLabel = ss.str() +
": Ortho (Norm)";
130 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
147 using Teuchos::parameterList;
150 RCP<const ParameterList> defaultParams = getValidParameters();
151 RCP<ParameterList> params;
153 params = parameterList (*defaultParams);
168 int maxNumOrthogPasses;
173 maxNumOrthogPasses = params->get<
int> (
"maxNumOrthogPasses");
174 }
catch (InvalidParameterName&) {
175 maxNumOrthogPasses = defaultParams->get<
int> (
"maxNumOrthogPasses");
176 params->set (
"maxNumOrthogPasses", maxNumOrthogPasses);
188 }
catch (InvalidParameterName&) {
193 params->remove (
"depTol");
194 }
catch (InvalidParameterName&) {
197 params->set (
"blkTol", blkTol);
202 }
catch (InvalidParameterName&) {
204 params->set (
"singTol", singTol);
207 max_ortho_steps_ = maxNumOrthogPasses;
211 this->setMyParamList (params);
217 if (defaultParams_.is_null()) {
218 defaultParams_ = Belos::getICGSDefaultParameters<ScalarType, MV, OP>();
221 return defaultParams_;
235 using Teuchos::parameterList;
238 RCP<const ParameterList> defaultParams = getValidParameters ();
240 RCP<ParameterList> params = parameterList (*defaultParams);
242 params->set (
"maxNumOrthogPasses", max_ortho_steps_fast_);
243 params->set (
"blkTol", blk_tol_fast_);
244 params->set (
"singTol", sing_tol_fast_);
261 params->
set (
"blkTol", blk_tol);
275 params->
set (
"singTol", sing_tol);
277 sing_tol_ = sing_tol;
412 projectAndNormalizeWithMxImpl (MV &X,
460 void setLabel(
const std::string& label);
464 const std::string&
getLabel()
const {
return label_; }
498 #ifdef BELOS_TEUCHOS_TIME_MONITOR
500 #endif // BELOS_TEUCHOS_TIME_MONITOR
508 bool completeBasis,
int howMany = -1 )
const;
540 template<
class StorageType,
class MV,
class OP>
541 const int ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::max_ortho_steps_default_ = 2;
543 template<
class StorageType,
class MV,
class OP>
544 const typename ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
545 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::blk_tol_default_
549 template<
class StorageType,
class MV,
class OP>
550 const typename ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
551 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::sing_tol_default_
554 template<
class StorageType,
class MV,
class OP>
555 const int ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::max_ortho_steps_fast_ = 1;
557 template<
class StorageType,
class MV,
class OP>
558 const typename ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
559 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::blk_tol_fast_
562 template<
class StorageType,
class MV,
class OP>
563 const typename ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
564 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::sing_tol_fast_
569 template<
class StorageType,
class MV,
class OP>
570 void ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::setLabel(
const std::string& label)
572 if (label != label_) {
574 #ifdef BELOS_TEUCHOS_TIME_MONITOR
575 std::stringstream ss;
576 ss << label_ +
": ICGS[" << max_ortho_steps_ <<
"]";
578 std::string orthoLabel = ss.str() +
": Orthogonalization";
581 std::string updateLabel = ss.str() +
": Ortho (Update)";
584 std::string normLabel = ss.str() +
": Ortho (Norm)";
587 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
595 template<
class StorageType,
class MV,
class OP>
597 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::orthonormError(
const MV &X,
Teuchos::RCP<const MV> MX)
const {
598 const ScalarType ONE = SCT::one();
599 int rank = MVT::GetNumberVecs(X);
601 MatOrthoManager<ScalarType,MV,OP>::innerProd(X,X,MX,xTx);
602 for (
int i=0; i<rank; i++) {
605 return xTx.normFrobenius();
610 template<
class StorageType,
class MV,
class OP>
612 ICGSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::orthogError(
const MV &X1,
Teuchos::RCP<const MV> MX1,
const MV &X2)
const {
613 int r1 = MVT::GetNumberVecs(X1);
614 int r2 = MVT::GetNumberVecs(X2);
616 MatOrthoManager<ScalarType,MV,OP>::innerProd(X2,X1,MX1,xTx);
617 return xTx.normFrobenius();
622 template<
class StorageType,
class MV,
class OP>
624 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::
625 projectAndNormalizeWithMxImpl (MV &X,
637 typedef SerialDenseMatrix< int, ScalarType > serial_dense_matrix_type;
638 typedef typename Array< RCP< const MV > >::size_type size_type;
640 #ifdef BELOS_TEUCHOS_TIME_MONITOR
644 ScalarType ONE = SCT::one();
645 const MagnitudeType ZERO = MGT::zero();
648 int xc = MVT::GetNumberVecs( X );
649 ptrdiff_t xr = MVT::GetGlobalLength( X );
656 B =
rcp (
new serial_dense_matrix_type (xc, xc));
666 for (size_type k = 0; k < nq; ++k)
668 const int numRows = MVT::GetNumberVecs (*Q[k]);
669 const int numCols = xc;
672 C[k] =
rcp (
new serial_dense_matrix_type (numRows, numCols));
673 else if (
C[k]->numRows() != numRows ||
C[k]->numCols() != numCols)
675 int err =
C[k]->reshape (numRows, numCols);
677 "IMGS orthogonalization: failed to reshape "
678 "C[" << k <<
"] (the array of block "
679 "coefficients resulting from projecting X "
680 "against Q[1:" << nq <<
"]).");
688 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
689 OPT::Apply(*(this->_Op),X,*MX);
697 int mxc = MVT::GetNumberVecs( *MX );
698 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
701 TEUCHOS_TEST_FOR_EXCEPTION( xc == 0 || xr == 0, std::invalid_argument,
"Belos::ICGSOrthoManager::projectAndNormalize(): X must be non-empty" );
704 for (
int i=0; i<nq; i++) {
705 numbas += MVT::GetNumberVecs( *Q[i] );
710 "Belos::ICGSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of B" );
713 "Belos::ICGSOrthoManager::projectAndNormalize(): MVT returned negative dimensions for X,MX" );
716 "Belos::ICGSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of MX" );
722 bool dep_flg =
false;
728 dep_flg = blkOrtho1( X, MX,
C, Q );
734 std::vector<ScalarType>
diag(xc);
736 #ifdef BELOS_TEUCHOS_TIME_MONITOR
739 MVT::MvDot( X, *MX,
diag );
741 (*B)(0,0) = SCT::squareroot(SCT::magnitude(
diag[0]));
743 ScalarType scale = ONE;
748 MVT::MvScale( X, scale );
751 MVT::MvScale( *MX, scale );
758 tmpX = MVT::CloneCopy(X);
760 tmpMX = MVT::CloneCopy(*MX);
764 dep_flg = blkOrtho( X, MX,
C, Q );
770 rank = blkOrthoSing( *tmpX, tmpMX,
C,
B, Q );
773 MVT::Assign( *tmpX, X );
775 MVT::Assign( *tmpMX, *MX );
780 rank = findBasis( X, MX,
B,
false );
785 rank = blkOrthoSing( *tmpX, tmpMX,
C,
B, Q );
788 MVT::Assign( *tmpX, X );
790 MVT::Assign( *tmpMX, *MX );
798 "Belos::ICGSOrthoManager::projectAndNormalize(): Debug error in rank variable." );
808 template<
class StorageType,
class MV,
class OP>
809 int ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::normalize(
813 #ifdef BELOS_TEUCHOS_TIME_MONITOR
818 return findBasis(X, MX,
B,
true);
825 template<
class StorageType,
class MV,
class OP>
826 void ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::project(
845 #ifdef BELOS_TEUCHOS_TIME_MONITOR
849 int xc = MVT::GetNumberVecs( X );
850 ptrdiff_t xr = MVT::GetGlobalLength( X );
852 std::vector<int> qcs(nq);
854 if (nq == 0 || xc == 0 || xr == 0) {
857 ptrdiff_t qr = MVT::GetGlobalLength ( *Q[0] );
868 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
869 OPT::Apply(*(this->_Op),X,*MX);
876 int mxc = MVT::GetNumberVecs( *MX );
877 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
881 "Belos::ICGSOrthoManager::project(): MVT returned negative dimensions for X,MX" );
884 "Belos::ICGSOrthoManager::project(): Size of X not consistant with MX,Q" );
888 for (
int i=0; i<nq; i++) {
890 "Belos::ICGSOrthoManager::project(): Q lengths not mutually consistant" );
891 qcs[i] = MVT::GetNumberVecs( *Q[i] );
893 "Belos::ICGSOrthoManager::project(): Q has less rows than columns" );
902 "Belos::ICGSOrthoManager::project(): Size of Q not consistant with size of C" );
907 blkOrtho( X, MX,
C, Q );
914 template<
class StorageType,
class MV,
class OP>
916 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::
937 const ScalarType ONE = SCT::one ();
938 const MagnitudeType ZERO = SCT::magnitude (SCT::zero ());
940 const int xc = MVT::GetNumberVecs (X);
941 const ptrdiff_t xr = MVT::GetGlobalLength (X);
956 MX = MVT::Clone(X,xc);
957 OPT::Apply(*(this->_Op),X,*MX);
968 const int mxc = (this->_hasOp) ? MVT::GetNumberVecs( *MX ) : xc;
969 const ptrdiff_t mxr = (this->_hasOp) ? MVT::GetGlobalLength( *MX ) : xr;
973 "Belos::ICGSOrthoManager::findBasis(): X must be non-empty" );
975 "Belos::ICGSOrthoManager::findBasis(): Size of X not consistant with size of B" );
977 "Belos::ICGSOrthoManager::findBasis(): Size of X not consistant with size of MX" );
979 "Belos::ICGSOrthoManager::findBasis(): Size of X not feasible for normalization" );
981 "Belos::ICGSOrthoManager::findBasis(): Invalid howMany parameter" );
986 int xstart = xc - howMany;
988 for (
int j = xstart;
j < xc;
j++) {
997 std::vector<int> index(1);
1003 MXj = MVT::CloneViewNonConst( *MX, index );
1011 std::vector<int> prev_idx( numX );
1016 for (
int i=0; i<numX; i++) {
1019 prevX = MVT::CloneView( X, prev_idx );
1021 prevMX = MVT::CloneView( *MX, prev_idx );
1024 oldMXj = MVT::CloneCopy( *MXj );
1029 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1034 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1037 MVT::MvDot( *Xj, *MXj, oldDot );
1041 "Belos::ICGSOrthoManager::findBasis(): Negative definiteness discovered in inner product" );
1047 for (
int i=0; i<max_ortho_steps_; ++i) {
1051 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1054 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*Xj,MXj,P2);
1060 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1063 MVT::MvTimesMatAddMv( -ONE, *prevX, P2, ONE, *Xj );
1071 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1074 MVT::MvTimesMatAddMv( -ONE, *prevMX, P2, ONE, *MXj );
1088 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1091 MVT::MvDot( *Xj, *oldMXj, newDot );
1094 newDot[0] = oldDot[0];
1098 if (completeBasis) {
1102 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(sing_tol_*oldDot[0]) ) {
1107 std::cout <<
"Belos::ICGSOrthoManager::findBasis() --> Random for column " << numX << std::endl;
1112 MVT::MvRandom( *tempXj );
1114 tempMXj = MVT::Clone( X, 1 );
1115 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1121 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1124 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1127 for (
int num_orth=0; num_orth<max_ortho_steps_; num_orth++){
1129 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1132 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*tempXj,tempMXj,product);
1135 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1138 MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *tempXj );
1141 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1144 MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *tempMXj );
1149 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1152 MVT::MvDot( *tempXj, *tempMXj, newDot );
1155 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1157 MVT::Assign( *tempXj, *Xj );
1159 MVT::Assign( *tempMXj, *MXj );
1171 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*blk_tol_) ) {
1179 ScalarType
diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1180 ScalarType scale = ONE;
1182 MVT::MvScale( *Xj, scale );
1185 MVT::MvScale( *MXj, scale );
1198 for (
int i=0; i<numX; i++) {
1199 (*B)(i,
j) = product(i,0);
1210 template<
class StorageType,
class MV,
class OP>
1212 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrtho1 ( MV &X,
Teuchos::RCP<MV> MX,
1217 int xc = MVT::GetNumberVecs( X );
1218 const ScalarType ONE = SCT::one();
1220 std::vector<int> qcs( nq );
1221 for (
int i=0; i<nq; i++) {
1222 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1229 for (
int i=0; i<nq; i++) {
1232 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1235 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,*
C[i]);
1239 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1242 MVT::MvTimesMatAddMv( -ONE, *Q[i], *
C[i], ONE, X );
1248 OPT::Apply( *(this->_Op), X, *MX);
1252 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1253 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1255 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1258 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *
C[i], ONE, *MX );
1265 for (
int j = 1;
j < max_ortho_steps_; ++
j) {
1267 for (
int i=0; i<nq; i++) {
1272 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1275 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,C2);
1279 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1282 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1288 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1292 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1294 else if (xc <= qcs[i]) {
1296 OPT::Apply( *(this->_Op), X, *MX);
1307 template<
class StorageType,
class MV,
class OP>
1309 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrtho ( MV &X,
Teuchos::RCP<MV> MX,
1314 int xc = MVT::GetNumberVecs( X );
1315 bool dep_flg =
false;
1316 const ScalarType ONE = SCT::one();
1318 std::vector<int> qcs( nq );
1319 for (
int i=0; i<nq; i++) {
1320 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1326 std::vector<ScalarType> oldDot( xc );
1328 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1331 MVT::MvDot( X, *MX, oldDot );
1336 for (
int i=0; i<nq; i++) {
1339 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1342 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,*
C[i]);
1346 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1349 MVT::MvTimesMatAddMv( -ONE, *Q[i], *
C[i], ONE, X );
1354 OPT::Apply( *(this->_Op), X, *MX);
1358 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1359 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1361 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1364 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *
C[i], ONE, *MX );
1371 for (
int j = 1;
j < max_ortho_steps_; ++
j) {
1373 for (
int i=0; i<nq; i++) {
1378 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1381 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,C2);
1385 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1388 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1394 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1398 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1400 else if (xc <= qcs[i]) {
1402 OPT::Apply( *(this->_Op), X, *MX);
1409 std::vector<ScalarType> newDot(xc);
1411 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1414 MVT::MvDot( X, *MX, newDot );
1418 for (
int i=0; i<xc; i++){
1419 if (SCT::magnitude(newDot[i]) < SCT::magnitude(oldDot[i] * blk_tol_)) {
1428 template<
class StorageType,
class MV,
class OP>
1430 ICGSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrthoSing ( MV &X,
Teuchos::RCP<MV> MX,
1437 const ScalarType ONE = SCT::one();
1438 const ScalarType ZERO = SCT::zero();
1441 int xc = MVT::GetNumberVecs( X );
1442 std::vector<int> indX( 1 );
1443 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1445 std::vector<int> qcs( nq );
1446 for (
int i=0; i<nq; i++) {
1447 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1456 for (
int j=0;
j<xc;
j++) {
1458 bool dep_flg =
false;
1462 std::vector<int> index(
j );
1463 for (
int ind=0; ind<
j; ind++) {
1466 lastQ = MVT::CloneView( X, index );
1469 Q.push_back( lastQ );
1471 qcs.push_back( MVT::GetNumberVecs( *lastQ ) );
1476 Xj = MVT::CloneViewNonConst( X, indX );
1478 MXj = MVT::CloneViewNonConst( *MX, indX );
1486 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1489 MVT::MvDot( *Xj, *MXj, oldDot );
1494 for (
int i=0; i<Q.size(); i++) {
1501 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1504 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*Xj,MXj,tempC);
1507 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1511 MVT::MvTimesMatAddMv( -ONE, *Q[i], tempC, ONE, *Xj );
1516 OPT::Apply( *(this->_Op), *Xj, *MXj);
1520 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1521 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1523 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1526 MVT::MvTimesMatAddMv( -ONE, *MQ[i], tempC, ONE, *MXj );
1533 for (
int num_ortho_steps=1; num_ortho_steps < max_ortho_steps_; ++num_ortho_steps) {
1535 for (
int i=0; i<Q.size(); i++) {
1541 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1544 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*Xj,MXj,C2);
1548 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1551 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, *Xj );
1558 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1561 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MXj );
1563 else if (xc <= qcs[i]) {
1565 OPT::Apply( *(this->_Op), *Xj, *MXj);
1573 if (SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*sing_tol_)) {
1579 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1581 MVT::MvScale( *Xj, ONE/diag );
1584 MVT::MvScale( *MXj, ONE/diag );
1594 MVT::MvRandom( *tempXj );
1596 tempMXj = MVT::Clone( X, 1 );
1597 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1603 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1606 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1609 for (
int num_orth=0; num_orth<max_ortho_steps_; num_orth++) {
1611 for (
int i=0; i<Q.size(); i++) {
1616 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1619 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*tempXj,tempMXj,product);
1622 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1625 MVT::MvTimesMatAddMv( -ONE, *Q[i], product, ONE, *tempXj );
1631 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1635 MVT::MvTimesMatAddMv( -ONE, *MQ[i], product, ONE, *tempMXj );
1637 else if (xc <= qcs[i]) {
1639 OPT::Apply( *(this->_Op), *tempXj, *tempMXj);
1648 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1651 MVT::MvDot( *tempXj, *tempMXj, newDot );
1655 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1656 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1662 MVT::MvAddMv( ONE/diag, *tempXj, ZERO, *tempXj, *Xj );
1664 MVT::MvAddMv( ONE/diag, *tempMXj, ZERO, *tempMXj, *MXj );
1686 #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.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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).
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.