Changeset 2562 in Sophya for trunk/SophyaProg/Tests/tsttminv.cc


Ignore:
Timestamp:
Jul 23, 2004, 12:54:27 PM (21 years ago)
Author:
cmv
Message:

add test of lapack SVD decomp by Divide and Conquer (cmv 23/07/04)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaProg/Tests/tsttminv.cc

    r2558 r2562  
    2727#define ALSO_LAPACK_EV_SYM
    2828#define ALSO_LAPACK_SVD
     29#define ALSO_LAPACK_SVD_DC
    2930
    3031//////////////////////////////////////////////////
     
    338339cout<<"------------ Eigen decompositon LapackEigen "<<endl;
    339340A=Ainput;
    340 TMatrix< TYPE > Evec(N,N); Evec = (TYPE) 0;
    341 TVector< complex<r_8> > Eval(N); Eval = complex<r_8>(0,0);
     341TMatrix< TYPE > Evec;
     342TVector< complex<r_8> > Eval;
    342343//-- Decompositon
    343344int_4 info = LapackEigen(A,Eval,Evec,true);
     
    434435cout<<"------------ SVD decompositon LapackSVD "<<endl;
    435436A=Ainput;
    436 TVector< TYPE > S(N,N); TMatrix< TYPE > U(N,N); TMatrix< TYPE > VT(N,N);
     437TVector< TYPE > S; TMatrix< TYPE > U; TMatrix< TYPE > VT;
    437438//-- Decompositon
    438439int_4 info = LapackSVD(A,S,U,VT);
     
    453454Check_Mat_Zero(AmUSVt);
    454455PrtTim("--- End of LapackSVD Test ---");
     456}
     457#endif
     458
     459
     460///////////////////////////////////////////////////
     461///////////// Test avec Lapack SVD_DC /////////////
     462///////////////////////////////////////////////////
     463#if defined(USE_LAPACK) && defined(ALSO_LAPACK_SVD_DC)
     464{
     465cout<<"\n=========================================="<<endl;
     466cout<<"------------ SVD decompositon LapackSVD_DC "<<endl;
     467A=Ainput;
     468TVector< TYPE > S; TMatrix< TYPE > U; TMatrix< TYPE > VT;
     469//-- Decompositon
     470int_4 info = LapackSVD_DC(A,S,U,VT);
     471cout<<"info="<<info<<endl;
     472PrtTim("--- End of LapackSVD_DC decompositon ---");
     473if(nprline>0) {cout<<S; cout<<endl;}
     474double smax = ABS_VAL(S(0)), smin = ABS_VAL(S(N-1));
     475cout<<" Smin = |"<<S(N-1)<<"| = "<<smin<<", "
     476    <<" Smax = |"<<S(0)<<"| = "<<smax<<", "
     477    <<" --> Smin/Smax = "<<smin/smax<<endl;
     478//-- A = U*S*VT
     479cout<<"Compute A = U*S*VT"<<endl;
     480TMatrix< TYPE > AmUSVt(N,N); AmUSVt = U;
     481for(int i=0;i<N;i++) for(int j=0;j<N;j++) AmUSVt(i,j) *= S(j);
     482AmUSVt *= VT; AmUSVt -= Ainput;
     483if(nprline>0) {cout<<AmUSVt; cout<<endl;}
     484//-- Check
     485Check_Mat_Zero(AmUSVt);
     486PrtTim("--- End of LapackSVD_DC Test ---");
    455487}
    456488#endif
Note: See TracChangeset for help on using the changeset viewer.