18 #ifndef BELOS_DGKS_ORTHOMANAGER_MP_VECTOR_HPP
19 #define BELOS_DGKS_ORTHOMANAGER_MP_VECTOR_HPP
22 #include "BelosDGKSOrthoManager.hpp"
26 template<
class Storage,
class MV,
class OP>
27 class DGKSOrthoManager<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_blk_ortho = max_blk_ortho_default_,
50 max_blk_ortho_( max_blk_ortho ),
53 sing_tol_( sing_tol ),
56 #ifdef BELOS_TEUCHOS_TIME_MONITOR
58 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
60 std::string orthoLabel = ss.str() +
": Orthogonalization";
63 std::string updateLabel = ss.str() +
": Ortho (Update)";
66 std::string normLabel = ss.str() +
": Ortho (Norm)";
69 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
76 const std::string& label =
"Belos",
79 max_blk_ortho_ ( max_blk_ortho_default_ ),
80 blk_tol_ ( blk_tol_default_ ),
81 dep_tol_ ( dep_tol_default_ ),
82 sing_tol_ ( sing_tol_default_ ),
85 setParameterList (plist);
87 #ifdef BELOS_TEUCHOS_TIME_MONITOR
89 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
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)";
116 using Teuchos::parameterList;
119 RCP<const ParameterList> defaultParams = getValidParameters();
120 RCP<ParameterList> params;
123 params = parameterList (*defaultParams);
134 const int maxNumOrthogPasses = params->get<
int> (
"maxNumOrthogPasses");
139 max_blk_ortho_ = maxNumOrthogPasses;
144 this->setMyParamList (params);
150 if (defaultParams_.is_null()) {
151 defaultParams_ = Belos::getDGKSDefaultParameters<ScalarType, MV, OP>();
154 return defaultParams_;
171 params->
set (
"blkTol", blk_tol);
181 params->
set (
"depTol", dep_tol);
191 params->
set (
"singTol", sing_tol);
193 sing_tol_ = sing_tol;
345 projectAndNormalizeWithMxImpl (MV &X,
397 void setLabel(
const std::string& label);
401 const std::string&
getLabel()
const {
return label_; }
441 #ifdef BELOS_TEUCHOS_TIME_MONITOR
443 #endif // BELOS_TEUCHOS_TIME_MONITOR
451 bool completeBasis,
int howMany = -1 )
const;
483 template<
class StorageType,
class MV,
class OP>
484 const int DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::max_blk_ortho_default_ = 2;
486 template<
class StorageType,
class MV,
class OP>
487 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
488 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::blk_tol_default_
492 template<
class StorageType,
class MV,
class OP>
493 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
494 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::dep_tol_default_
499 template<
class StorageType,
class MV,
class OP>
500 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
501 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::sing_tol_default_
504 template<
class StorageType,
class MV,
class OP>
505 const int DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::max_blk_ortho_fast_ = 1;
507 template<
class StorageType,
class MV,
class OP>
508 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
509 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::blk_tol_fast_
512 template<
class StorageType,
class MV,
class OP>
513 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
514 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::dep_tol_fast_
517 template<
class StorageType,
class MV,
class OP>
518 const typename DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::MagnitudeType
519 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::sing_tol_fast_
524 template<
class StorageType,
class MV,
class OP>
525 void DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::setLabel(
const std::string& label)
527 if (label != label_) {
529 #ifdef BELOS_TEUCHOS_TIME_MONITOR
530 std::stringstream ss;
531 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
533 std::string orthoLabel = ss.str() +
": Orthogonalization";
536 std::string updateLabel = ss.str() +
": Ortho (Update)";
539 std::string normLabel = ss.str() +
": Ortho (Norm)";
542 std::string ipLabel = ss.str() +
": Ortho (Inner Product)";
550 template<
class StorageType,
class MV,
class OP>
552 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::orthonormError(
const MV &X,
Teuchos::RCP<const MV> MX)
const {
553 const ScalarType ONE = SCT::one();
554 int rank = MVT::GetNumberVecs(X);
557 #ifdef BELOS_TEUCHOS_TIME_MONITOR
560 MatOrthoManager<ScalarType,MV,OP>::innerProd(X,X,MX,xTx);
562 for (
int i=0; i<rank; i++) {
565 return xTx.normFrobenius();
570 template<
class StorageType,
class MV,
class OP>
572 DGKSOrthoManager<Sacado::MP::Vector<StorageType>,MV,OP>::orthogError(
const MV &X1,
Teuchos::RCP<const MV> MX1,
const MV &X2)
const {
573 int r1 = MVT::GetNumberVecs(X1);
574 int r2 = MVT::GetNumberVecs(X2);
577 #ifdef BELOS_TEUCHOS_TIME_MONITOR
580 MatOrthoManager<ScalarType,MV,OP>::innerProd(X2,X1,MX1,xTx);
582 return xTx.normFrobenius();
587 template<
class StorageType,
class MV,
class OP>
589 DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::
590 projectAndNormalizeWithMxImpl (MV &X,
602 typedef SerialDenseMatrix< int, ScalarType > serial_dense_matrix_type;
603 typedef typename Array< RCP< const MV > >::size_type size_type;
605 #ifdef BELOS_TEUCHOS_TIME_MONITOR
609 ScalarType ONE = SCT::one();
610 const MagnitudeType ZERO = SCT::magnitude(SCT::zero());
613 int xc = MVT::GetNumberVecs( X );
614 ptrdiff_t xr = MVT::GetGlobalLength( X );
621 B =
rcp (
new serial_dense_matrix_type (xc, xc));
631 for (size_type k = 0; k < nq; ++k)
633 const int numRows = MVT::GetNumberVecs (*Q[k]);
634 const int numCols = xc;
637 C[k] =
rcp (
new serial_dense_matrix_type (numRows, numCols));
638 else if (
C[k]->numRows() != numRows ||
C[k]->numCols() != numCols)
640 int err =
C[k]->reshape (numRows, numCols);
642 "DGKS orthogonalization: failed to reshape "
643 "C[" << k <<
"] (the array of block "
644 "coefficients resulting from projecting X "
645 "against Q[1:" << nq <<
"]).");
653 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
654 OPT::Apply(*(this->_Op),X,*MX);
662 int mxc = MVT::GetNumberVecs( *MX );
663 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
666 TEUCHOS_TEST_FOR_EXCEPTION( xc == 0 || xr == 0, std::invalid_argument,
"Belos::DGKSOrthoManager::projectAndNormalize(): X must be non-empty" );
669 for (
int i=0; i<nq; i++) {
670 numbas += MVT::GetNumberVecs( *Q[i] );
675 "Belos::DGKSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of B" );
678 "Belos::DGKSOrthoManager::projectAndNormalize(): MVT returned negative dimensions for X,MX" );
681 "Belos::DGKSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of MX" );
687 bool dep_flg =
false;
692 dep_flg = blkOrtho1( X, MX,
C, Q );
697 std::vector<ScalarType>
diag(1);
699 #ifdef BELOS_TEUCHOS_TIME_MONITOR
702 MVT::MvDot( X, *MX,
diag );
705 (*B)(0,0) = SCT::squareroot(SCT::magnitude(
diag[0]));
707 ScalarType scale = ONE;
712 MVT::MvScale( X, scale );
715 MVT::MvScale( *MX, scale );
721 tmpX = MVT::CloneCopy(X);
723 tmpMX = MVT::CloneCopy(*MX);
726 dep_flg = blkOrtho( X, MX,
C, Q );
731 rank = blkOrthoSing( *tmpX, tmpMX,
C,
B, Q );
733 MVT::Assign( *tmpX, X );
735 MVT::Assign( *tmpMX, *MX );
740 rank = findBasis( X, MX,
B,
false );
744 rank = blkOrthoSing( *tmpX, tmpMX,
C,
B, Q );
746 MVT::Assign( *tmpX, X );
748 MVT::Assign( *tmpMX, *MX );
756 "Belos::DGKSOrthoManager::projectAndNormalize(): Debug error in rank variable." );
766 template<
class StorageType,
class MV,
class OP>
767 int DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::normalize(
771 #ifdef BELOS_TEUCHOS_TIME_MONITOR
775 return findBasis(X, MX,
B,
true);
782 template<
class StorageType,
class MV,
class OP>
783 void DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::project(
802 #ifdef BELOS_TEUCHOS_TIME_MONITOR
806 int xc = MVT::GetNumberVecs( X );
807 ptrdiff_t xr = MVT::GetGlobalLength( X );
809 std::vector<int> qcs(nq);
811 if (nq == 0 || xc == 0 || xr == 0) {
814 ptrdiff_t qr = MVT::GetGlobalLength ( *Q[0] );
825 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
826 OPT::Apply(*(this->_Op),X,*MX);
833 int mxc = MVT::GetNumberVecs( *MX );
834 ptrdiff_t mxr = MVT::GetGlobalLength( *MX );
838 "Belos::DGKSOrthoManager::project(): MVT returned negative dimensions for X,MX" );
841 "Belos::DGKSOrthoManager::project(): Size of X not consistant with MX,Q" );
845 for (
int i=0; i<nq; i++) {
847 "Belos::DGKSOrthoManager::project(): Q lengths not mutually consistant" );
848 qcs[i] = MVT::GetNumberVecs( *Q[i] );
850 "Belos::DGKSOrthoManager::project(): Q has less rows than columns" );
859 "Belos::DGKSOrthoManager::project(): Size of Q not consistant with size of C" );
864 blkOrtho( X, MX,
C, Q );
871 template<
class StorageType,
class MV,
class OP>
872 int DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::findBasis(
875 bool completeBasis,
int howMany )
const {
892 const ScalarType ONE = SCT::one();
893 const MagnitudeType ZERO = SCT::magnitude(SCT::zero());
895 int xc = MVT::GetNumberVecs( X );
896 ptrdiff_t xr = MVT::GetGlobalLength( X );
911 MX = MVT::Clone(X,xc);
912 OPT::Apply(*(this->_Op),X,*MX);
923 int mxc = (this->_hasOp) ? MVT::GetNumberVecs( *MX ) : xc;
924 ptrdiff_t mxr = (this->_hasOp) ? MVT::GetGlobalLength( *MX ) : xr;
928 "Belos::DGKSOrthoManager::findBasis(): X must be non-empty" );
930 "Belos::DGKSOrthoManager::findBasis(): Size of X not consistant with size of B" );
932 "Belos::DGKSOrthoManager::findBasis(): Size of X not consistant with size of MX" );
934 "Belos::DGKSOrthoManager::findBasis(): Size of X not feasible for normalization" );
936 "Belos::DGKSOrthoManager::findBasis(): Invalid howMany parameter" );
941 int xstart = xc - howMany;
943 for (
int j = xstart;
j < xc;
j++) {
952 std::vector<int> index(1);
956 if ((this->_hasOp)) {
958 MXj = MVT::CloneViewNonConst( *MX, index );
966 std::vector<int> prev_idx( numX );
971 for (
int i=0; i<numX; i++) {
974 prevX = MVT::CloneView( X, prev_idx );
976 prevMX = MVT::CloneView( *MX, prev_idx );
979 oldMXj = MVT::CloneCopy( *MXj );
984 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
989 #ifdef BELOS_TEUCHOS_TIME_MONITOR
992 MVT::MvDot( *Xj, *MXj, oldDot );
996 "Belos::DGKSOrthoManager::findBasis(): Negative definiteness discovered in inner product" );
1002 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1005 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*Xj,MXj,product);
1010 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1013 MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *Xj );
1021 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1024 MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *MXj );
1029 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1032 MVT::MvDot( *Xj, *MXj, newDot );
1036 if ( MGT::squareroot(SCT::magnitude(newDot[0])) < dep_tol_*MGT::squareroot(SCT::magnitude(oldDot[0])) ) {
1041 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1044 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*Xj,MXj,P2);
1049 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1052 MVT::MvTimesMatAddMv( -ONE, *prevX, P2, ONE, *Xj );
1054 if ((this->_hasOp)) {
1055 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1058 MVT::MvTimesMatAddMv( -ONE, *prevMX, P2, ONE, *MXj );
1066 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1069 MVT::MvDot( *Xj, *oldMXj, newDot );
1072 newDot[0] = oldDot[0];
1076 if (completeBasis) {
1080 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(sing_tol_*oldDot[0]) ) {
1085 std::cout <<
"Belos::DGKSOrthoManager::findBasis() --> Random for column " << numX << std::endl;
1090 MVT::MvRandom( *tempXj );
1092 tempMXj = MVT::Clone( X, 1 );
1093 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1099 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1102 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1105 for (
int num_orth=0; num_orth<max_blk_ortho_; num_orth++){
1107 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1110 MatOrthoManager<ScalarType,MV,OP>::innerProd(*prevX,*tempXj,tempMXj,product);
1113 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1116 MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *tempXj );
1119 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1122 MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *tempMXj );
1127 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1130 MVT::MvDot( *tempXj, *tempMXj, newDot );
1133 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1135 MVT::Assign( *tempXj, *Xj );
1137 MVT::Assign( *tempMXj, *MXj );
1149 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*blk_tol_) ) {
1156 ScalarType
diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1157 ScalarType scale = ONE;
1159 MVT::MvScale( *Xj, scale );
1162 MVT::MvScale( *MXj, scale );
1175 for (
int i=0; i<numX; i++) {
1176 (*B)(i,
j) = product(i,0);
1186 template<
class StorageType,
class MV,
class OP>
1188 DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrtho1 ( MV &X,
Teuchos::RCP<MV> MX,
1193 int xc = MVT::GetNumberVecs( X );
1194 const ScalarType ONE = SCT::one();
1196 std::vector<int> qcs( nq );
1197 for (
int i=0; i<nq; i++) {
1198 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1202 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1204 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1207 MVT::MvDot( X, *MX, oldDot );
1212 for (
int i=0; i<nq; i++) {
1215 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1218 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,*
C[i]);
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 );
1247 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1250 MVT::MvDot( X, *MX, newDot );
1263 if ( MGT::squareroot(SCT::magnitude(newDot[0])) < dep_tol_*MGT::squareroot(SCT::magnitude(oldDot[0])) ) {
1266 for (
int i=0; i<nq; i++) {
1271 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1274 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);
1306 template<
class StorageType,
class MV,
class OP>
1308 DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrtho ( MV &X,
Teuchos::RCP<MV> MX,
1313 int xc = MVT::GetNumberVecs( X );
1314 bool dep_flg =
false;
1315 const ScalarType ONE = SCT::one();
1317 std::vector<int> qcs( nq );
1318 for (
int i=0; i<nq; i++) {
1319 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1325 std::vector<ScalarType> oldDot( xc );
1327 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1330 MVT::MvDot( X, *MX, oldDot );
1335 for (
int i=0; i<nq; i++) {
1338 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1341 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],X,MX,*
C[i]);
1345 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1348 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_blk_ortho_; ++
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);
1386 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1389 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1395 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1399 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1401 else if (xc <= qcs[i]) {
1403 OPT::Apply( *(this->_Op), X, *MX);
1410 std::vector<ScalarType> newDot(xc);
1412 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1415 MVT::MvDot( X, *MX, newDot );
1419 for (
int i=0; i<xc; i++){
1420 if (SCT::magnitude(newDot[i]) < SCT::magnitude(oldDot[i] * blk_tol_)) {
1430 template<
class StorageType,
class MV,
class OP>
1432 DGKSOrthoManager<Sacado::MP::Vector<StorageType>, MV, OP>::blkOrthoSing ( MV &X,
Teuchos::RCP<MV> MX,
1439 const ScalarType ONE = SCT::one();
1440 const ScalarType ZERO = SCT::zero();
1443 int xc = MVT::GetNumberVecs( X );
1444 std::vector<int> indX( 1 );
1445 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1447 std::vector<int> qcs( nq );
1448 for (
int i=0; i<nq; i++) {
1449 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1458 for (
int j=0;
j<xc;
j++) {
1460 bool dep_flg =
false;
1464 std::vector<int> index(
j );
1465 for (
int ind=0; ind<
j; ind++) {
1468 lastQ = MVT::CloneView( X, index );
1471 Q.push_back( lastQ );
1473 qcs.push_back( MVT::GetNumberVecs( *lastQ ) );
1478 Xj = MVT::CloneViewNonConst( X, indX );
1480 MXj = MVT::CloneViewNonConst( *MX, indX );
1488 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1491 MVT::MvDot( *Xj, *MXj, oldDot );
1496 for (
int i=0; i<Q.size(); i++) {
1503 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1506 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*Xj,MXj,tempC);
1510 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1513 MVT::MvTimesMatAddMv( -ONE, *Q[i], tempC, ONE, *Xj );
1519 OPT::Apply( *(this->_Op), *Xj, *MXj);
1523 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1524 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1526 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1529 MVT::MvTimesMatAddMv( -ONE, *MQ[i], tempC, ONE, *MXj );
1537 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1540 MVT::MvDot( *Xj, *MXj, newDot );
1546 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*dep_tol_) ) {
1548 for (
int i=0; i<Q.size(); i++) {
1554 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1557 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*Xj,MXj,C2);
1561 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1564 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, *Xj );
1570 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1574 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MXj );
1576 else if (xc <= qcs[i]) {
1578 OPT::Apply( *(this->_Op), *Xj, *MXj);
1585 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1588 MVT::MvDot( *Xj, *MXj, newDot );
1593 if (SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*sing_tol_)) {
1599 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1601 MVT::MvScale( *Xj, ONE/diag );
1604 MVT::MvScale( *MXj, ONE/diag );
1614 MVT::MvRandom( *tempXj );
1616 tempMXj = MVT::Clone( X, 1 );
1617 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1623 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1626 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1629 for (
int num_orth=0; num_orth<max_blk_ortho_; num_orth++) {
1631 for (
int i=0; i<Q.size(); i++) {
1636 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1639 MatOrthoManager<ScalarType,MV,OP>::innerProd(*Q[i],*tempXj,tempMXj,product);
1642 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1645 MVT::MvTimesMatAddMv( -ONE, *Q[i], product, ONE, *tempXj );
1651 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1655 MVT::MvTimesMatAddMv( -ONE, *MQ[i], product, ONE, *tempMXj );
1657 else if (xc <= qcs[i]) {
1659 OPT::Apply( *(this->_Op), *tempXj, *tempMXj);
1668 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1671 MVT::MvDot( *tempXj, *tempMXj, newDot );
1675 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1676 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1682 MVT::MvAddMv( ONE/diag, *tempXj, ZERO, *tempXj, *Xj );
1684 MVT::MvAddMv( ONE/diag, *tempMXj, ZERO, *tempMXj, *MXj );
1706 #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.
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)
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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).