51 #ifndef BELOS_DGKS_ORTHOMANAGER_MP_VECTOR_HPP
52 #define BELOS_DGKS_ORTHOMANAGER_MP_VECTOR_HPP
55 #include "BelosDGKSOrthoManager.hpp"
59 template<
class Storage,
class MV,
class OP>
60 class DGKSOrthoManager<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_blk_ortho = max_blk_ortho_default_,
83 max_blk_ortho_( max_blk_ortho ),
86 sing_tol_( sing_tol ),
89 #ifdef BELOS_TEUCHOS_TIME_MONITOR
91 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
93 std::string orthoLabel = ss.str() +
": Orthogonalization";
96 std::string updateLabel = ss.str() +
": Ortho (Update)";
99 std::string normLabel = ss.str() +
": Ortho (Norm)";
102 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
109 const std::string& label =
"Belos",
112 max_blk_ortho_ ( max_blk_ortho_default_ ),
113 blk_tol_ ( blk_tol_default_ ),
114 dep_tol_ ( dep_tol_default_ ),
115 sing_tol_ ( sing_tol_default_ ),
118 setParameterList (plist);
120 #ifdef BELOS_TEUCHOS_TIME_MONITOR
121 std::stringstream ss;
122 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
124 std::string orthoLabel = ss.str() +
": Orthogonalization";
127 std::string updateLabel = ss.str() +
": Ortho (Update)";
130 std::string normLabel = ss.str() +
": Ortho (Norm)";
133 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
149 using Teuchos::parameterList;
152 RCP<const ParameterList> defaultParams = getValidParameters();
153 RCP<ParameterList> params;
156 params = parameterList (*defaultParams);
167 const int maxNumOrthogPasses = params->get<
int> (
"maxNumOrthogPasses");
172 max_blk_ortho_ = maxNumOrthogPasses;
177 this->setMyParamList (params);
183 if (defaultParams_.is_null()) {
184 defaultParams_ = Belos::getDGKSDefaultParameters<ScalarType, MV, OP>();
187 return defaultParams_;
204 params->
set (
"blkTol", blk_tol);
214 params->
set (
"depTol", dep_tol);
224 params->
set (
"singTol", sing_tol);
226 sing_tol_ = sing_tol;
378 projectAndNormalizeWithMxImpl (MV &X,
430 void setLabel(
const std::string& label);
434 const std::string&
getLabel()
const {
return label_; }
474 #ifdef BELOS_TEUCHOS_TIME_MONITOR
476 #endif // BELOS_TEUCHOS_TIME_MONITOR
484 bool completeBasis,
int howMany = -1 )
const;
516 template<
class StorageType,
class MV,
class OP>
517 const int DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::max_blk_ortho_default_ = 2;
519 template<
class StorageType,
class MV,
class OP>
520 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
521 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::blk_tol_default_
525 template<
class StorageType,
class MV,
class OP>
526 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
527 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::dep_tol_default_
532 template<
class StorageType,
class MV,
class OP>
533 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
534 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::sing_tol_default_
537 template<
class StorageType,
class MV,
class OP>
538 const int DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::max_blk_ortho_fast_ = 1;
540 template<
class StorageType,
class MV,
class OP>
541 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
542 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::blk_tol_fast_
545 template<
class StorageType,
class MV,
class OP>
546 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
547 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::dep_tol_fast_
550 template<
class StorageType,
class MV,
class OP>
551 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
552 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::sing_tol_fast_
557 template<
class StorageType,
class MV,
class OP>
558 void DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::setLabel(
const std::string& label)
560 if (label != label_) {
562 #ifdef BELOS_TEUCHOS_TIME_MONITOR
563 std::stringstream ss;
564 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
566 std::string orthoLabel = ss.str() +
": Orthogonalization";
569 std::string updateLabel = ss.str() +
": Ortho (Update)";
572 std::string normLabel = ss.str() +
": Ortho (Norm)";
575 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
583 template<
class StorageType,
class MV,
class OP>
585 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::orthonormError(
const MV &X,
Teuchos::RCP<const MV> MX)
const {
586 const ScalarType ONE = SCT::one();
587 int rank = MVT::GetNumberVecs(X);
590 #ifdef BELOS_TEUCHOS_TIME_MONITOR
593 MatOrthoManager<ScalarType,MV,OP>::innerProd(X,X,MX,xTx);
595 for (
int i=0; i<rank; i++) {
598 return xTx.normFrobenius();
603 template<
class StorageType,
class MV,
class OP>
605 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::orthogError(
const MV &X1,
Teuchos::RCP<const MV> MX1,
const MV &X2)
const {
606 int r1 = MVT::GetNumberVecs(X1);
607 int r2 = MVT::GetNumberVecs(X2);
610 #ifdef BELOS_TEUCHOS_TIME_MONITOR
613 MatOrthoManager<ScalarType,MV,OP>::innerProd(X2,X1,MX1,xTx);
615 return xTx.normFrobenius();
620 template<
class StorageType,
class MV,
class OP>
622 DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::
623 projectAndNormalizeWithMxImpl (MV &X,
635 typedef SerialDenseMatrix< int, ScalarType > serial_dense_matrix_type;
636 typedef typename Array< RCP< const MV > >::size_type size_type;
638 #ifdef BELOS_TEUCHOS_TIME_MONITOR
642 ScalarType ONE = SCT::one();
643 const MagnitudeType ZERO = SCT::magnitude(SCT::zero());
646 int xc = MVT::GetNumberVecs( X );
647 ptrdiff_t xr = MVT::GetGlobalLength( X );
654 B =
rcp (
new serial_dense_matrix_type (xc, xc));
664 for (size_type k = 0; k < nq; ++k)
666 const int numRows = MVT::GetNumberVecs (*Q[k]);
667 const int numCols = xc;
670 C[k] =
rcp (
new serial_dense_matrix_type (numRows, numCols));
671 else if (
C[k]->numRows() != numRows ||
C[k]->numCols() != numCols)
673 int err =
C[k]->reshape (numRows, numCols);
675 "DGKS orthogonalization: failed to reshape "
676 "C[" << k <<
"] (the array of block "
677 "coefficients resulting from projecting X "
678 "against Q[1:" << nq <<
"]).");
686 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
687 OPT::Apply(*(this->_Op),X,*MX);
695 int mxc = MVT::GetNumberVecs( *MX );
696 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
699 TEUCHOS_TEST_FOR_EXCEPTION( xc == 0 || xr == 0, std::invalid_argument,
"Belos::DGKSOrthoManager::projectAndNormalize(): X must be non-empty" );
702 for (
int i=0; i<nq; i++) {
703 numbas += MVT::GetNumberVecs( *Q[i] );
708 "Belos::DGKSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of B" );
711 "Belos::DGKSOrthoManager::projectAndNormalize(): MVT returned negative dimensions for X,MX" );
714 "Belos::DGKSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of MX" );
720 bool dep_flg =
false;
725 dep_flg = blkOrtho1( X, MX,
C, Q );
730 std::vector<ScalarType>
diag(1);
732 #ifdef BELOS_TEUCHOS_TIME_MONITOR
735 MVT::MvDot( X, *MX,
diag );
738 (*B)(0,0) = SCT::squareroot(SCT::magnitude(
diag[0]));
740 ScalarType scale = ONE;
745 MVT::MvScale( X, scale );
748 MVT::MvScale( *MX, scale );
754 tmpX = MVT::CloneCopy(X);
756 tmpMX = MVT::CloneCopy(*MX);
759 dep_flg = blkOrtho( X, MX,
C, Q );
764 rank = blkOrthoSing( *tmpX, tmpMX,
C,
B, Q );
766 MVT::Assign( *tmpX, X );
768 MVT::Assign( *tmpMX, *MX );
773 rank = findBasis( X, MX,
B,
false );
777 rank = blkOrthoSing( *tmpX, tmpMX,
C,
B, Q );
779 MVT::Assign( *tmpX, X );
781 MVT::Assign( *tmpMX, *MX );
789 "Belos::DGKSOrthoManager::projectAndNormalize(): Debug error in rank variable." );
799 template<
class StorageType,
class MV,
class OP>
800 int DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::normalize(
804 #ifdef BELOS_TEUCHOS_TIME_MONITOR
808 return findBasis(X, MX,
B,
true);
815 template<
class StorageType,
class MV,
class OP>
816 void DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::project(
835 #ifdef BELOS_TEUCHOS_TIME_MONITOR
839 int xc = MVT::GetNumberVecs( X );
840 ptrdiff_t xr = MVT::GetGlobalLength( X );
842 std::vector<int> qcs(nq);
844 if (nq == 0 || xc == 0 || xr == 0) {
847 ptrdiff_t qr = MVT::GetGlobalLength ( *Q[0] );
858 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
859 OPT::Apply(*(this->_Op),X,*MX);
866 int mxc = MVT::GetNumberVecs( *MX );
867 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
871 "Belos::DGKSOrthoManager::project(): MVT returned negative dimensions for X,MX" );
874 "Belos::DGKSOrthoManager::project(): Size of X not consistant with MX,Q" );
878 for (
int i=0; i<nq; i++) {
880 "Belos::DGKSOrthoManager::project(): Q lengths not mutually consistant" );
881 qcs[i] = MVT::GetNumberVecs( *Q[i] );
883 "Belos::DGKSOrthoManager::project(): Q has less rows than columns" );
892 "Belos::DGKSOrthoManager::project(): Size of Q not consistant with size of C" );
897 blkOrtho( X, MX,
C, Q );
904 template<
class StorageType,
class MV,
class OP>
905 int DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::findBasis(
908 bool completeBasis,
int howMany )
const {
925 const ScalarType ONE = SCT::one();
926 const MagnitudeType ZERO = SCT::magnitude(SCT::zero());
928 int xc = MVT::GetNumberVecs( X );
929 ptrdiff_t xr = MVT::GetGlobalLength( X );
944 MX = MVT::Clone(X,xc);
945 OPT::Apply(*(this->_Op),X,*MX);
956 int mxc = (this->_hasOp) ? MVT::GetNumberVecs( *MX ) : xc;
957 ptrdiff_t mxr = (this->_hasOp) ? MVT::GetGlobalLength( *MX ) : xr;
961 "Belos::DGKSOrthoManager::findBasis(): X must be non-empty" );
963 "Belos::DGKSOrthoManager::findBasis(): Size of X not consistant with size of B" );
965 "Belos::DGKSOrthoManager::findBasis(): Size of X not consistant with size of MX" );
967 "Belos::DGKSOrthoManager::findBasis(): Size of X not feasible for normalization" );
969 "Belos::DGKSOrthoManager::findBasis(): Invalid howMany parameter" );
974 int xstart = xc - howMany;
976 for (
int j = xstart;
j < xc;
j++) {
985 std::vector<int> index(1);
989 if ((this->_hasOp)) {
991 MXj = MVT::CloneViewNonConst( *MX, index );
999 std::vector<int> prev_idx( numX );
1004 for (
int i=0; i<numX; i++) {
1007 prevX = MVT::CloneView( X, prev_idx );
1009 prevMX = MVT::CloneView( *MX, prev_idx );
1012 oldMXj = MVT::CloneCopy( *MXj );
1017 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1022 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1025 MVT::MvDot( *Xj, *MXj, oldDot );
1029 "Belos::DGKSOrthoManager::findBasis(): Negative definiteness discovered in inner product" );
1035 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1038 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*Xj,MXj,product);
1043 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1046 MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *Xj );
1054 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1057 MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *MXj );
1062 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1065 MVT::MvDot( *Xj, *MXj, newDot );
1069 if ( MGT::squareroot(SCT::magnitude(newDot[0])) < dep_tol_*MGT::squareroot(SCT::magnitude(oldDot[0])) ) {
1074 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1077 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*Xj,MXj,P2);
1082 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1085 MVT::MvTimesMatAddMv( -ONE, *prevX, P2, ONE, *Xj );
1087 if ((this->_hasOp)) {
1088 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1091 MVT::MvTimesMatAddMv( -ONE, *prevMX, P2, ONE, *MXj );
1099 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1102 MVT::MvDot( *Xj, *oldMXj, newDot );
1105 newDot[0] = oldDot[0];
1109 if (completeBasis) {
1113 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(sing_tol_*oldDot[0]) ) {
1118 std::cout <<
"Belos::DGKSOrthoManager::findBasis() --> Random for column " << numX << std::endl;
1123 MVT::MvRandom( *tempXj );
1125 tempMXj = MVT::Clone( X, 1 );
1126 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1132 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1135 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1138 for (
int num_orth=0; num_orth<max_blk_ortho_; num_orth++){
1140 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1143 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*tempXj,tempMXj,product);
1146 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1149 MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *tempXj );
1152 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1155 MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *tempMXj );
1160 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1163 MVT::MvDot( *tempXj, *tempMXj, newDot );
1166 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1168 MVT::Assign( *tempXj, *Xj );
1170 MVT::Assign( *tempMXj, *MXj );
1182 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*blk_tol_) ) {
1189 ScalarType
diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1190 ScalarType scale = ONE;
1192 MVT::MvScale( *Xj, scale );
1195 MVT::MvScale( *MXj, scale );
1208 for (
int i=0; i<numX; i++) {
1209 (*B)(i,
j) = product(i,0);
1219 template<
class StorageType,
class MV,
class OP>
1221 DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrtho1 ( MV &X,
Teuchos::RCP<MV> MX,
1226 int xc = MVT::GetNumberVecs( X );
1227 const ScalarType ONE = SCT::one();
1229 std::vector<int> qcs( nq );
1230 for (
int i=0; i<nq; i++) {
1231 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1235 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1237 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1240 MVT::MvDot( X, *MX, oldDot );
1245 for (
int i=0; i<nq; i++) {
1248 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1251 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,*
C[i]);
1255 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1258 MVT::MvTimesMatAddMv( -ONE, *Q[i], *
C[i], ONE, X );
1264 OPT::Apply( *(this->_Op), X, *MX);
1268 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1269 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1271 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1274 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *
C[i], ONE, *MX );
1280 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1283 MVT::MvDot( X, *MX, newDot );
1296 if ( MGT::squareroot(SCT::magnitude(newDot[0])) < dep_tol_*MGT::squareroot(SCT::magnitude(oldDot[0])) ) {
1299 for (
int i=0; i<nq; i++) {
1304 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1307 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,C2);
1312 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1315 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1321 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1325 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1327 else if (xc <= qcs[i]) {
1329 OPT::Apply( *(this->_Op), X, *MX);
1339 template<
class StorageType,
class MV,
class OP>
1341 DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrtho ( MV &X,
Teuchos::RCP<MV> MX,
1346 int xc = MVT::GetNumberVecs( X );
1347 bool dep_flg =
false;
1348 const ScalarType ONE = SCT::one();
1350 std::vector<int> qcs( nq );
1351 for (
int i=0; i<nq; i++) {
1352 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1358 std::vector<ScalarType> oldDot( xc );
1360 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1363 MVT::MvDot( X, *MX, oldDot );
1368 for (
int i=0; i<nq; i++) {
1371 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1374 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,*
C[i]);
1378 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1381 MVT::MvTimesMatAddMv( -ONE, *Q[i], *
C[i], ONE, X );
1387 OPT::Apply( *(this->_Op), X, *MX);
1391 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1392 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1394 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1397 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *
C[i], ONE, *MX );
1404 for (
int j = 1;
j < max_blk_ortho_; ++
j) {
1406 for (
int i=0; i<nq; i++) {
1411 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1414 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,C2);
1419 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1422 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1428 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1432 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1434 else if (xc <= qcs[i]) {
1436 OPT::Apply( *(this->_Op), X, *MX);
1443 std::vector<ScalarType> newDot(xc);
1445 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1448 MVT::MvDot( X, *MX, newDot );
1452 for (
int i=0; i<xc; i++){
1453 if (SCT::magnitude(newDot[i]) < SCT::magnitude(oldDot[i] * blk_tol_)) {
1463 template<
class StorageType,
class MV,
class OP>
1465 DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrthoSing ( MV &X,
Teuchos::RCP<MV> MX,
1472 const ScalarType ONE = SCT::one();
1473 const ScalarType ZERO = SCT::zero();
1476 int xc = MVT::GetNumberVecs( X );
1477 std::vector<int> indX( 1 );
1478 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1480 std::vector<int> qcs( nq );
1481 for (
int i=0; i<nq; i++) {
1482 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1491 for (
int j=0;
j<xc;
j++) {
1493 bool dep_flg =
false;
1497 std::vector<int> index(
j );
1498 for (
int ind=0; ind<
j; ind++) {
1501 lastQ = MVT::CloneView( X, index );
1504 Q.push_back( lastQ );
1506 qcs.push_back( MVT::GetNumberVecs( *lastQ ) );
1511 Xj = MVT::CloneViewNonConst( X, indX );
1513 MXj = MVT::CloneViewNonConst( *MX, indX );
1521 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1524 MVT::MvDot( *Xj, *MXj, oldDot );
1529 for (
int i=0; i<Q.size(); i++) {
1536 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1539 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*Xj,MXj,tempC);
1543 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1546 MVT::MvTimesMatAddMv( -ONE, *Q[i], tempC, ONE, *Xj );
1552 OPT::Apply( *(this->_Op), *Xj, *MXj);
1556 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1557 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1559 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1562 MVT::MvTimesMatAddMv( -ONE, *MQ[i], tempC, ONE, *MXj );
1570 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1573 MVT::MvDot( *Xj, *MXj, newDot );
1579 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*dep_tol_) ) {
1581 for (
int i=0; i<Q.size(); i++) {
1587 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1590 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*Xj,MXj,C2);
1594 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1597 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, *Xj );
1603 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1607 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MXj );
1609 else if (xc <= qcs[i]) {
1611 OPT::Apply( *(this->_Op), *Xj, *MXj);
1618 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1621 MVT::MvDot( *Xj, *MXj, newDot );
1626 if (SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*sing_tol_)) {
1632 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1634 MVT::MvScale( *Xj, ONE/diag );
1637 MVT::MvScale( *MXj, ONE/diag );
1647 MVT::MvRandom( *tempXj );
1649 tempMXj = MVT::Clone( X, 1 );
1650 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1656 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1659 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1662 for (
int num_orth=0; num_orth<max_blk_ortho_; num_orth++) {
1664 for (
int i=0; i<Q.size(); i++) {
1669 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1672 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*tempXj,tempMXj,product);
1675 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1678 MVT::MvTimesMatAddMv( -ONE, *Q[i], product, ONE, *tempXj );
1684 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1688 MVT::MvTimesMatAddMv( -ONE, *MQ[i], product, ONE, *tempMXj );
1690 else if (xc <= qcs[i]) {
1692 OPT::Apply( *(this->_Op), *tempXj, *tempMXj);
1701 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1704 MVT::MvDot( *tempXj, *tempMXj, newDot );
1708 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1709 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1715 MVT::MvAddMv( ONE/diag, *tempXj, ZERO, *tempXj, *Xj );
1717 MVT::MvAddMv( ONE/diag, *tempMXj, ZERO, *tempMXj, *MXj );
1739 #endif // BELOS_DGKS_ORTHOMANAGER_MP_VECTOR_HPP
MultiVecTraits< ScalarType, MV > MVT
static const MagnitudeType sing_tol_default_
Singular block detection threshold (default).
Sacado::MP::Vector< Storage > ScalarType
static const MagnitudeType dep_tol_fast_
(Non-block) reorthogonalization threshold (fast).
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)
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
MagnitudeType getBlkTol() const
Return parameter for block re-orthogonalization threshhold.
MagnitudeType blk_tol_
Block reorthogonalization threshold.
int max_blk_ortho_
Max number of (re)orthogonalization steps, including the first.
KOKKOS_INLINE_FUNCTION bool OR(Mask< T > m)
Teuchos::ScalarTraits< ScalarType >::magnitudeType orthonormError(const MV &X) const
void setSingTol(const MagnitudeType sing_tol)
Set parameter for singular block detection.
KOKKOS_INLINE_FUNCTION MaskedAssign< scalar > mask_assign(bool b, scalar *s)
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 sing_tol_
Singular block detection threshold.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Teuchos::ScalarTraits< ScalarType > SCT
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool is_null(const RCP< T > &p)
static const MagnitudeType blk_tol_default_
Block reorthogonalization threshold (default).
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.
static const MagnitudeType sing_tol_fast_
Singular block detection threshold (fast).
MagnitudeType getDepTol() const
Return parameter for re-orthogonalization threshhold.
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
~DGKSOrthoManager()
Destructor.
OperatorTraits< ScalarType, MV, OP > OPT
Teuchos::ScalarTraits< MagnitudeType > MGT
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.
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.
static const MagnitudeType blk_tol_fast_
Block reorthogonalization threshold (fast).
static const int max_blk_ortho_default_
Max number of (re)orthogonalization steps, including the first (default).
Teuchos::RCP< Teuchos::ParameterList > defaultParams_
Default parameter list.
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.
MagnitudeType getSingTol() const
Return parameter for singular block detection.
void setBlkTol(const MagnitudeType blk_tol)
Set parameter for block re-orthogonalization threshhold.
Teuchos::ScalarTraits< ScalarType >::magnitudeType MagnitudeType
std::string label_
Label for timer(s).
MagnitudeType dep_tol_
(Non-block) reorthogonalization threshold.
void setDepTol(const MagnitudeType dep_tol)
Set parameter for re-orthogonalization threshhold.
static const int max_blk_ortho_fast_
Max number of (re)orthogonalization steps, including the first (fast).
static const MagnitudeType dep_tol_default_
(Non-block) reorthogonalization threshold (default).