15 #ifndef BELOS_DGKS_ORTHOMANAGER_HPP
16 #define BELOS_DGKS_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>
70 max_blk_ortho_( max_blk_ortho ),
73 sing_tol_( sing_tol ),
76 #ifdef BELOS_TEUCHOS_TIME_MONITOR
78 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
80 std::string orthoLabel = ss.str() +
": Orthogonalization";
83 std::string updateLabel = ss.str() +
": Ortho (Update)";
86 std::string normLabel = ss.str() +
": Ortho (Norm)";
89 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
96 const std::string& label =
"Belos",
107 #ifdef BELOS_TEUCHOS_TIME_MONITOR
108 std::stringstream ss;
109 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
111 std::string orthoLabel = ss.str() +
": Orthogonalization";
114 std::string updateLabel = ss.str() +
": Ortho (Update)";
117 std::string normLabel = ss.str() +
": Ortho (Norm)";
120 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
136 using Teuchos::parameterList;
140 RCP<ParameterList> params;
143 params = parameterList (*defaultParams);
154 const int maxNumOrthogPasses = params->get<
int> (
"maxNumOrthogPasses");
155 const MagnitudeType blkTol = params->get<MagnitudeType> (
"blkTol");
156 const MagnitudeType depTol = params->get<MagnitudeType> (
"depTol");
157 const MagnitudeType singTol = params->get<MagnitudeType> (
"singTol");
159 max_blk_ortho_ = maxNumOrthogPasses;
170 if (defaultParams_.
is_null()) {
171 defaultParams_ = Belos::getDGKSDefaultParameters<ScalarType, MV, OP>();
174 return defaultParams_;
191 params->
set (
"blkTol", blk_tol);
201 params->
set (
"depTol", dep_tol);
211 params->
set (
"singTol", sing_tol);
213 sing_tol_ = sing_tol;
417 void setLabel(
const std::string& label);
421 const std::string&
getLabel()
const {
return label_; }
453 MagnitudeType blk_tol_;
455 MagnitudeType dep_tol_;
457 MagnitudeType sing_tol_;
461 #ifdef BELOS_TEUCHOS_TIME_MONITOR
463 #endif // BELOS_TEUCHOS_TIME_MONITOR
471 bool completeBasis,
int howMany = -1 )
const;
503 template<
class ScalarType,
class MV,
class OP>
506 template<
class ScalarType,
class MV,
class OP>
507 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
512 template<
class ScalarType,
class MV,
class OP>
513 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
519 template<
class ScalarType,
class MV,
class OP>
520 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
524 template<
class ScalarType,
class MV,
class OP>
527 template<
class ScalarType,
class MV,
class OP>
528 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
532 template<
class ScalarType,
class MV,
class OP>
533 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
537 template<
class ScalarType,
class MV,
class OP>
538 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
544 template<
class ScalarType,
class MV,
class OP>
547 if (label != label_) {
549 #ifdef BELOS_TEUCHOS_TIME_MONITOR
550 std::stringstream ss;
551 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
553 std::string orthoLabel = ss.str() +
": Orthogonalization";
556 std::string updateLabel = ss.str() +
": Ortho (Update)";
559 std::string normLabel = ss.str() +
": Ortho (Norm)";
562 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
570 template<
class ScalarType,
class MV,
class OP>
573 const ScalarType ONE = SCT::one();
574 int rank = MVT::GetNumberVecs(X);
577 #ifdef BELOS_TEUCHOS_TIME_MONITOR
582 for (
int i=0; i<rank; i++) {
590 template<
class ScalarType,
class MV,
class OP>
593 int r1 = MVT::GetNumberVecs(X1);
594 int r2 = MVT::GetNumberVecs(X2);
597 #ifdef BELOS_TEUCHOS_TIME_MONITOR
607 template<
class ScalarType,
class MV,
class OP>
623 typedef typename Array< RCP< const MV > >::size_type size_type;
625 #ifdef BELOS_TEUCHOS_TIME_MONITOR
629 ScalarType ONE = SCT::one();
630 const MagnitudeType ZERO = SCT::magnitude(SCT::zero());
633 int xc = MVT::GetNumberVecs( X );
634 ptrdiff_t xr = MVT::GetGlobalLength( X );
641 B =
rcp (
new serial_dense_matrix_type (xc, xc));
651 for (size_type k = 0; k < nq; ++k)
653 const int numRows = MVT::GetNumberVecs (*Q[k]);
654 const int numCols = xc;
657 C[k] =
rcp (
new serial_dense_matrix_type (numRows, numCols));
658 else if (C[k]->numRows() != numRows || C[k]->numCols() != numCols)
660 int err = C[k]->reshape (numRows, numCols);
662 "DGKS orthogonalization: failed to reshape "
663 "C[" << k <<
"] (the array of block "
664 "coefficients resulting from projecting X "
665 "against Q[1:" << nq <<
"]).");
671 if (MX == Teuchos::null) {
673 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
674 OPT::Apply(*(this->_Op),X,*MX);
682 int mxc = MVT::GetNumberVecs( *MX );
683 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
686 TEUCHOS_TEST_FOR_EXCEPTION( xc == 0 || xr == 0, std::invalid_argument,
"Belos::DGKSOrthoManager::projectAndNormalize(): X must be non-empty" );
689 for (
int i=0; i<nq; i++) {
690 numbas += MVT::GetNumberVecs( *Q[i] );
695 "Belos::DGKSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of B" );
698 "Belos::DGKSOrthoManager::projectAndNormalize(): MVT returned negative dimensions for X,MX" );
700 TEUCHOS_TEST_FOR_EXCEPTION( xc!=mxc || xr!=mxr, std::invalid_argument,
701 "Belos::DGKSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of MX" );
707 bool dep_flg =
false;
713 dep_flg = blkOrtho1( X, MX, C, Q );
716 if ( B == Teuchos::null ) {
719 std::vector<ScalarType> diag(1);
721 #ifdef BELOS_TEUCHOS_TIME_MONITOR
724 MVT::MvDot( X, *MX, diag );
726 (*B)(0,0) = SCT::squareroot(SCT::magnitude(diag[0]));
728 if (SCT::magnitude((*B)(0,0)) > ZERO) {
730 MVT::MvScale( X, ONE/(*B)(0,0) );
733 MVT::MvScale( *MX, ONE/(*B)(0,0) );
741 tmpX = MVT::CloneCopy(X);
743 tmpMX = MVT::CloneCopy(*MX);
747 dep_flg = blkOrtho( X, MX, C, Q );
752 rank = blkOrthoSing( *tmpX, tmpMX, C, B, Q );
755 MVT::Assign( *tmpX, X );
757 MVT::Assign( *tmpMX, *MX );
762 rank = findBasis( X, MX, B,
false );
766 rank = blkOrthoSing( *tmpX, tmpMX, C, B, Q );
769 MVT::Assign( *tmpX, X );
771 MVT::Assign( *tmpMX, *MX );
778 TEUCHOS_TEST_FOR_EXCEPTION( rank > xc || rank < 0, std::logic_error,
779 "Belos::DGKSOrthoManager::projectAndNormalize(): Debug error in rank variable." );
789 template<
class ScalarType,
class MV,
class OP>
794 #ifdef BELOS_TEUCHOS_TIME_MONITOR
799 return findBasis(X, MX, B,
true);
806 template<
class ScalarType,
class MV,
class OP>
826 #ifdef BELOS_TEUCHOS_TIME_MONITOR
830 int xc = MVT::GetNumberVecs( X );
831 ptrdiff_t xr = MVT::GetGlobalLength( X );
833 std::vector<int> qcs(nq);
835 if (nq == 0 || xc == 0 || xr == 0) {
838 ptrdiff_t qr = MVT::GetGlobalLength ( *Q[0] );
847 if (MX == Teuchos::null) {
849 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
850 OPT::Apply(*(this->_Op),X,*MX);
857 int mxc = MVT::GetNumberVecs( *MX );
858 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
862 "Belos::DGKSOrthoManager::project(): MVT returned negative dimensions for X,MX" );
865 "Belos::DGKSOrthoManager::project(): Size of X not consistant with MX,Q" );
868 for (
int i=0; i<nq; i++) {
870 "Belos::DGKSOrthoManager::project(): Q lengths not mutually consistant" );
871 qcs[i] = MVT::GetNumberVecs( *Q[i] );
873 "Belos::DGKSOrthoManager::project(): Q has less rows than columns" );
876 if ( C[i] == Teuchos::null ) {
881 "Belos::DGKSOrthoManager::project(): Size of Q not consistant with size of C" );
886 blkOrtho( X, MX, C, Q );
893 template<
class ScalarType,
class MV,
class OP>
897 bool completeBasis,
int howMany )
const {
914 const ScalarType ONE = SCT::one();
915 const MagnitudeType ZERO = SCT::magnitude(SCT::zero());
917 int xc = MVT::GetNumberVecs( X );
918 ptrdiff_t xr = MVT::GetGlobalLength( X );
931 if (MX == Teuchos::null) {
933 MX = MVT::Clone(X,xc);
934 OPT::Apply(*(this->_Op),X,*MX);
941 if ( B == Teuchos::null ) {
945 int mxc = (this->_hasOp) ? MVT::GetNumberVecs( *MX ) : xc;
946 ptrdiff_t mxr = (this->_hasOp) ? MVT::GetGlobalLength( *MX ) : xr;
950 "Belos::DGKSOrthoManager::findBasis(): X must be non-empty" );
952 "Belos::DGKSOrthoManager::findBasis(): Size of X not consistant with size of B" );
954 "Belos::DGKSOrthoManager::findBasis(): Size of X not consistant with size of MX" );
956 "Belos::DGKSOrthoManager::findBasis(): Size of X not feasible for normalization" );
958 "Belos::DGKSOrthoManager::findBasis(): Invalid howMany parameter" );
963 int xstart = xc - howMany;
965 for (
int j = xstart; j < xc; j++) {
974 std::vector<int> index(1);
978 if ((this->_hasOp)) {
980 MXj = MVT::CloneViewNonConst( *MX, index );
988 std::vector<int> prev_idx( numX );
993 for (
int i=0; i<numX; i++) {
996 prevX = MVT::CloneView( X, prev_idx );
998 prevMX = MVT::CloneView( *MX, prev_idx );
1001 oldMXj = MVT::CloneCopy( *MXj );
1006 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1011 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1014 MVT::MvDot( *Xj, *MXj, oldDot );
1018 "Belos::DGKSOrthoManager::findBasis(): Negative definiteness discovered in inner product" );
1025 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1033 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1036 MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *Xj );
1044 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1047 MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *MXj );
1052 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1055 MVT::MvDot( *Xj, *MXj, newDot );
1059 if ( MGT::squareroot(SCT::magnitude(newDot[0])) < dep_tol_*MGT::squareroot(SCT::magnitude(oldDot[0])) ) {
1064 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1072 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1075 MVT::MvTimesMatAddMv( -ONE, *prevX, P2, ONE, *Xj );
1077 if ((this->_hasOp)) {
1078 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1081 MVT::MvTimesMatAddMv( -ONE, *prevMX, P2, ONE, *MXj );
1089 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1092 MVT::MvDot( *Xj, *oldMXj, newDot );
1095 newDot[0] = oldDot[0];
1099 if (completeBasis) {
1103 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(sing_tol_*oldDot[0]) ) {
1108 std::cout <<
"Belos::DGKSOrthoManager::findBasis() --> Random for column " << numX << std::endl;
1113 MVT::MvRandom( *tempXj );
1115 tempMXj = MVT::Clone( X, 1 );
1116 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1122 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1125 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1128 for (
int num_orth=0; num_orth<max_blk_ortho_; num_orth++){
1130 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1136 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1139 MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *tempXj );
1142 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1145 MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *tempMXj );
1150 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1153 MVT::MvDot( *tempXj, *tempMXj, newDot );
1156 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1158 MVT::Assign( *tempXj, *Xj );
1160 MVT::Assign( *tempMXj, *MXj );
1172 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*blk_tol_) ) {
1180 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1182 if (SCT::magnitude(diag) > ZERO) {
1183 MVT::MvScale( *Xj, ONE/diag );
1186 MVT::MvScale( *MXj, ONE/diag );
1200 for (
int i=0; i<numX; i++) {
1201 (*B)(i,j) = product(i,0);
1212 template<
class ScalarType,
class MV,
class OP>
1214 DGKSOrthoManager<ScalarType, MV, OP>::blkOrtho1 ( MV &X,
Teuchos::RCP<MV> MX,
1219 int xc = MVT::GetNumberVecs( X );
1220 const ScalarType ONE = SCT::one();
1222 std::vector<int> qcs( nq );
1223 for (
int i=0; i<nq; i++) {
1224 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1228 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1230 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1233 MVT::MvDot( X, *MX, oldDot );
1238 for (
int i=0; i<nq; i++) {
1241 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1248 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1251 MVT::MvTimesMatAddMv( -ONE, *Q[i], *C[i], ONE, X );
1257 OPT::Apply( *(this->_Op), X, *MX);
1261 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1262 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1264 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1267 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *C[i], ONE, *MX );
1274 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1277 MVT::MvDot( X, *MX, newDot );
1291 if ( MGT::squareroot(SCT::magnitude(newDot[0])) < dep_tol_*MGT::squareroot(SCT::magnitude(oldDot[0])) ) {
1294 for (
int i=0; i<nq; i++) {
1299 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1307 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1310 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1316 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1320 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1322 else if (xc <= qcs[i]) {
1324 OPT::Apply( *(this->_Op), X, *MX);
1335 template<
class ScalarType,
class MV,
class OP>
1337 DGKSOrthoManager<ScalarType, MV, OP>::blkOrtho ( MV &X,
Teuchos::RCP<MV> MX,
1342 int xc = MVT::GetNumberVecs( X );
1343 bool dep_flg =
false;
1344 const ScalarType ONE = SCT::one();
1346 std::vector<int> qcs( nq );
1347 for (
int i=0; i<nq; i++) {
1348 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1354 std::vector<ScalarType> oldDot( xc );
1356 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1359 MVT::MvDot( X, *MX, oldDot );
1364 for (
int i=0; i<nq; i++) {
1367 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1374 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1377 MVT::MvTimesMatAddMv( -ONE, *Q[i], *C[i], ONE, X );
1383 OPT::Apply( *(this->_Op), X, *MX);
1387 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1388 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1390 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1393 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *C[i], ONE, *MX );
1400 for (
int j = 1; j < max_blk_ortho_; ++j) {
1402 for (
int i=0; i<nq; i++) {
1407 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1415 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1418 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1424 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1428 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1430 else if (xc <= qcs[i]) {
1432 OPT::Apply( *(this->_Op), X, *MX);
1439 std::vector<ScalarType> newDot(xc);
1441 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1444 MVT::MvDot( X, *MX, newDot );
1448 for (
int i=0; i<xc; i++){
1449 if (SCT::magnitude(newDot[i]) < SCT::magnitude(oldDot[i] * blk_tol_)) {
1459 template<
class ScalarType,
class MV,
class OP>
1461 DGKSOrthoManager<ScalarType, MV, OP>::blkOrthoSing ( MV &X,
Teuchos::RCP<MV> MX,
1468 const ScalarType ONE = SCT::one();
1469 const ScalarType ZERO = SCT::zero();
1472 int xc = MVT::GetNumberVecs( X );
1473 std::vector<int> indX( 1 );
1474 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1476 std::vector<int> qcs( nq );
1477 for (
int i=0; i<nq; i++) {
1478 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1487 for (
int j=0; j<xc; j++) {
1489 bool dep_flg =
false;
1493 std::vector<int> index( j );
1494 for (
int ind=0; ind<j; ind++) {
1497 lastQ = MVT::CloneView( X, index );
1500 Q.push_back( lastQ );
1502 qcs.push_back( MVT::GetNumberVecs( *lastQ ) );
1507 Xj = MVT::CloneViewNonConst( X, indX );
1509 MXj = MVT::CloneViewNonConst( *MX, indX );
1517 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1520 MVT::MvDot( *Xj, *MXj, oldDot );
1525 for (
int i=0; i<Q.size(); i++) {
1532 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1539 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1542 MVT::MvTimesMatAddMv( -ONE, *Q[i], tempC, ONE, *Xj );
1548 OPT::Apply( *(this->_Op), *Xj, *MXj);
1552 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1553 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1555 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1558 MVT::MvTimesMatAddMv( -ONE, *MQ[i], tempC, ONE, *MXj );
1566 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1569 MVT::MvDot( *Xj, *MXj, newDot );
1575 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*dep_tol_) ) {
1577 for (
int i=0; i<Q.size(); i++) {
1583 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1590 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1593 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, *Xj );
1599 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1603 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MXj );
1605 else if (xc <= qcs[i]) {
1607 OPT::Apply( *(this->_Op), *Xj, *MXj);
1614 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1617 MVT::MvDot( *Xj, *MXj, newDot );
1622 if (SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*sing_tol_)) {
1628 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1630 MVT::MvScale( *Xj, ONE/diag );
1633 MVT::MvScale( *MXj, ONE/diag );
1643 MVT::MvRandom( *tempXj );
1645 tempMXj = MVT::Clone( X, 1 );
1646 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1652 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1655 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1658 for (
int num_orth=0; num_orth<max_blk_ortho_; num_orth++) {
1660 for (
int i=0; i<Q.size(); i++) {
1665 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1671 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1674 MVT::MvTimesMatAddMv( -ONE, *Q[i], product, ONE, *tempXj );
1680 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1684 MVT::MvTimesMatAddMv( -ONE, *MQ[i], product, ONE, *tempMXj );
1686 else if (xc <= qcs[i]) {
1688 OPT::Apply( *(this->_Op), *tempXj, *tempMXj);
1697 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1700 MVT::MvDot( *tempXj, *tempMXj, newDot );
1704 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1705 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1711 MVT::MvAddMv( ONE/diag, *tempXj, ZERO, *tempXj, *Xj );
1713 MVT::MvAddMv( ONE/diag, *tempMXj, ZERO, *tempMXj, *MXj );
1733 template<
class ScalarType,
class MV,
class OP>
1737 using Teuchos::parameterList;
1740 RCP<ParameterList> params = parameterList (
"DGKS");
1745 "Maximum number of orthogonalization passes (includes the "
1746 "first). Default is 2, since \"twice is enough\" for Krylov "
1749 "Block reorthogonalization threshold.");
1751 "(Non-block) reorthogonalization threshold.");
1753 "Singular block detection threshold.");
1758 template<
class ScalarType,
class MV,
class OP>
1764 RCP<ParameterList> params = getDGKSDefaultParameters<ScalarType, MV, OP>();
1766 params->set (
"maxNumOrthogPasses",
1768 params->set (
"blkTol",
1770 params->set (
"depTol",
1772 params->set (
"singTol",
1780 #endif // BELOS_DGKS_ORTHOMANAGER_HPP
void setSingTol(const MagnitudeType sing_tol)
Set parameter for singular block detection.
static const MagnitudeType blk_tol_default_
Block reorthogonalization threshold (default).
static const MagnitudeType dep_tol_fast_
(Non-block) reorthogonalization threshold (fast).
static const MagnitudeType sing_tol_default_
Singular block detection threshold (default).
static const MagnitudeType blk_tol_fast_
Block reorthogonalization threshold (fast).
bool is_null(const boost::shared_ptr< T > &p)
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 > getDGKSDefaultParameters()
"Default" parameters for robustness and accuracy.
DGKSOrthoManager(const std::string &label="Belos", Teuchos::RCP< const OP > Op=Teuchos::null, const int max_blk_ortho=max_blk_ortho_default_, const MagnitudeType blk_tol=blk_tol_default_, const MagnitudeType dep_tol=dep_tol_default_, const MagnitudeType sing_tol=sing_tol_default_)
Constructor specifying re-orthogonalization tolerance.
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
~DGKSOrthoManager()
Destructor.
void setBlkTol(const MagnitudeType blk_tol)
Set parameter for block re-orthogonalization threshhold.
static const MagnitudeType dep_tol_default_
(Non-block) reorthogonalization threshold (default).
void setDepTol(const MagnitudeType dep_tol)
Set parameter for re-orthogonalization threshhold.
bool is_null(const std::shared_ptr< T > &p)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Declaration of basic traits for the multivector type.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
DGKSOrthoManager(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.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Class which defines basic traits for the operator type.
static const int max_blk_ortho_default_
Max number of (re)orthogonalization steps, including the first (default).
void setLabel(const std::string &label)
This method sets the label used by the timers in the orthogonalization manager.
ScalarTraits< ScalarType >::magnitudeType normFrobenius() const
Traits class which defines basic operations on multivectors.
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...
MagnitudeType getDepTol() const
Return parameter for re-orthogonalization threshhold.
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_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setMyParamList(const RCP< ParameterList > ¶mList)
static const int max_blk_ortho_fast_
Max number of (re)orthogonalization steps, including the first (fast).
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
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.
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...
RCP< ParameterList > getNonconstParameterList()
static const MagnitudeType sing_tol_fast_
Singular block detection threshold (fast).
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 ...
Teuchos::ScalarTraits< ScalarType >::magnitudeType orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
An implementation of the Belos::MatOrthoManager that performs orthogonalization using (potentially) m...
Class which defines basic traits for the operator type.
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.
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
MagnitudeType getBlkTol() const
Return parameter for block re-orthogonalization threshhold.
Teuchos::RCP< Teuchos::ParameterList > getDGKSFastParameters()
"Fast" but possibly unsafe or less accurate parameters.
Belos header file which uses auto-configuration information to include necessary C++ headers...
MagnitudeType getSingTol() const
Return parameter for singular block detection.
Templated virtual class for providing orthogonalization/orthonormalization methods with matrix-based ...