15#ifndef BELOS_DGKS_ORTHOMANAGER_HPP
16#define BELOS_DGKS_ORTHOMANAGER_HPP
32#include "Teuchos_as.hpp"
33#ifdef BELOS_TEUCHOS_TIME_MONITOR
34#include "Teuchos_TimeMonitor.hpp"
40 template<
class ScalarType,
class MV,
class OP>
44 template<
class ScalarType,
class MV,
class OP>
47 template<
class ScalarType,
class MV,
class OP>
52 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
53 typedef typename Teuchos::ScalarTraits<MagnitudeType> MGT;
54 typedef Teuchos::ScalarTraits<ScalarType> SCT;
64 Teuchos::RCP<const OP>
Op = Teuchos::null,
76#ifdef BELOS_TEUCHOS_TIME_MONITOR
78 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
80 std::string
orthoLabel =
ss.str() +
": Orthogonalization";
86 std::string
normLabel =
ss.str() +
": Ortho (Norm)";
89 std::string
ipLabel =
ss.str() +
": Ortho (Inner Product)";
96 const std::string&
label =
"Belos",
97 Teuchos::RCP<const OP>
Op = Teuchos::null)
107#ifdef BELOS_TEUCHOS_TIME_MONITOR
108 std::stringstream
ss;
109 ss << label_ +
": DGKS[" << max_blk_ortho_ <<
"]";
111 std::string
orthoLabel =
ss.str() +
": Orthogonalization";
117 std::string
normLabel =
ss.str() +
": Ortho (Norm)";
120 std::string
ipLabel =
ss.str() +
": Ortho (Inner Product)";
135 using Teuchos::ParameterList;
136 using Teuchos::parameterList;
141 if (
plist.is_null()) {
155 const MagnitudeType
blkTol =
params->get<MagnitudeType> (
"blkTol");
156 const MagnitudeType
depTol =
params->get<MagnitudeType> (
"depTol");
157 const MagnitudeType
singTol =
params->get<MagnitudeType> (
"singTol");
167 Teuchos::RCP<const Teuchos::ParameterList>
170 if (defaultParams_.is_null()) {
174 return defaultParams_;
185 Teuchos::RCP<Teuchos::ParameterList>
params = this->getNonconstParameterList();
199 Teuchos::RCP<Teuchos::ParameterList>
params = this->getNonconstParameterList();
209 Teuchos::RCP<Teuchos::ParameterList>
params = this->getNonconstParameterList();
259 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
260 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const;
266 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
267 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const {
298 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B)
const;
303 int normalize ( MV &
X, Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B )
const {
367 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
368 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
369 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const;
381 typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
392 typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
398 typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
407 typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
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
466 mutable Teuchos::RCP<Teuchos::ParameterList> defaultParams_;
469 int findBasis(MV &
X, Teuchos::RCP<MV>
MX,
470 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > C,
474 bool blkOrtho1 ( MV &
X, Teuchos::RCP<MV>
MX,
475 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
476 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const;
479 bool blkOrtho ( MV &
X, Teuchos::RCP<MV>
MX,
480 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
481 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const;
496 int blkOrthoSing ( MV &
X, Teuchos::RCP<MV>
MX,
497 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
498 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
499 Teuchos::ArrayView<Teuchos::RCP<const MV> >
QQ)
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
509 = 10*Teuchos::ScalarTraits<typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType>::squareroot(
510 Teuchos::ScalarTraits<
typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType>::eps() );
512 template<
class ScalarType,
class MV,
class OP>
513 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
515 = Teuchos::ScalarTraits<typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType>::one()
516 / Teuchos::ScalarTraits<typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType>::squareroot(
517 2*Teuchos::ScalarTraits<
typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType>::one() );
519 template<
class ScalarType,
class MV,
class OP>
520 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
522 = 10*Teuchos::ScalarTraits<typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType>::eps();
524 template<
class ScalarType,
class MV,
class OP>
527 template<
class ScalarType,
class MV,
class OP>
528 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
530 = Teuchos::ScalarTraits<typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType>::zero();
532 template<
class ScalarType,
class MV,
class OP>
533 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
535 = Teuchos::ScalarTraits<typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType>::zero();
537 template<
class ScalarType,
class MV,
class OP>
538 const typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType
540 = Teuchos::ScalarTraits<typename DGKSOrthoManager<ScalarType,MV,OP>::MagnitudeType>::zero();
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";
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>
571 typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
574 int rank = MVT::GetNumberVecs(
X);
575 Teuchos::SerialDenseMatrix<int,ScalarType>
xTx(
rank,
rank);
577#ifdef BELOS_TEUCHOS_TIME_MONITOR
585 return xTx.normFrobenius();
590 template<
class ScalarType,
class MV,
class OP>
591 typename Teuchos::ScalarTraits<ScalarType>::magnitudeType
593 int r1 = MVT::GetNumberVecs(
X1);
594 int r2 = MVT::GetNumberVecs(
X2);
595 Teuchos::SerialDenseMatrix<int,ScalarType>
xTx(
r2,
r1);
597#ifdef BELOS_TEUCHOS_TIME_MONITOR
602 return xTx.normFrobenius();
607 template<
class ScalarType,
class MV,
class OP>
612 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
613 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
614 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const
616 using Teuchos::Array;
618 using Teuchos::is_null;
621 using Teuchos::SerialDenseMatrix;
625#ifdef BELOS_TEUCHOS_TIME_MONITOR
630 const MagnitudeType
ZERO = SCT::magnitude(SCT::zero());
633 int xc = MVT::GetNumberVecs(
X );
651 for (size_type
k = 0;
k <
nq; ++
k)
653 const int numRows = MVT::GetNumberVecs (*
Q[
k]);
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);
679 MX = Teuchos::rcp( &
X,
false );
682 int mxc = MVT::GetNumberVecs( *
MX );
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" );
701 "Belos::DGKSOrthoManager::projectAndNormalize(): Size of X must be consistant with size of MX" );
716 if ( B == Teuchos::null ) {
717 B = Teuchos::rcp(
new Teuchos::SerialDenseMatrix<int,ScalarType>(
xc,
xc) );
719 std::vector<ScalarType>
diag(1);
721#ifdef BELOS_TEUCHOS_TIME_MONITOR
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);
755 MVT::Assign( *
tmpX,
X );
762 rank = findBasis(
X,
MX, B,
false );
769 MVT::Assign( *
tmpX,
X );
779 "Belos::DGKSOrthoManager::projectAndNormalize(): Debug error in rank variable." );
789 template<
class ScalarType,
class MV,
class OP>
791 MV &
X, Teuchos::RCP<MV>
MX,
792 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B )
const {
794#ifdef BELOS_TEUCHOS_TIME_MONITOR
799 return findBasis(
X,
MX, B,
true);
806 template<
class ScalarType,
class MV,
class OP>
808 MV &
X, Teuchos::RCP<MV>
MX,
809 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
810 Teuchos::ArrayView<Teuchos::RCP<const MV> >
Q)
const {
826#ifdef BELOS_TEUCHOS_TIME_MONITOR
830 int xc = MVT::GetNumberVecs(
X );
833 std::vector<int>
qcs(
nq);
835 if (
nq == 0 ||
xc == 0 ||
xr == 0) {
847 if (
MX == Teuchos::null) {
849 MX = MVT::Clone(
X,MVT::GetNumberVecs(
X));
850 OPT::Apply(*(this->_Op),
X,*
MX);
855 MX = Teuchos::rcp( &
X,
false );
857 int mxc = MVT::GetNumberVecs( *
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 ) {
877 C[
i] = Teuchos::rcp(
new Teuchos::SerialDenseMatrix<int,ScalarType>(
qcs[
i],
xc) );
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>
895 MV &
X, Teuchos::RCP<MV>
MX,
896 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
915 const MagnitudeType
ZERO = SCT::magnitude(SCT::zero());
917 int xc = MVT::GetNumberVecs(
X );
931 if (
MX == Teuchos::null) {
933 MX = MVT::Clone(
X,
xc);
934 OPT::Apply(*(this->_Op),
X,*
MX);
941 if ( B == Teuchos::null ) {
942 B = Teuchos::rcp(
new Teuchos::SerialDenseMatrix<int,ScalarType>(
xc,
xc) );
945 int mxc = (this->_hasOp) ? MVT::GetNumberVecs( *
MX ) :
xc;
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" );
974 std::vector<int> index(1);
976 Teuchos::RCP<MV>
Xj = MVT::CloneViewNonConst(
X, index );
977 Teuchos::RCP<MV>
MXj;
978 if ((this->_hasOp)) {
980 MXj = MVT::CloneViewNonConst( *
MX, index );
1005 Teuchos::SerialDenseMatrix<int,ScalarType>
product(
numX, 1);
1011#ifdef BELOS_TEUCHOS_TIME_MONITOR
1018 "Belos::DGKSOrthoManager::findBasis(): Negative definiteness discovered in inner product" );
1025#ifdef BELOS_TEUCHOS_TIME_MONITOR
1033#ifdef BELOS_TEUCHOS_TIME_MONITOR
1044#ifdef BELOS_TEUCHOS_TIME_MONITOR
1052#ifdef BELOS_TEUCHOS_TIME_MONITOR
1059 if ( MGT::squareroot(SCT::magnitude(
newDot[0])) < dep_tol_*MGT::squareroot(SCT::magnitude(
oldDot[0])) ) {
1062 Teuchos::SerialDenseMatrix<int,ScalarType>
P2(
numX,1);
1064#ifdef BELOS_TEUCHOS_TIME_MONITOR
1072#ifdef BELOS_TEUCHOS_TIME_MONITOR
1077 if ((this->_hasOp)) {
1078#ifdef BELOS_TEUCHOS_TIME_MONITOR
1089#ifdef BELOS_TEUCHOS_TIME_MONITOR
1103 if ( SCT::magnitude(
newDot[0]) < SCT::magnitude(sing_tol_*
oldDot[0]) ) {
1108 std::cout <<
"Belos::DGKSOrthoManager::findBasis() --> Random for column " <<
numX << std::endl;
1111 Teuchos::RCP<MV>
tempXj = MVT::Clone(
X, 1 );
1113 MVT::MvRandom( *
tempXj );
1122#ifdef BELOS_TEUCHOS_TIME_MONITOR
1130#ifdef BELOS_TEUCHOS_TIME_MONITOR
1136#ifdef BELOS_TEUCHOS_TIME_MONITOR
1142#ifdef BELOS_TEUCHOS_TIME_MONITOR
1150#ifdef BELOS_TEUCHOS_TIME_MONITOR
1156 if ( SCT::magnitude(
newDot[0]) >= SCT::magnitude(
oldDot[0]*sing_tol_) ) {
1172 if ( SCT::magnitude(
newDot[0]) < SCT::magnitude(
oldDot[0]*blk_tol_) ) {
1212 template<
class ScalarType,
class MV,
class OP>
1214 DGKSOrthoManager<ScalarType, MV, OP>::blkOrtho1 ( MV &X, Teuchos::RCP<MV> MX,
1215 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
1216 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const
1219 int xc = MVT::GetNumberVecs(
X );
1222 std::vector<int>
qcs(
nq );
1223 for (
int i=0;
i<
nq;
i++) {
1224 qcs[
i] = MVT::GetNumberVecs( *
Q[
i] );
1230#ifdef BELOS_TEUCHOS_TIME_MONITOR
1236 Teuchos::Array<Teuchos::RCP<MV> >
MQ(
nq);
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);
1262 OPT::Apply( *(this->_Op), *
Q[
i], *
MQ[
i] );
1264#ifdef BELOS_TEUCHOS_TIME_MONITOR
1274#ifdef BELOS_TEUCHOS_TIME_MONITOR
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
1316#ifdef BELOS_TEUCHOS_TIME_MONITOR
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,
1338 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
1339 Teuchos::ArrayView<Teuchos::RCP<const MV> > Q)
const
1342 int xc = MVT::GetNumberVecs(
X );
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
1362 Teuchos::Array<Teuchos::RCP<MV> >
MQ(
nq);
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);
1388 OPT::Apply( *(this->_Op), *
Q[
i], *
MQ[
i] );
1390#ifdef BELOS_TEUCHOS_TIME_MONITOR
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
1424#ifdef BELOS_TEUCHOS_TIME_MONITOR
1432 OPT::Apply( *(this->_Op),
X, *
MX);
1439 std::vector<ScalarType>
newDot(
xc);
1441#ifdef BELOS_TEUCHOS_TIME_MONITOR
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,
1462 Teuchos::Array<Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > > C,
1463 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > B,
1464 Teuchos::ArrayView<Teuchos::RCP<const MV> > QQ)
const
1466 Teuchos::Array<Teuchos::RCP<const MV> >
Q (
QQ);
1472 int xc = MVT::GetNumberVecs(
X );
1473 std::vector<int>
indX( 1 );
1476 std::vector<int>
qcs(
nq );
1477 for (
int i=0;
i<
nq;
i++) {
1478 qcs[
i] = MVT::GetNumberVecs( *
Q[
i] );
1482 Teuchos::RCP<const MV>
lastQ;
1483 Teuchos::RCP<MV>
Xj,
MXj;
1484 Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> >
lastC;
1487 for (
int j=0;
j<
xc;
j++) {
1493 std::vector<int> index(
j );
1497 lastQ = MVT::CloneView(
X, index );
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
1523 Teuchos::Array<Teuchos::RCP<MV> >
MQ(
Q.size());
1525 for (
int i=0;
i<
Q.size();
i++) {
1528 Teuchos::SerialDenseMatrix<int,ScalarType>
tempC( Teuchos::View, *C[
i],
qcs[
i], 1, 0,
j );
1532#ifdef BELOS_TEUCHOS_TIME_MONITOR
1539#ifdef BELOS_TEUCHOS_TIME_MONITOR
1548 OPT::Apply( *(this->_Op), *
Xj, *
MXj);
1553 OPT::Apply( *(this->_Op), *
Q[
i], *
MQ[
i] );
1555#ifdef BELOS_TEUCHOS_TIME_MONITOR
1566#ifdef BELOS_TEUCHOS_TIME_MONITOR
1575 if ( SCT::magnitude(
newDot[0]) < SCT::magnitude(
oldDot[0]*dep_tol_) ) {
1577 for (
int i=0;
i<
Q.size();
i++) {
1578 Teuchos::SerialDenseMatrix<int,ScalarType>
tempC( Teuchos::View, *C[
i],
qcs[
i], 1, 0,
j );
1579 Teuchos::SerialDenseMatrix<int,ScalarType>
C2(
qcs[
i], 1 );
1583#ifdef BELOS_TEUCHOS_TIME_MONITOR
1590#ifdef BELOS_TEUCHOS_TIME_MONITOR
1599#ifdef BELOS_TEUCHOS_TIME_MONITOR
1607 OPT::Apply( *(this->_Op), *
Xj, *
MXj);
1614#ifdef BELOS_TEUCHOS_TIME_MONITOR
1622 if (SCT::magnitude(
newDot[0]) < SCT::magnitude(
oldDot[0]*sing_tol_)) {
1641 Teuchos::RCP<MV>
tempXj = MVT::Clone(
X, 1 );
1643 MVT::MvRandom( *
tempXj );
1652#ifdef BELOS_TEUCHOS_TIME_MONITOR
1660 for (
int i=0;
i<
Q.size();
i++) {
1661 Teuchos::SerialDenseMatrix<int,ScalarType>
product(
qcs[
i], 1 );
1665#ifdef BELOS_TEUCHOS_TIME_MONITOR
1671#ifdef BELOS_TEUCHOS_TIME_MONITOR
1680#ifdef BELOS_TEUCHOS_TIME_MONITOR
1697#ifdef BELOS_TEUCHOS_TIME_MONITOR
1704 if ( SCT::magnitude(
newDot[0]) >= SCT::magnitude(
oldDot[0]*sing_tol_) ) {
1733 template<
class ScalarType,
class MV,
class OP>
1736 using Teuchos::ParameterList;
1737 using Teuchos::parameterList;
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>
1761 using Teuchos::ParameterList;
1766 params->set (
"maxNumOrthogPasses",
Belos header file which uses auto-configuration information to include necessary C++ headers.
Templated virtual class for providing orthogonalization/orthonormalization methods with matrix-based ...
Declaration of basic traits for the multivector type.
Class which defines basic traits for the operator type.
An implementation of the Belos::MatOrthoManager that performs orthogonalization using (potentially) m...
static const MagnitudeType sing_tol_default_
Singular block detection threshold (default).
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.
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 ...
static const int max_blk_ortho_default_
Max number of (re)orthogonalization steps, including the first (default).
~DGKSOrthoManager()
Destructor.
MagnitudeType getSingTol() const
Return parameter for singular block detection.
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 dep_tol_default_
(Non-block) reorthogonalization threshold (default).
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.
static const MagnitudeType blk_tol_default_
Block reorthogonalization threshold (default).
static const int max_blk_ortho_fast_
Max number of (re)orthogonalization steps, including the first (fast).
static const MagnitudeType blk_tol_fast_
Block reorthogonalization threshold (fast).
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
const std::string & getLabel() const
This method returns the label being used by the timers in the orthogonalization manager.
Teuchos::ScalarTraits< ScalarType >::magnitudeType orthonormError(const MV &X) const
This method computes the error in orthonormality of a multivector.
void setDepTol(const MagnitudeType dep_tol)
Set parameter for re-orthogonalization threshhold.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void setBlkTol(const MagnitudeType blk_tol)
Set parameter for block 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 .
MagnitudeType getDepTol() const
Return parameter for re-orthogonalization threshhold.
static const MagnitudeType sing_tol_fast_
Singular block detection threshold (fast).
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...
void setLabel(const std::string &label)
This method sets the label used by the timers in the orthogonalization manager.
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.
static const MagnitudeType dep_tol_fast_
(Non-block) reorthogonalization threshold (fast).
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 ,...
void setSingTol(const MagnitudeType sing_tol)
Set parameter for singular block detection.
MagnitudeType getBlkTol() const
Return parameter for block re-orthogonalization threshhold.
Belos's templated virtual class for providing routines for orthogonalization and orthonormzalition of...
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.
Alternative run-time polymorphic interface for operators.
Operator()
Default constructor (does nothing).
Teuchos::RCP< Teuchos::ParameterList > getDGKSDefaultParameters()
"Default" parameters for robustness and accuracy.
Teuchos::RCP< Teuchos::ParameterList > getDGKSFastParameters()
"Fast" but possibly unsafe or less accurate parameters.