1 #include "RBGen_ISVDMultiSDB.h"
3 #include "Epetra_LAPACK.h"
4 #include "Epetra_BLAS.h"
5 #include "Epetra_Comm.h"
6 #include "Epetra_Map.h"
14 "RBGen::ISVDMultiSDB::updateBasis(): this routine not supported.");
16 void ISVDMultiSDB::makePass() {
20 bool firstPass = (curRank_ == 0);
21 const int numCols = A_->NumVectors();
42 int info, lwork = 2*curRank_;
43 std::vector<double> tau(2*curRank_), work(lwork);
44 lapack.
GEQRF(numCols,2*curRank_,W12[0],numCols,&tau[0],&work[0],lwork,&info);
46 "RBGen::ISVDMultiSDB::makePass(): error calling GEQRF on current right basis while constructing next pass coefficients.");
53 for (
int j=0; j<curRank_; j++) {
54 for (
int i=0; i<j; i++) {
55 Rerr += abs(W12[j][i]);
57 Rerr += abs(abs(W12[j][j]) - 1.0);
62 lapack.
ORGQR(numCols,2*curRank_,2*curRank_,W12[0],numCols,&tau[0],&work[0],lwork,&info);
64 "RBGen::ISVDMultiSDB::makePass(): error calling ORGQR to construct next pass coefficients.");
68 info = lclAW.Multiply(
'N',
'N',1.0,*A_,W12,0.0);
70 "RBGen::ISVDMultiSDB::makePass(): Error calling Epetra_MultiVector::Multiply() for A*W");
78 while ( ( firstPass && numProc_ < numCols) ||
79 (!firstPass && numProc_ < 2*oldRank) ) {
98 lup = (lup < lmin_ ? lmin_ : lup);
99 lup = (lup > lmax_ ? lmax_ : lup);
109 lup = (lup > numCols - numProc_ ? numCols - numProc_ : lup);
112 lup = (lup > 2*oldRank - numProc_ ? 2*oldRank - numProc_ : lup);
115 lup = (lup > maxBasisSize_ - curRank_ ? maxBasisSize_ - curRank_ : lup);
147 int info = lclWV.Multiply(
'N',
'N',1.0,W12,lclV,0.0);
149 "RBGen::ISVDMultiSDB::makePass(): error Multiply()ing Epetra_MultiVector for W*V.");
169 int info = W2.Multiply(
'T',
'N',1.0,*A_,Ulcl,0.0);
171 "RBGen::IncSVD::computeBasis(): Error calling Epetra_MultiVector::Multiply for A^T U.");
174 for (
int i=0; i<curRank_; i++) {
178 info = W2.Multiply(
'N',
'N',-1.0,Vlcl,S,1.0);
180 "RBGen::IncSVD::computeBasis(): Error calling Epetra_MultiVector::Multiply for V S.");
184 resNorms_.resize(curRank_);
185 W2.Norm2(&resNorms_[0]);
187 for (
int i=0; i<curRank_; i++) {
188 if (sigma_[i] != 0.0) {
189 resNorms_[i] /= sigma_[i];
196 std::vector<double> errnorms(curRank_);
202 curU(::View,*U_,0,curRank_),
203 curV(::View,*V_,0,curRank_);
207 for (
int i=0; i<curRank_; i++) {
208 curS[i][i] = sigma_[i];
210 info = work.Multiply(
'N',
'N',1.0,curU,curS,0.0);
212 "RBGen::ISVDMultiSDB::makePass(): Error calling Epetra_MultiVector::Multiply() for debugging U S.");
213 info = work.Multiply(
'N',
'N',-1.0,*A_,curV,1.0);
215 "RBGen::ISVDMultiSDB::makePass(): Error calling Epetra_MultiVector::Multiply() for debugging U S - A V.");
216 work.Norm2(&errnorms[0]);
217 for (
int i=0; i<curRank_; i++) {
218 if (sigma_[i] != 0.0) {
219 errnorms[i] /= sigma_[i];
229 if (comm->
MyPID() == 0 && verbLevel_ >= 1) {
231 <<
"------------- ISVDMultiSDB::makePass() -----------" << std::endl
232 <<
"| Number of passes: " << curNumPasses_ << std::endl
233 <<
"| Current rank: " << curRank_ << std::endl
234 <<
"| Current sigmas: " << std::endl;
235 for (
int i=0; i<curRank_; i++) {
236 std::cout <<
"| " << sigma_[i] << std::endl;
239 std::cout <<
"|DBG US-AV norms: " << std::endl;
240 for (
int i=0; i<curRank_; i++) {
241 std::cout <<
"|DBG " << errnorms[i] << std::endl;
244 std::cout <<
"|DBG R-I norm: " << Rerr << std::endl;
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void GEQRF(const int M, const int N, float *A, const int LDA, float *TAU, float *WORK, const int lwork, int *INFO) const
virtual int MyPID() const =0
ISVDMultiSDB()
Default constructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void updateBasis(const Teuchos::RCP< Epetra_MultiVector > &update_ss)
Update the current basis by appending new snapshots.
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.
void ORGQR(const int M, const int N, const int K, float *A, const int LDA, float *TAU, float *WORK, const int LWORK, int *INFO) const