47 #ifndef BELOS_ICGS_ORTHOMANAGER_HPP
48 #define BELOS_ICGS_ORTHOMANAGER_HPP
65 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
66 #ifdef BELOS_TEUCHOS_TIME_MONITOR
68 #endif // BELOS_TEUCHOS_TIME_MONITOR
76 template<
class ScalarType>
86 const int defaultMaxNumOrthogPasses = 2;
87 const magnitude_type eps = STM::eps();
88 const magnitude_type defaultBlkTol =
89 as<magnitude_type> (10) * STM::squareroot (eps);
90 const magnitude_type defaultSingTol = as<magnitude_type> (10) * eps;
93 Teuchos::parameterList (
"ICGS");
94 params->set (
"maxNumOrthogPasses", defaultMaxNumOrthogPasses,
95 "Maximum number of orthogonalization passes "
96 "(includes the first). Default is 2, since "
97 "\"twice is enough\" for Krylov methods.");
98 params->set (
"blkTol", defaultBlkTol,
99 "Block reorthogonalization threshhold.");
100 params->set (
"singTol", defaultSingTol,
101 "Singular block detection threshold.");
109 template<
class ScalarType>
118 typedef ScalarTraits<magnitude_type> STM;
120 RCP<const ParameterList> defaultParams = getDefaultIcgsParameters<ScalarType>();
122 RCP<ParameterList> params =
rcp (
new ParameterList (*defaultParams));
124 const int maxBlkOrtho = 1;
125 const magnitude_type blkTol = STM::zero();
126 const magnitude_type singTol = STM::zero();
128 params->set (
"maxNumOrthogPasses", maxBlkOrtho);
129 params->set (
"blkTol", blkTol);
130 params->set (
"singTol", singTol);
144 template<
class ScalarType>
145 void TEUCHOS_DEPRECATED
147 int& maxNumOrthogPasses,
155 RCP<const ParameterList> defaultParams = getDefaultIcgsParameters<ScalarType>();
162 int _maxNumOrthogPasses;
163 magnitude_type _blkTol, _singTol;
165 _maxNumOrthogPasses = defaultParams->get<
int> (
"maxNumOrthogPasses");
166 _blkTol = defaultParams->get<magnitude_type> (
"blkTol");
167 _singTol = defaultParams->get<magnitude_type> (
"singTol");
170 _maxNumOrthogPasses = params->
get<
int> (
"maxNumOrthogPasses");
171 if (_maxNumOrthogPasses < 1)
172 _maxNumOrthogPasses = defaultParams->get<
int> (
"maxNumOrthogPasses");
174 _maxNumOrthogPasses = defaultParams->get<
int> (
"maxNumOrthogPasses");
178 _blkTol = params->
get<magnitude_type> (
"blkTol");
180 _blkTol = defaultParams->get<magnitude_type> (
"blkTol");
185 _blkTol = params->
get<magnitude_type> (
"depTol");
187 _blkTol = defaultParams->get<magnitude_type> (
"blkTol");
192 _singTol = params->
get<magnitude_type> (
"singTol");
194 _singTol = defaultParams->get<magnitude_type> (
"singTol");
196 _singTol = defaultParams->get<magnitude_type> (
"singTol");
199 maxNumOrthogPasses = _maxNumOrthogPasses;
205 template<
class ScalarType,
class MV,
class OP>
225 const int max_ortho_steps = 2,
227 const MagnitudeType sing_tol = 10*
MGT::eps() )
229 max_ortho_steps_( max_ortho_steps ),
231 sing_tol_( sing_tol ),
234 #ifdef BELOS_TEUCHOS_TIME_MONITOR
235 std::string orthoLabel = label_ +
": Orthogonalization";
238 std::string updateLabel = label_ +
": Ortho (Update)";
241 std::string normLabel = label_ +
": Ortho (Norm)";
244 std::string ipLabel = label_ +
": Ortho (Inner Product)";
251 const std::string& label =
"Belos",
254 max_ortho_steps_ (2),
255 blk_tol_ (10 *
MGT::squareroot (
MGT::eps())),
256 sing_tol_ (10 *
MGT::eps()),
261 #ifdef BELOS_TEUCHOS_TIME_MONITOR
262 std::string orthoLabel = label_ +
": Orthogonalization";
265 std::string updateLabel = label_ +
": Ortho (Update)";
268 std::string normLabel = label_ +
": Ortho (Norm)";
271 std::string ipLabel = label_ +
": Ortho (Inner Product)";
288 using Teuchos::parameterList;
292 RCP<ParameterList> params;
294 params = parameterList (*defaultParams);
309 int maxNumOrthogPasses;
310 MagnitudeType blkTol;
311 MagnitudeType singTol;
314 maxNumOrthogPasses = params->
get<
int> (
"maxNumOrthogPasses");
315 }
catch (InvalidParameterName&) {
316 maxNumOrthogPasses = defaultParams->get<
int> (
"maxNumOrthogPasses");
317 params->set (
"maxNumOrthogPasses", maxNumOrthogPasses);
328 blkTol = params->get<MagnitudeType> (
"blkTol");
329 }
catch (InvalidParameterName&) {
331 blkTol = params->get<MagnitudeType> (
"depTol");
334 params->remove (
"depTol");
335 }
catch (InvalidParameterName&) {
336 blkTol = defaultParams->get<MagnitudeType> (
"blkTol");
338 params->set (
"blkTol", blkTol);
342 singTol = params->get<MagnitudeType> (
"singTol");
343 }
catch (InvalidParameterName&) {
344 singTol = defaultParams->get<MagnitudeType> (
"singTol");
345 params->set (
"singTol", singTol);
348 max_ortho_steps_ = maxNumOrthogPasses;
360 using Teuchos::parameterList;
363 if (defaultParams_.
is_null()) {
364 RCP<ParameterList> params = parameterList (
"ICGS");
368 const int defaultMaxNumOrthogPasses = 2;
369 const MagnitudeType eps =
MGT::eps();
370 const MagnitudeType defaultBlkTol =
372 const MagnitudeType defaultSingTol = as<MagnitudeType> (10) * eps;
374 params->set (
"maxNumOrthogPasses", defaultMaxNumOrthogPasses,
375 "Maximum number of orthogonalization passes (includes the "
376 "first). Default is 2, since \"twice is enough\" for Krylov "
378 params->set (
"blkTol", defaultBlkTol,
"Block reorthogonalization "
380 params->set (
"singTol", defaultSingTol,
"Singular block detection "
382 defaultParams_ = params;
384 return defaultParams_;
397 using Teuchos::parameterList;
402 RCP<ParameterList> params = parameterList (*defaultParams);
404 const int maxBlkOrtho = 1;
405 const MagnitudeType blkTol =
MGT::zero();
406 const MagnitudeType singTol =
MGT::zero();
408 params->set (
"maxNumOrthogPasses", maxBlkOrtho);
409 params->set (
"blkTol", blkTol);
410 params->set (
"singTol", singTol);
427 params->
set (
"blkTol", blk_tol);
441 params->
set (
"singTol", sing_tol);
443 sing_tol_ = sing_tol;
632 void setLabel(
const std::string& label);
636 const std::string&
getLabel()
const {
return label_; }
642 int max_ortho_steps_;
644 MagnitudeType blk_tol_;
646 MagnitudeType sing_tol_;
650 #ifdef BELOS_TEUCHOS_TIME_MONITOR
652 timerNorm_, timerScale_, timerInnerProd_;
653 #endif // BELOS_TEUCHOS_TIME_MONITOR
661 bool completeBasis,
int howMany = -1 )
const;
694 template<
class ScalarType,
class MV,
class OP>
697 if (label != label_) {
699 std::string orthoLabel = label_ +
": Orthogonalization";
700 #ifdef BELOS_TEUCHOS_TIME_MONITOR
704 std::string updateLabel = label_ +
": Ortho (Update)";
705 #ifdef BELOS_TEUCHOS_TIME_MONITOR
709 std::string normLabel = label_ +
": Ortho (Norm)";
710 #ifdef BELOS_TEUCHOS_TIME_MONITOR
714 std::string ipLabel = label_ +
": Ortho (Inner Product)";
715 #ifdef BELOS_TEUCHOS_TIME_MONITOR
723 template<
class ScalarType,
class MV,
class OP>
726 const ScalarType ONE = SCT::one();
727 int rank = MVT::GetNumberVecs(X);
730 for (
int i=0; i<rank; i++) {
738 template<
class ScalarType,
class MV,
class OP>
741 int r1 = MVT::GetNumberVecs(X1);
742 int r2 = MVT::GetNumberVecs(X2);
750 template<
class ScalarType,
class MV,
class OP>
764 typedef typename Array< RCP< const MV > >::size_type size_type;
766 #ifdef BELOS_TEUCHOS_TIME_MONITOR
770 ScalarType ONE = SCT::one();
774 int xc = MVT::GetNumberVecs( X );
775 ptrdiff_t xr = MVText::GetGlobalLength( X );
782 B =
rcp (
new serial_dense_matrix_type (xc, xc));
792 for (size_type k = 0; k < nq; ++k)
794 const int numRows = MVT::GetNumberVecs (*Q[k]);
795 const int numCols = xc;
798 C[k] =
rcp (
new serial_dense_matrix_type (numRows, numCols));
799 else if (C[k]->numRows() != numRows || C[k]->numCols() != numCols)
801 int err = C[k]->reshape (numRows, numCols);
803 "IMGS orthogonalization: failed to reshape "
804 "C[" << k <<
"] (the array of block "
805 "coefficients resulting from projecting X "
806 "against Q[1:" << nq <<
"]).");
812 if (MX == Teuchos::null) {
814 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
815 OPT::Apply(*(this->_Op),X,*MX);
823 int mxc = MVT::GetNumberVecs( *MX );
824 ptrdiff_t mxr = MVText::GetGlobalLength( *MX );
827 TEUCHOS_TEST_FOR_EXCEPTION( xc == 0 || xr == 0, std::invalid_argument,
"Belos::ICGSOrthoManager::projectAndNormalize(): X must be non-empty" );
830 for (
int i=0; i<nq; i++) {
831 numbas += MVT::GetNumberVecs( *Q[i] );
836 "Belos::ICGSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of B" );
839 "Belos::ICGSOrthoManager::projectAndNormalize(): MVT returned negative dimensions for X,MX" );
841 TEUCHOS_TEST_FOR_EXCEPTION( xc!=mxc || xr!=mxr, std::invalid_argument,
842 "Belos::ICGSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of MX" );
848 bool dep_flg =
false;
852 tmpX = MVT::CloneCopy(X);
854 tmpMX = MVT::CloneCopy(*MX);
861 dep_flg = blkOrtho1( X, MX, C, Q );
865 #ifdef BELOS_TEUCHOS_TIME_MONITOR
868 if ( B == Teuchos::null ) {
871 std::vector<ScalarType> diag(xc);
872 MVT::MvDot( X, *MX, diag );
873 (*B)(0,0) = SCT::squareroot(SCT::magnitude(diag[0]));
875 MVT::MvScale( X, ONE/(*B)(0,0) );
878 MVT::MvScale( *MX, ONE/(*B)(0,0) );
886 dep_flg = blkOrtho( X, MX, C, Q );
892 rank = blkOrthoSing( *tmpX, tmpMX, C, B, Q );
895 MVT::Assign( *tmpX, X );
897 MVT::Assign( *tmpMX, *MX );
902 rank = findBasis( X, MX, B,
false );
907 rank = blkOrthoSing( *tmpX, tmpMX, C, B, Q );
910 MVT::Assign( *tmpX, X );
912 MVT::Assign( *tmpMX, *MX );
919 TEUCHOS_TEST_FOR_EXCEPTION( rank > xc || rank < 0, std::logic_error,
920 "Belos::ICGSOrthoManager::projectAndNormalize(): Debug error in rank variable." );
930 template<
class ScalarType,
class MV,
class OP>
935 #ifdef BELOS_TEUCHOS_TIME_MONITOR
940 return findBasis(X, MX, B,
true);
946 template<
class ScalarType,
class MV,
class OP>
966 #ifdef BELOS_TEUCHOS_TIME_MONITOR
970 int xc = MVT::GetNumberVecs( X );
971 ptrdiff_t xr = MVText::GetGlobalLength( X );
973 std::vector<int> qcs(nq);
975 if (nq == 0 || xc == 0 || xr == 0) {
978 ptrdiff_t qr = MVText::GetGlobalLength ( *Q[0] );
987 if (MX == Teuchos::null) {
989 MX = MVT::Clone(X,MVT::GetNumberVecs(X));
990 OPT::Apply(*(this->_Op),X,*MX);
997 int mxc = MVT::GetNumberVecs( *MX );
998 ptrdiff_t mxr = MVText::GetGlobalLength( *MX );
1002 "Belos::ICGSOrthoManager::project(): MVT returned negative dimensions for X,MX" );
1005 "Belos::ICGSOrthoManager::project(): Size of X not consistant with MX,Q" );
1009 for (
int i=0; i<nq; i++) {
1011 "Belos::ICGSOrthoManager::project(): Q lengths not mutually consistant" );
1012 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1014 "Belos::ICGSOrthoManager::project(): Q has less rows than columns" );
1018 if ( C[i] == Teuchos::null ) {
1023 "Belos::ICGSOrthoManager::project(): Size of Q not consistant with size of C" );
1028 blkOrtho( X, MX, C, Q );
1035 template<
class ScalarType,
class MV,
class OP>
1057 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1059 #endif // BELOS_TEUCHOS_TIME_MONITOR
1061 const ScalarType ONE = SCT::one ();
1062 const MagnitudeType ZERO = SCT::magnitude (SCT::zero ());
1064 const int xc = MVT::GetNumberVecs (X);
1065 const ptrdiff_t xr = MVText::GetGlobalLength (X);
1067 if (howMany == -1) {
1078 if (MX == Teuchos::null) {
1080 MX = MVT::Clone(X,xc);
1081 OPT::Apply(*(this->_Op),X,*MX);
1088 if ( B == Teuchos::null ) {
1092 const int mxc = (this->_hasOp) ? MVT::GetNumberVecs( *MX ) : xc;
1093 const ptrdiff_t mxr = (this->_hasOp) ? MVText::GetGlobalLength( *MX ) : xr;
1097 "Belos::ICGSOrthoManager::findBasis(): X must be non-empty" );
1099 "Belos::ICGSOrthoManager::findBasis(): Size of X not consistant with size of B" );
1101 "Belos::ICGSOrthoManager::findBasis(): Size of X not consistant with size of MX" );
1103 "Belos::ICGSOrthoManager::findBasis(): Size of X not feasible for normalization" );
1105 "Belos::ICGSOrthoManager::findBasis(): Invalid howMany parameter" );
1110 int xstart = xc - howMany;
1112 for (
int j = xstart; j < xc; j++) {
1118 bool addVec =
false;
1121 std::vector<int> index(1);
1127 MXj = MVT::CloneViewNonConst( *MX, index );
1135 std::vector<int> prev_idx( numX );
1139 for (
int i=0; i<numX; i++) {
1142 prevX = MVT::CloneView( X, prev_idx );
1144 prevMX = MVT::CloneView( *MX, prev_idx );
1150 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1155 MVT::MvDot( *Xj, *MXj, oldDot );
1158 "Belos::ICGSOrthoManager::findBasis(): Negative definiteness discovered in inner product" );
1164 for (
int i=0; i<max_ortho_steps_; ++i) {
1168 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1177 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1180 MVT::MvTimesMatAddMv( -ONE, *prevX, P2, ONE, *Xj );
1188 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1191 MVT::MvTimesMatAddMv( -ONE, *prevMX, P2, ONE, *MXj );
1204 MVT::MvDot( *Xj, *oldMXj, newDot );
1207 if (completeBasis) {
1211 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(sing_tol_*oldDot[0]) ) {
1216 std::cout <<
"Belos::ICGSOrthoManager::findBasis() --> Random for column " << numX << std::endl;
1221 MVT::MvRandom( *tempXj );
1223 tempMXj = MVT::Clone( X, 1 );
1224 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1229 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1231 for (
int num_orth=0; num_orth<max_ortho_steps_; num_orth++){
1233 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1239 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1242 MVT::MvTimesMatAddMv( -ONE, *prevX, product, ONE, *tempXj );
1245 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1248 MVT::MvTimesMatAddMv( -ONE, *prevMX, product, ONE, *tempMXj );
1252 MVT::MvDot( *tempXj, *tempMXj, newDot );
1254 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1256 MVT::Assign( *tempXj, *Xj );
1258 MVT::Assign( *tempMXj, *MXj );
1270 if ( SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*blk_tol_) ) {
1278 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1280 MVT::MvScale( *Xj, ONE/diag );
1283 MVT::MvScale( *MXj, ONE/diag );
1297 for (
int i=0; i<numX; i++) {
1298 (*B)(i,j) = product(i,0);
1309 template<
class ScalarType,
class MV,
class OP>
1311 ICGSOrthoManager<ScalarType, MV, OP>::blkOrtho1 ( MV &X,
Teuchos::RCP<MV> MX,
1316 int xc = MVT::GetNumberVecs( X );
1317 const ScalarType ONE = SCT::one();
1319 std::vector<int> qcs( nq );
1320 for (
int i=0; i<nq; i++) {
1321 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1328 for (
int i=0; i<nq; i++) {
1331 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1338 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1341 MVT::MvTimesMatAddMv( -ONE, *Q[i], *C[i], ONE, X );
1347 OPT::Apply( *(this->_Op), X, *MX);
1351 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1352 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1353 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *C[i], ONE, *MX );
1359 for (
int j = 1; j < max_ortho_steps_; ++j) {
1361 for (
int i=0; i<nq; i++) {
1366 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1373 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1376 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1383 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1385 else if (xc <= qcs[i]) {
1387 OPT::Apply( *(this->_Op), X, *MX);
1398 template<
class ScalarType,
class MV,
class OP>
1400 ICGSOrthoManager<ScalarType, MV, OP>::blkOrtho ( MV &X,
Teuchos::RCP<MV> MX,
1405 int xc = MVT::GetNumberVecs( X );
1406 bool dep_flg =
false;
1407 const ScalarType ONE = SCT::one();
1409 std::vector<int> qcs( nq );
1410 for (
int i=0; i<nq; i++) {
1411 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1417 std::vector<ScalarType> oldDot( xc );
1418 MVT::MvDot( X, *MX, oldDot );
1422 for (
int i=0; i<nq; i++) {
1425 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1432 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1435 MVT::MvTimesMatAddMv( -ONE, *Q[i], *C[i], ONE, X );
1440 OPT::Apply( *(this->_Op), X, *MX);
1444 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1445 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1446 MVT::MvTimesMatAddMv( -ONE, *MQ[i], *C[i], ONE, *MX );
1452 for (
int j = 1; j < max_ortho_steps_; ++j) {
1454 for (
int i=0; i<nq; i++) {
1459 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1466 #ifdef BELOS_TEUCHOS_TIME_MONITOR
1469 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, X );
1476 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MX );
1478 else if (xc <= qcs[i]) {
1480 OPT::Apply( *(this->_Op), X, *MX);
1487 std::vector<ScalarType> newDot(xc);
1488 MVT::MvDot( X, *MX, newDot );
1491 for (
int i=0; i<xc; i++){
1492 if (SCT::magnitude(newDot[i]) < SCT::magnitude(oldDot[i] * blk_tol_)) {
1501 template<
class ScalarType,
class MV,
class OP>
1503 ICGSOrthoManager<ScalarType, MV, OP>::blkOrthoSing ( MV &X,
Teuchos::RCP<MV> MX,
1510 const ScalarType ONE = SCT::one();
1511 const ScalarType ZERO = SCT::zero();
1514 int xc = MVT::GetNumberVecs( X );
1515 std::vector<int> indX( 1 );
1516 std::vector<ScalarType> oldDot( 1 ), newDot( 1 );
1518 std::vector<int> qcs( nq );
1519 for (
int i=0; i<nq; i++) {
1520 qcs[i] = MVT::GetNumberVecs( *Q[i] );
1529 for (
int j=0; j<xc; j++) {
1531 bool dep_flg =
false;
1535 std::vector<int> index( j );
1536 for (
int ind=0; ind<j; ind++) {
1539 lastQ = MVT::CloneView( X, index );
1542 Q.push_back( lastQ );
1544 qcs.push_back( MVT::GetNumberVecs( *lastQ ) );
1549 Xj = MVT::CloneViewNonConst( X, indX );
1551 MXj = MVT::CloneViewNonConst( *MX, indX );
1558 MVT::MvDot( *Xj, *MXj, oldDot );
1562 for (
int i=0; i<Q.size(); i++) {
1570 MVT::MvTimesMatAddMv( -ONE, *Q[i], tempC, ONE, *Xj );
1575 OPT::Apply( *(this->_Op), *Xj, *MXj);
1579 MQ[i] = MVT::Clone( *Q[i], qcs[i] );
1580 OPT::Apply( *(this->_Op), *Q[i], *MQ[i] );
1581 MVT::MvTimesMatAddMv( -ONE, *MQ[i], tempC, ONE, *MXj );
1587 for (
int num_ortho_steps=1; num_ortho_steps < max_ortho_steps_; ++num_ortho_steps) {
1589 for (
int i=0; i<Q.size(); i++) {
1596 MVT::MvTimesMatAddMv( -ONE, *Q[i], C2, ONE, *Xj );
1602 MVT::MvTimesMatAddMv( -ONE, *MQ[i], C2, ONE, *MXj );
1604 else if (xc <= qcs[i]) {
1606 OPT::Apply( *(this->_Op), *Xj, *MXj);
1614 if (SCT::magnitude(newDot[0]) < SCT::magnitude(oldDot[0]*sing_tol_)) {
1620 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1622 MVT::MvScale( *Xj, ONE/diag );
1625 MVT::MvScale( *MXj, ONE/diag );
1635 MVT::MvRandom( *tempXj );
1637 tempMXj = MVT::Clone( X, 1 );
1638 OPT::Apply( *(this->_Op), *tempXj, *tempMXj );
1643 MVT::MvDot( *tempXj, *tempMXj, oldDot );
1645 for (
int num_orth=0; num_orth<max_ortho_steps_; num_orth++) {
1647 for (
int i=0; i<Q.size(); i++) {
1652 MVT::MvTimesMatAddMv( -ONE, *Q[i], product, ONE, *tempXj );
1658 MVT::MvTimesMatAddMv( -ONE, *MQ[i], product, ONE, *tempMXj );
1660 else if (xc <= qcs[i]) {
1662 OPT::Apply( *(this->_Op), *tempXj, *tempMXj);
1670 MVT::MvDot( *tempXj, *tempMXj, newDot );
1673 if ( SCT::magnitude(newDot[0]) >= SCT::magnitude(oldDot[0]*sing_tol_) ) {
1674 ScalarType diag = SCT::squareroot(SCT::magnitude(newDot[0]));
1680 MVT::MvAddMv( ONE/diag, *tempXj, ZERO, *tempXj, *Xj );
1682 MVT::MvAddMv( ONE/diag, *tempMXj, ZERO, *tempMXj, *MXj );
1704 #endif // BELOS_ICGS_ORTHOMANAGER_HPP
void setBlkTol(const MagnitudeType blk_tol)
Set parameter for block re-orthogonalization threshhold.
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
bool is_null(const boost::shared_ptr< T > &p)
static magnitudeType eps()
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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.
MagnitudeType getBlkTol() const
Return parameter for block re-orthogonalization threshhold.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
int projectAndNormalize(MV &X, Teuchos::Array< Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > > C, Teuchos::RCP< Teuchos::SerialDenseMatrix< int, ScalarType > > B, Teuchos::ArrayView< Teuchos::RCP< const MV > > Q) const
This method calls projectAndNormalize(X,Teuchos::null,C,B,Q); see documentation for that function...
Declaration of basic traits for the multivector type.
void setLabel(const std::string &label)
This method sets the label used by the timers in the orthogonalization manager.
Teuchos::RCP< const Teuchos::ParameterList > TEUCHOS_DEPRECATED getFastIcgsParameters()
"Fast" parameters for ICGSOrthoManager.
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...
An extension of the MultiVecTraits class that adds a new vector length method.
Class which defines basic traits for the operator type.
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...
void TEUCHOS_DEPRECATED readIcgsParameters(const Teuchos::RCP< const Teuchos::ParameterList > ¶ms, int &maxNumOrthogPasses, typename Teuchos::ScalarTraits< ScalarType >::magnitudeType &blkTol, typename Teuchos::ScalarTraits< ScalarType >::magnitudeType &singTol)
Read ICGS options from the given parameter list.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
~ICGSOrthoManager()
Destructor.
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 ...
void setMyParamList(const RCP< ParameterList > ¶mList)
RCP< ParameterList > getNonconstParameterList()
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.
void setSingTol(const MagnitudeType sing_tol)
Set parameter for singular block detection.
MagnitudeType getSingTol() const
Return parameter for singular block detection.
An implementation of the Belos::MatOrthoManager that performs orthogonalization using multiple steps ...
int projectAndNormalize(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 ...
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.
TypeTo as(const TypeFrom &t)
Teuchos::RCP< const Teuchos::ParameterList > getFastParameters() const
"Fast" but possibly unsafe or less accurate parameters.
Class which defines basic traits for the operator type.
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
Belos header file which uses auto-configuration information to include necessary C++ headers...
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 ...
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 ...
ICGSOrthoManager(const std::string &label="Belos", Teuchos::RCP< const OP > Op=Teuchos::null, const int max_ortho_steps=2, const MagnitudeType blk_tol=10 *MGT::squareroot(MGT::eps()), const MagnitudeType sing_tol=10 *MGT::eps())
Constructor specifying re-orthogonalization tolerance.
Teuchos::RCP< const Teuchos::ParameterList > TEUCHOS_DEPRECATED getDefaultIcgsParameters()
Default parameters for ICGSOrthoManager.
Templated virtual class for providing orthogonalization/orthonormalization methods with matrix-based ...
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const