1 #include "RBGen_ISVDMultiSDA.h"
3 #include "Epetra_LAPACK.h"
4 #include "Epetra_BLAS.h"
5 #include "Epetra_Comm.h"
13 "RBGen::ISVDMultiSDA::updateBasis(): this routine not supported.");
15 void ISVDMultiSDA::makePass() {
19 bool firstPass = (curRank_ == 0);
20 const int numCols = A_->NumVectors();
22 "RBGen::ISVDMultiSDA::makePass(): after first pass, numProc should be numCols");
46 int info, lwork = 2*curRank_;
47 std::vector<double> tau(2*curRank_), work(lwork);
48 info = lclZ->ExtractView(&Z_A,&Z_LDA);
50 "RBGen::ISVDMultiSDA::makePass(): error calling ExtractView on Epetra_MultiVector Z.");
51 lapack.
GEQRF(numCols,2*curRank_,Z_A,Z_LDA,&tau[0],&work[0],lwork,&info);
53 "RBGen::ISVDMultiSDA::makePass(): error calling GEQRF on current right basis while constructing next pass coefficients.");
60 for (
int j=0; j<curRank_; j++) {
61 for (
int i=0; i<j; i++) {
62 Rerr += abs(Z_A[j*Z_LDA+i]);
64 Rerr += abs(abs(Z_A[j*Z_LDA+j]) - 1.0);
69 lapack.
LARFT(
'F',
'C',numCols,2*curRank_,Z_A,Z_LDA,&tau[0],workT_->
A(),workT_->
LDA());
80 for (
int j=0; j<2*curRank_; j++) {
82 for (
int i=0; i<j; i++) {
90 info = lclAZT->Multiply(
'N',
'N',1.0,*A_,*lclZ,0.0);
92 "RBGen::ISVDMultiSDA::makePass(): Error calling Epetra_MultiVector::Multiply() for A*Z");
94 info = lclAZT->ExtractView(&AZT_A,&AZT_LDA);
96 "RBGen::ISVDMultiSDA::makePass(): error calling ExtractView on Epetra_MultiVector AZ.");
97 blas.
TRMM(
'R',
'U',
'N',
'N',numCols,2*curRank_,1.0,workT_->
A(),workT_->
LDA(),AZT_A,AZT_LDA);
109 while (numProc_ < numCols) {
128 lup = (lup < lmin_ ? lmin_ : lup);
129 lup = (lup > lmax_ ? lmax_ : lup);
136 lup = (lup > numCols - numProc_ ? numCols - numProc_ : lup);
138 lup = (lup > maxBasisSize_ - curRank_ ? maxBasisSize_ - curRank_ : lup);
155 int info = Unew.Multiply(
'N',
'T',-1.0,*lclAZT,Zi,1.0);
157 "RBGen::ISVDMultiSDA::makePass(): Error calling Epetra_MultiVector::Multiply() for A*Wi");
179 info = TZTV.Multiply(
'T',
'N',1.0,*lclZ,lclV,0.0);
181 "RBGen::ISVDMultiSDA::makePass(): Error calling Epetra_MultiVector::Multiply() for Z^T V.");
183 info = TZTV.ExtractView(&TZTV_A,&TZTV_LDA);
185 "RBGen::ISVDMultiSDA::makePass(): error calling ExtractView on Epetra_MultiVector TZTV.");
187 blas.
TRMM(
'L',
'U',
'N',
'N',2*oldRank,curRank_,1.0,workT_->
A(),workT_->
LDA(),TZTV_A,TZTV_LDA);
189 info = lclV.Multiply(
'N',
'N',-1.0,*lclZ,TZTV,1.0);
191 "RBGen::ISVDMultiSDA::makePass(): Error calling Epetra_MultiVector::Multiply() for W V.");
208 int info = Z2.Multiply(
'T',
'N',1.0,*A_,Ulcl,0.0);
210 "RBGen::IncSVD::computeBasis(): Error calling Epetra_MultiVector::Multiply for A^T U.");
213 for (
int i=0; i<curRank_; i++) {
217 info = Z2.Multiply(
'N',
'N',-1.0,Vlcl,S,1.0);
219 "RBGen::IncSVD::computeBasis(): Error calling Epetra_MultiVector::Multiply for V S.");
223 resNorms_.resize(curRank_);
224 Z2.Norm2(&resNorms_[0]);
226 for (
int i=0; i<curRank_; i++) {
227 if (sigma_[i] != 0.0) {
228 resNorms_[i] /= sigma_[i];
235 std::vector<double> errnorms(curRank_);
241 curU(::View,*U_,0,curRank_),
242 curV(::View,*V_,0,curRank_);
246 for (
int i=0; i<curRank_; i++) {
247 curS[i][i] = sigma_[i];
249 info = work.Multiply(
'N',
'N',1.0,curU,curS,0.0);
251 "RBGen::ISVDMultiSDA::makePass(): Error calling Epetra_MultiVector::Multiply() for debugging U S.");
252 info = work.Multiply(
'N',
'N',-1.0,*A_,curV,1.0);
254 "RBGen::ISVDMultiSDA::makePass(): Error calling Epetra_MultiVector::Multiply() for debugging U S - A V.");
255 work.Norm2(&errnorms[0]);
256 for (
int i=0; i<curRank_; i++) {
257 if (sigma_[i] != 0.0) {
258 errnorms[i] /= sigma_[i];
268 if (comm->
MyPID() == 0 && verbLevel_ >= 1) {
270 <<
"------------- ISVDMultiSDA::makePass() -----------" << std::endl
271 <<
"| Number of passes: " << curNumPasses_ << std::endl
272 <<
"| Current rank: " << curRank_ << std::endl
273 <<
"| Current sigmas: " << std::endl;
274 for (
int i=0; i<curRank_; i++) {
275 std::cout <<
"| " << sigma_[i] << std::endl;
278 std::cout <<
"|DBG US-AV norms: " << std::endl;
279 for (
int i=0; i<curRank_; i++) {
280 std::cout <<
"|DBG " << errnorms[i] << std::endl;
283 std::cout <<
"|DBG R-I norm: " << Rerr << std::endl;
void TRMM(const char SIDE, const char UPLO, const char TRANSA, const char DIAG, const int M, const int N, const float ALPHA, const float *A, const int LDA, float *B, const int LDB) const
#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
void updateBasis(const Teuchos::RCP< Epetra_MultiVector > &update_ss)
Update the current basis by appending new snapshots.
virtual int MyPID() const =0
ISVDMultiSDA()
Default constructor.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void LARFT(const char DIRECT, const char STOREV, const int N, const int K, double *V, const int LDV, double *TAU, double *T, const int LDT) const
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.