1 #include "RBGen_StSVD_RTR.h"
2 #include "AnasaziSVQBOrthoManager.hpp"
3 #include "AnasaziBasicOrthoManager.hpp"
6 #include "Epetra_SerialDenseMatrix.h"
7 #include "Epetra_LAPACK.h"
8 #include "Epetra_LocalMap.h"
9 #include "Epetra_Comm.h"
10 #include "Epetra_Vector.h"
15 isInitialized_(false),
18 timerComp_(
"Total Elapsed Time"),
42 stopReasons_.push_back(
"n/a");
43 stopReasons_.push_back(
"maximum iterations");
44 stopReasons_.push_back(
"negative curvature");
45 stopReasons_.push_back(
"exceeded TR");
46 stopReasons_.push_back(
"kappa convergence");
47 stopReasons_.push_back(
"theta convergence");
48 stopReasons_.push_back(
"");
53 if (isInitialized_ ==
false) {
61 if (isInitialized_ ==
false) {
82 rank_ = rbmethod_params.
get(
"Basis Size",(
int)5);
85 tol_ = rbmethod_params.
get<
double>(
"Convergence Tolerance",tol_);
88 debug_ = rbmethod_params.
get<
bool>(
"StSVD Debug",debug_);
91 verbLevel_ = rbmethod_params.
get<
int>(
"StSVD Verbosity Level",verbLevel_);
94 maxOuterIters_ = rbmethod_params.
get<
int>(
"StSVD Max Outer Iters",maxOuterIters_);
97 maxInnerIters_ = rbmethod_params.
get<
int>(
"StSVD Max Inner Iters",maxInnerIters_);
100 Delta0_ = rbmethod_params.
get<
double>(
"StSVD Delta0",sqrt(3.0)*rank_);
103 localV_ = rbmethod_params.
get<
bool>(
"StSVD Local V",localV_);
105 rhoPrime_ = rbmethod_params.
get<
double>(
"StSVD Rho Prime",rhoPrime_);
107 std::invalid_argument,
108 "RBGen::StSVDRTR:: Rho Prime must be in (0,1/4)");
110 initElem_ = rbmethod_params.
get<
bool>(
"StSVD Init Elementary",initElem_);
113 if (rbmethod_params.
isType<
114 Teuchos::RCP< Anasazi::OrthoManager<double,Epetra_MultiVector> >
118 ortho_ = rbmethod_params.
get<
121 TEUCHOS_TEST_FOR_EXCEPTION(ortho_ == Teuchos::null,std::invalid_argument,
"RBGen::StSVDRTR::User specified null ortho manager.");
133 ortho_ =
rcp(
new Anasazi::BasicOrthoManager<double,Epetra_MultiVector,Epetra_Operator>() );
137 TEUCHOS_TEST_FOR_EXCEPTION(ss == Teuchos::null,std::invalid_argument,
"Input snapshot matrix cannot be null.");
140 m_ = A_->GlobalLength();
141 n_ = A_->NumVectors();
148 void StSVDRTR::initialize()
150 if (isInitialized_)
return;
155 sigma_.resize( rank_ );
164 Epetra_Map vmap(A_->NumVectors(),0,A_->Comm());
167 resNorms_.resize(rank_);
168 resUNorms_.resize(rank_);
169 resVNorms_.resize(rank_);
176 for (
int j=0; j<rank_; j++)
181 lid = U_->Map().LID(j);
186 lid = V_->Map().LID(j);
200 for (
int j=0; j<rank_; j++) {
228 dgesvd_work_.resize(5*rank_);
232 int ret = ortho_->normalize(*U_);
234 ret = ortho_->normalize(*V_);
247 info = AU_->Multiply(
'T',
'N',1.0,*A_,*U_,0.0);
249 "RBGen::StSVD::initialize(): Error calling Epetra_MultiVector::Muliply.");
252 info = dgesvd_A_->Multiply(
'T',
'N',1.0,*AU_,*V_,0.0);
254 "RBGen::StSVD::initialize(): Error calling Epetra_MultiVector::Muliply.");
258 std::logic_error,
"RBGen::StSVD/RTR::initialize(): VV should have constant stride.");
262 lapack.
GESVD(
'O',
'A',rank_,rank_,dgesvd_A_->Values(),dgesvd_A_->Stride(),&sigma_[0],
263 NULL,rank_,VV.Values(),VV.Stride(),&dgesvd_work_[0],dgesvd_work_.size(),NULL,&info);
265 "RBGen::StSVD::initialize(): Error calling GESVD.");
267 info = U_->Multiply(
'N',
'N',-1.0,UCopy,*dgesvd_A_,0.0);
269 "RBGen::StSVD::initialize(): Error calling Epetra_MultiVector::Muliply.");
271 info = V_->Multiply(
'N',
'T',1.0,VCopy,VV,0.0);
273 "RBGen::StSVD::initialize(): Error calling Epetra_MultiVector::Muliply.");
279 info = AU_->Multiply(
'T',
'N',1.0,*A_,*U_,0.0);
281 "RBGen::StSVD::initialize(): Error calling Epetra_MultiVector::Muliply.");
282 info = AV_->Multiply(
'N',
'N',1.0,*A_,*V_,0.0);
284 "RBGen::StSVD::initialize(): Error calling Epetra_MultiVector::Muliply.");
295 isInitialized_ =
true;
299 chk.checkSigma =
true;
302 chk.checkSyms =
true;
304 Debug(chk,
", after updateF().");
318 isInitialized_ =
false;
329 using std::setprecision;
331 using std::scientific;
341 "computeBasis() requires non-null snapshot set.");
352 innerStop_ = NOTHING;
354 tiny_rhonum_ =
false;
355 zero_rhoden_ =
false;
361 while ( (maxScaledNorm_ > tol_) && (iter_ < maxOuterIters_) ) {
376 chk.checkElen =
true;
377 chk.checkRlen =
true;
379 Debug(chk,
", after call to solveTRSubproblem.");
396 retract(*U_,*V_,*newU,*newV);
398 catch (std::runtime_error oops) {
400 "RBGen::StSVD::computeBasis(): Retraction of eta failed.");
421 info = newAU->Multiply(
'T',
'N',1.0,*A_,*newU,0.0);
423 "RBGen::StSVD::computeBasis(): Error calling Epetra_MultiVector::Muliply.");
429 tiny_rhonum_ = neg_rho_ = zero_rhoden_ =
false;
432 std::vector<double> dots(rank_);
433 newV->Dot(*newAU,&dots[0]);
435 for (
int i=0; i<rank_; i++) {
436 fxnew += dots[i]*N_[i];
440 std::cout <<
" >> newfx: " << setw(18) << scientific << setprecision(10) << fxnew << std::endl;
442 rhonum_ = fx_ - fxnew;
453 std::vector<double> ips(rank_);
455 etaU_->Dot(*AV_,&ips[0]);
456 for (
int i=0; i<rank_; i++) rhoden_ += -1.0*ips[i]*N_[i];
457 etaV_->Dot(*AU_,&ips[0]);
458 for (
int i=0; i<rank_; i++) rhoden_ += -1.0*ips[i]*N_[i];
459 rhoden_ = rhoden_ - 0.5*innerProduct(*etaU_,*etaV_,*HeU_,*HeV_);
461 std::cout <<
" >> rhonum: " << rhonum_ << std::endl;
462 std::cout <<
" >> rhoden: " << rhoden_ << std::endl;
470 rho_ = rhonum_ / rhoden_;
480 if (rho_ >= rhoPrime_) {
494 info = AV_->Multiply(
'N',
'N',1.0,*A_,*V_,0.0);
496 "RBGen::StSVD::computeBasis(): Error calling Epetra_MultiVector::Muliply.");
504 std::cout <<
" >> new f(x): " << setw(18) << scientific << setprecision(10) << fx_ << std::endl;
508 newU = Teuchos::null;
509 newV = Teuchos::null;
510 newAU = Teuchos::null;
519 if (this->rho_ < .25) {
520 Delta_ = .25 * Delta_;
523 else if (this->rho_ > .75 && (innerStop_ == NEGATIVE_CURVATURE || innerStop_ == EXCEEDED_TR)) {
540 chk.checkSigma =
true;
543 chk.checkSyms =
true;
545 Debug(chk,
", in computeBasis().");
551 if (verbLevel_ > 1) {
552 std::cout <<
"----------------------------------------------------------------" << std::endl;
560 void StSVDRTR::updateF()
566 info = dgesvd_A_->Multiply(
'T',
'N',1.0,*AU_,*V_,0.0);
568 "RBGen::StSVD::initialize(): Error calling Epetra_MultiVector::Muliply.");
575 for (
int j=0; j<rank_; j++)
577 for (
int i=0; i<rank_; i++)
579 (*UAVNsym_)[j][i] = (*dgesvd_A_)[j][i];
580 (*VAUNsym_)[j][i] = (*dgesvd_A_)[i][j];
582 (*UAVNsym_)(j)->Scale(N_[j]);
583 (*VAUNsym_)(j)->Scale(N_[j]);
592 for (
int j=0; j<rank_; j++)
594 fx_ += (*dgesvd_A_)[j][j] * N_[j];
601 lapack.
GESVD(
'N',
'N',rank_,rank_,dgesvd_A_->Values(),dgesvd_A_->Stride(),&sigma_[0],
602 NULL,rank_,NULL,rank_,&dgesvd_work_[0],dgesvd_work_.size(),NULL,&info);
604 "RBGen::StSVD::initialize(): Error calling Epetra_MultiVector::Muliply.");
613 void StSVDRTR::updateResiduals()
616 using std::setprecision;
617 using std::scientific;
644 for (
int i=0; i<rank_; i++) {
645 (*RU_)(i)->Update( 1.0, *(*AV_)(i), sigma_[i], *(*U_)(i), 0.0 );
646 (*RV_)(i)->Update( 1.0, *(*AU_)(i), sigma_[i], *(*V_)(i), 0.0 );
650 RU_->Norm2(&resUNorms_[0]);
651 RV_->Norm2(&resVNorms_[0]);
654 for (
int i=0; i<rank_; i++) {
659 if (sigma_[i] > 0.0) {
660 resUNorms_[i] /= sigma_[i];
661 resVNorms_[i] /= sigma_[i];
665 std::cout <<
" >> Residual norms " << std::endl
666 <<
" >> U V" << std::endl;
668 for (
int i=0; i<rank_; i++) {
669 std::cout <<
" >> " << setw(15) << scientific << setprecision(6) << resUNorms_[i]
670 <<
" " << setw(15) << scientific << setprecision(6) << resVNorms_[i]
675 for (
int i=0; i<rank_; i++) {
676 resNorms_[i] =
SCT::squareroot(resUNorms_[i]*resUNorms_[i] + resVNorms_[i]*resVNorms_[i]);
677 maxScaledNorm_ = EPETRA_MAX(resNorms_[i],maxScaledNorm_);
689 "RBGen::StSVDRTR::updateBasis(): this routine not yet supported.");
697 if (isInitialized_) {
701 return std::vector<double>(rank_,-1);
708 void StSVDRTR::solveTRSubproblem()
720 using std::setprecision;
721 innerStop_ = MAXIMUM_ITERATIONS;
723 int dim = (n_-rank_)*rank_ + (m_-rank_)*rank_ + (rank_-1)*rank_;
724 if (maxInnerIters_ != -1 && maxInnerIters_ < dim) {
725 dim = maxInnerIters_;
727 const double D2 = Delta_*Delta_;
730 double d_Hd, alpha, beta, r_r, rold_rold;
732 double e_e, e_d, d_d, e_e_new;
737 etaU_->PutScalar(0.0);
738 etaV_->PutScalar(0.0);
739 HeU_->PutScalar(0.0);
740 HeV_->PutScalar(0.0);
760 for (
int j=0; j<rank_; j++)
762 (*RU_)(j)->Scale(N_[j]);
763 (*RV_)(j)->Scale(N_[j]);
765 Proj(*U_,*V_,*RU_,*RV_);
767 r_r = innerProduct(*RU_,*RV_);
772 normGrad0_ = r0_norm;
776 deltaU_->Update(-1.0,*RU_,0.0);
777 deltaV_->Update(-1.0,*RV_,0.0);
784 chk.checkElen =
true;
785 chk.checkRlen =
true;
788 Debug(chk,
", before loop in solveTRSubproblem.");
793 for (
int i=0; i<dim; ++i) {
798 Hess(*U_,*V_,*deltaU_,*deltaV_,*HdU_,*HdV_);
799 d_Hd = innerProduct(*deltaU_,*deltaV_,*HdU_,*HdV_);
805 double Hd_d = innerProduct(*HdU_,*HdV_,*deltaU_,*deltaV_);
807 <<
" >> Inner iteration " << i << std::endl
808 <<
" >> (r,r) : " << r_r << std::endl
809 <<
" >> (d,Hd) : " << d_Hd << std::endl
810 <<
" >> (Hd,d) : " << Hd_d << std::endl
811 <<
" >> alpha : " << alpha << std::endl;
815 e_e_new = e_e + 2.0*alpha*e_d + alpha*alpha*d_d;
818 if (d_Hd <= 0 || e_e_new >= D2) {
821 std::cout <<
" >> tau : " << tau << std::endl;
824 etaU_->Update(tau,*deltaU_,1.0);
825 etaV_->Update(tau,*deltaV_,1.0);
826 HeU_->Update(tau,*HdU_,1.0);
827 HeV_->Update(tau,*HdV_,1.0);
830 RU_->Update(tau,*HdU_,1.0);
831 RV_->Update(tau,*HdV_,1.0);
832 Proj(*U_,*V_,*RU_,*RV_);
835 innerStop_ = NEGATIVE_CURVATURE;
838 innerStop_ = EXCEEDED_TR;
845 etaU_->Update(alpha,*deltaU_,1.0);
846 etaV_->Update(alpha,*deltaV_,1.0);
847 HeU_->Update(alpha,*HdU_,1.0);
848 HeV_->Update(alpha,*HdV_,1.0);
854 RU_->Update(alpha,*HdU_,1.0);
855 RV_->Update(alpha,*HdV_,1.0);
856 Proj(*U_,*V_,*RU_,*RV_);
859 r_r = innerProduct(*RU_,*RV_);
868 double kconv = r0_norm * conv_kappa_;
872 double tconv = r0_norm *
SCT::pow(r0_norm,conv_theta_);
873 double conv = kconv < tconv ? kconv : tconv;
874 if ( r_norm <= conv ) {
876 innerStop_ = THETA_CONVERGENCE;
879 innerStop_ = KAPPA_CONVERGENCE;
885 beta = r_r/rold_rold;
886 deltaU_->Update(-1.0,*RU_,beta);
887 deltaV_->Update(-1.0,*RV_,beta);
889 e_d = beta*(e_d + alpha*d_d);
890 d_d = r_r + beta*beta*d_d;
893 std::cout <<
" >> computed e_e: " << setw(15) << setprecision(6) << innerProduct(*etaU_,*etaV_)
894 <<
" e_d: " << setw(15) << setprecision(6) << innerProduct(*etaU_,*etaV_,*deltaU_,*deltaV_)
895 <<
" d_d: " << setw(15) << setprecision(6) << innerProduct(*deltaU_,*deltaV_) << std::endl;
896 std::cout <<
" >> cached e_e: " << setw(15) << setprecision(6) << e_e
897 <<
" e_d: " << setw(15) << setprecision(6) << e_d
898 <<
" d_d: " << setw(15) << setprecision(6) << d_d << std::endl;
904 chk.checkElen =
true;
905 chk.checkRlen =
true;
908 Debug(chk,
", end of loop in solveTRSubproblem.");
924 for (
int j=0; j < rank_; j++) {
925 for (
int i=0; i < j; i++) {
931 for (
int j=0; j < rank_-1; j++) {
932 for (
int i=j+1; i < rank_; i++) {
956 info = S.Multiply(
'T',
'N',1.0,xU,etaU,0.0);
958 "RBGen::StSVD::Proj(): Error calling Epetra_MultiVector::Muliply.");
962 info = etaU.Multiply(
'N',
'N',-1.0,xU,S,1.0);
964 "RBGen::StSVD::Proj(): Error calling Epetra_MultiVector::Muliply.");
966 info = S.Multiply(
'T',
'N',1.0,xV,etaV,0.0);
968 "RBGen::StSVD::Proj(): Error calling Epetra_MultiVector::Muliply.");
972 info = etaV.Multiply(
'N',
'N',-1.0,xV,S,1.0);
974 "RBGen::StSVD::Proj(): Error calling Epetra_MultiVector::Muliply.");
979 double StSVDRTR::innerProduct(
984 std::vector<double> norms(rank_);
986 etaU.Norm2(&norms[0]);
987 for (
int i=0; i<rank_; i++) ip += norms[i]*norms[i];
988 etaV.Norm2(&norms[0]);
989 for (
int i=0; i<rank_; i++) ip += norms[i]*norms[i];
995 double StSVDRTR::innerProduct(
1002 std::vector<double> ips(rank_);
1004 etaU.Dot(zetaU,&ips[0]);
1005 for (
int i=0; i<rank_; i++) ip += ips[i];
1006 etaV.Dot(zetaV,&ips[0]);
1007 for (
int i=0; i<rank_; i++) ip += ips[i];
1014 void StSVDRTR::retract(
1027 etaU.Update(1.0,xU,1.0);
1028 ret = ortho_->normalize(etaU,UR);
1030 "RBGen::StSVD::retract(): Ortho failure in retraction.");
1032 etaV.Update(1.0,xV,1.0);
1033 ret = ortho_->normalize(etaV,VR);
1035 "RBGen::StSVD::retract(): Ortho failure in retraction.");
1045 for (
int j=0; j<rank_; j++)
1047 for (
int i=j+1; i<rank_; i++)
1052 std::cout <<
" >> norm(tril(UR)): " << tril << std::endl;
1055 for (
int j=0; j<rank_; j++) {
1056 if ( (*UR)(j,j) < 0.0 )
1062 std::cout <<
" >> positive(UR): " << (positive ?
"yes" :
"no ") << std::endl;
1066 for (
int j=0; j<rank_; j++)
1068 for (
int i=j+1; i<rank_; i++)
1073 std::cout <<
" >> norm(tril(VR)): " << tril << std::endl;
1076 for (
int j=0; j<rank_; j++) {
1077 if ( (*VR)(j,j) < 0.0 )
1083 std::cout <<
" >> positive(VR): " << (positive ?
"yes" :
"no ") << std::endl;
1098 void StSVDRTR::Hess(
1108 int info = HetaU.Multiply(
'N',
'N',1.0,*A_,etaV,0.0);
1110 "RBGen::StSVD::Hess(): Error calling Epetra_MultiVector::Muliply.");
1113 for (
int i=0; i<rank_; i++) {
1114 HetaU(i)->Scale(N_[i]);
1118 int info = HetaU.Multiply(
'N',
'N',-1.0,etaU,*UAVNsym_,1.0);
1120 "RBGen::StSVD::Hess(): Error calling Epetra_MultiVector::Muliply.");
1124 int info = HetaV.Multiply(
'T',
'N',1.0,*A_,etaU,0.0);
1126 "RBGen::StSVD::Hess(): Error calling Epetra_MultiVector::Muliply.");
1129 for (
int i=0; i<rank_; i++) {
1130 HetaV(i)->Scale(N_[i]);
1134 int info = HetaV.Multiply(
'N',
'N',-1.0,etaV,*VAUNsym_,1.0);
1136 "RBGen::StSVD::Hess(): Error calling Epetra_MultiVector::Muliply.");
1139 Proj(xU,xV,HetaU,HetaV);
1180 void StSVDRTR::Debug(
const CheckList &chk, std::string where)
const
1183 using std::setprecision;
1184 std::stringstream os;
1186 os.setf(std::ios::scientific, std::ios::floatfield);
1193 os <<
" >> Debugging checks: iteration " << iter_ << where << std::endl;
1195 info = AV.Multiply(
'N',
'N',1.0,*A_,*V_,0.0);
1196 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, std::logic_error,
"RBGen::StSVDRTR::Debug(): error calling Epetra_MultiVector::Multiply for AU.");
1197 info = AU.Multiply(
'T',
'N',1.0,*A_,*U_,0.0);
1198 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, std::logic_error,
"RBGen::StSVDRTR::Debug(): error calling Epetra_MultiVector::Multiply for AU.");
1201 tmp = ortho_->orthonormError(*U_);
1202 os <<
" >> Error in U^H M U == I : " << tmp << std::endl;
1203 tmp = ortho_->orthonormError(*V_);
1204 os <<
" >> Error in V^H M V == I : " << tmp << std::endl;
1206 tmp = Utils::errorEquality(*AV_,AV);
1207 os <<
" >> Error in A V == AV : " << tmp << std::endl;
1208 tmp = Utils::errorEquality(*AU_,AU);
1209 os <<
" >> Error in A' U == AU : " << tmp << std::endl;
1212 if (chk.checkSigma) {
1214 std::vector<double> work(5*rank_), sigma(rank_);
1215 info = S.Multiply(
'T',
'N',1.0,*U_,AV,0.0);
1216 TEUCHOS_TEST_FOR_EXCEPTION(info != 0, std::logic_error,
"RBGen::StSVDRTR::Debug(): error calling Epetra_MultiVector::Multiply for U'*A*V.");
1217 lapack.
GESVD(
'N',
'N',rank_,rank_,S.Values(),S.Stride(),&sigma[0],
1218 NULL,rank_,NULL,rank_,&work[0],work.size(),NULL,&info);
1220 os <<
" >> Stored Sigma Computed Sigma" << std::endl;
1221 for (
int i=0; i<rank_; i++) {
1222 os <<
" >> " << setw(15) << setprecision(6) << sigma_[i] <<
" "
1223 << setw(15) << setprecision(6) << sigma[i] << std::endl;
1227 if (chk.checkSyms) {
1238 if (chk.checkElen) {
1242 if (chk.checkRlen) {
1257 Proj(*U_,*V_,PiU,PiV);
1258 tmp = Utils::errorEquality(*etaU_,PiU);
1259 os <<
" >> Error in Pi E_U == E_U : " << tmp << std::endl;
1260 tmp = Utils::errorEquality(*etaV_,PiV);
1261 os <<
" >> Error in Pi E_V == E_V : " << tmp << std::endl;
1268 Proj(*U_,*V_,PiU,PiV);
1269 tmp = Utils::errorEquality(*HeU_,PiU);
1270 os <<
" >> Error in Pi H E_U == H E_U : " << tmp << std::endl;
1271 tmp = Utils::errorEquality(*HeV_,PiV);
1272 os <<
" >> Error in Pi H E_V == H E_V : " << tmp << std::endl;
1274 Hess(*U_,*V_,*etaU_,*etaV_,HU,HV);
1275 tmp = Utils::errorEquality(*HeU_,HU);
1276 os <<
" >> Error in H D_U == HD_U : " << tmp << std::endl;
1277 tmp = Utils::errorEquality(*HeV_,HV);
1278 os <<
" >> Error in H D_V == HD_V : " << tmp << std::endl;
1284 Proj(*U_,*V_,PiU,PiV);
1285 tmp = Utils::errorEquality(*deltaU_,PiU);
1286 os <<
" >> Error in Pi D_U == D_U : " << tmp << std::endl;
1287 tmp = Utils::errorEquality(*deltaV_,PiV);
1288 os <<
" >> Error in Pi D_V == D_V : " << tmp << std::endl;
1295 Proj(*U_,*V_,PiU,PiV);
1296 tmp = Utils::errorEquality(*HdU_,PiU);
1297 os <<
" >> Error in Pi H D_U == H D_U : " << tmp << std::endl;
1298 tmp = Utils::errorEquality(*HdV_,PiV);
1299 os <<
" >> Error in Pi H D_V == H D_V : " << tmp << std::endl;
1301 Hess(*U_,*V_,*deltaU_,*deltaV_,HU,HV);
1302 tmp = Utils::errorEquality(*HdU_,HU);
1303 os <<
" >> Error in H D_U == HD_U : " << tmp << std::endl;
1304 tmp = Utils::errorEquality(*HdV_,HV);
1305 os <<
" >> Error in H D_V == HD_V : " << tmp << std::endl;
1308 Hd_d = innerProduct(*HdU_,*HdV_,*deltaU_,*deltaV_);
1309 d_Hd = innerProduct(*deltaU_,*deltaV_,*HdU_,*HdV_);
1310 os <<
" >> Hd_d : " << Hd_d
1311 <<
" \t\t d_Hd : " << d_Hd << std::endl;
1319 Proj(*U_,*V_,PiU,PiV);
1320 tmp = Utils::errorEquality(*RU_,PiU);
1321 os <<
" >> Error in Pi R_U == R_U : " << tmp << std::endl;
1322 tmp = Utils::errorEquality(*RV_,PiV);
1323 os <<
" >> Error in Pi R_V == R_V : " << tmp << std::endl;
1326 Hess(*U_,*V_,*etaU_,*etaV_,HU,HV);
1328 for (
int j=0; j<rank_; j++) {
1329 GU(j)->Scale(N_[j]);
1330 GV(j)->Scale(N_[j]);
1332 Proj(*U_,*V_,GU,GV);
1334 GU.Update(1.0,HU,1.0);
1335 GV.Update(1.0,HV,1.0);
1337 tmp = Utils::errorEquality(*RU_,GU);
1338 os <<
" >> Error in (model res)_U == R_U : " << tmp << std::endl;
1339 tmp = Utils::errorEquality(*RV_,GV);
1340 os <<
" >> Error in (model res)_V == R_V : " << tmp << std::endl;
1343 std::cout << os.str() << std::endl;
1346 void StSVDRTR::printStatus()
const
1349 using std::setprecision;
1351 using std::scientific;
1355 if (verbLevel_ == 1) {
1359 std::cout << (accepted_ ?
"accept" :
"REJECT");
1362 std::cout <<
"<init>";
1364 std::cout <<
" " << tradjust_
1365 <<
" k: " << setw(5) << iter_
1367 if (numInner_ == -1) {
1368 std::cout <<
" n/a";
1371 std::cout << setw(5) << numInner_;
1373 std::cout <<
" f(x): " << setw(18) << scientific << setprecision(10) << fx_
1374 <<
" |res|: " << setw(18) << scientific << setprecision(10) << maxScaledNorm_
1375 <<
" " << stopReasons_[innerStop_] << std::endl;
1377 else if (verbLevel_ > 1) {
1378 std::cout <<
"----------------------------------------------------------------" << std::endl;
1382 std::cout << (accepted_ ?
"accept" :
"REJECT");
1385 std::cout <<
"<init>";
1387 std::cout <<
" " << tradjust_
1388 <<
" k: " << setw(5) << iter_
1390 if (numInner_ == -1) {
1391 std::cout <<
" n/a ";
1394 std::cout << setw(5) << numInner_;
1396 std::cout <<
" " << stopReasons_[innerStop_] << std::endl;
1398 std::cout <<
" f(x) : " << setw(18) << scientific << setprecision(10) << fx_
1399 <<
" |res|: " << setw(18) << scientific << setprecision(10) << maxScaledNorm_ << std::endl;
1401 std::cout <<
" Delta : " << setw(18) << scientific << setprecision(10) << Delta_
1402 <<
" |eta| : " << setw(18) << scientific << setprecision(10) << etaLen_ << std::endl;
1405 std::cout <<
" NEGATIVE rho : " << setw(18) << scientific << setprecision(10) << rho_ << std::endl;
1407 else if (tiny_rhonum_) {
1409 std::cout <<
" VERY SMALL rho_num : " << setw(18) << scientific << setprecision(10) << rhonum_ << std::endl;
1411 else if (zero_rhoden_) {
1413 std::cout <<
" ZERO rho_den : " << setw(18) << scientific << setprecision(10) << rhoden_ << std::endl;
1417 std::cout <<
" rho : " << setw(18) << scientific << setprecision(10) << rho_ << std::endl;
std::vector< double > getSingularValues() const
Return the singular values.
T & get(const std::string &name, T def_value)
void updateBasis(const Teuchos::RCP< Epetra_MultiVector > &update_ss)
Update the current basis using a new set of snapshots.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
std::vector< double > getResNorms()
Return the scaled residual norms.
void Reset(const Teuchos::RCP< Epetra_MultiVector > &new_ss)
Reset the snapshot set used to compute the reduced basis.
StSVDRTR()
Default constructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void GESVD(const char JOBU, const char JOBVT, const OrdinalType m, const OrdinalType n, ScalarType *A, const OrdinalType lda, MagnitudeType *S, ScalarType *U, const OrdinalType ldu, ScalarType *V, const OrdinalType ldv, ScalarType *WORK, const OrdinalType lwork, MagnitudeType *RWORK, OrdinalType *info) const
void computeBasis()
Computes bases for the left and (optionally) right singular subspaces, along with singular vaues...
static magnitudeType magnitude(T a)
bool isType(const std::string &name) const
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Teuchos::RCP< const Epetra_MultiVector > getRightBasis() const
Return a basis for the right singular subspace.
Teuchos::RCP< const Epetra_MultiVector > getBasis() const
Return a basis for the left singular subspace.
void Initialize(const Teuchos::RCP< Teuchos::ParameterList > ¶ms, const Teuchos::RCP< const Epetra_MultiVector > &init, const Teuchos::RCP< RBGen::FileIOHandler< Epetra_Operator > > &fileio=Teuchos::null)
Initialize the method with the given parameter list and snapshot set.