Changeset 2563 in Sophya


Ignore:
Timestamp:
Jul 26, 2004, 12:55:16 PM (21 years ago)
Author:
cmv
Message:

change arg SVD_DC -> TVector<r_8> cmv 26/07/04

Location:
trunk/SophyaExt/LinAlg
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/LinAlg/intflapack.cc

    r2561 r2563  
    209209
    210210////////////////////////////////////////////////////////////////////////////////////
    211 //! Interface to Lapack linear system solver driver s/d/c/zgesvd().
    212 /*! Solve the linear system a * x = b. Input arrays
    213   should have FortranMemory mapping (column packed).
     211//! Interface to Lapack linear system solver driver s/d/c/zgesv().
     212/*! Solve the linear system a * x = b using LU factorization.
     213  Input arrays should have FortranMemory mapping (column packed).
    214214  \param a : input matrix, overwritten on output
    215215  \param b : input-output, input vector b, contains x on exit
     
    262262
    263263////////////////////////////////////////////////////////////////////////////////////
    264 //! Interface to Lapack linear system solver driver s/d/c/zsysvd().
    265 /*! Solve the linear system a * x = b with a symetric. Input arrays
    266   should have FortranMemory mapping (column packed).
     264//! Interface to Lapack linear system solver driver s/d/c/zsysv().
     265/*! Solve the linear system a * x = b with a symetric matrix using LU factorization.
     266  Input arrays should have FortranMemory mapping (column packed).
    267267  \param a : input matrix symetric , overwritten on output
    268268  \param b : input-output, input vector b, contains x on exit
    269   \return : return code from lapack driver
     269  \return : return code from lapack driver _sysv()
    270270 */
    271271template <class T>
     
    341341//! Interface to Lapack least squares solver driver s/d/c/zgels().
    342342/*! Solves the linear least squares problem defined by an m-by-n matrix
    343   \b a and an m element vector \b b .
     343  \b a and an m element vector \b b , using QR or LQ factorization .
    344344  A solution \b x to the overdetermined system of linear equations
    345345  b = a * x is computed, minimizing the norm of b-a*x.
     
    569569/*! Same as SVD but with Divide and Conquer method */
    570570template <class T>
    571 int LapackServer<T>::SVD_DC(TMatrix<T>& a, TVector<T>& s, TMatrix<T>& u, TMatrix<T>& vt)
     571int LapackServer<T>::SVD_DC(TMatrix<T>& a, TVector<r_8>& s, TMatrix<T>& u, TMatrix<T>& vt)
    572572{
    573573
     
    593593
    594594  if(typeid(T) == typeid(r_4) ) {
     595    r_4* sloc = new r_4[minmn];
    595596    int_4 lwork = 3*minmn*minmn + supermax;
    596597    r_4* work = new r_4[lwork +5];
    597598    int_4* iwork = new int_4[8*minmn +5];
    598599    sgesdd_(&jobz,&m,&n,(r_4*)a.Data(),&lda,
    599            (r_4*)s.Data(),(r_4*)u.Data(),&ldu,(r_4*)vt.Data(),&ldvt,
     600           (r_4*)sloc,(r_4*)u.Data(),&ldu,(r_4*)vt.Data(),&ldvt,
    600601           (r_4*)work,&lwork,(int_4*)iwork,&info);
    601     delete [] work; delete [] iwork;
     602    for(int_4 i=0;i<minmn;i++) s(i) = (r_8) sloc[i];
     603    delete [] sloc; delete [] work; delete [] iwork;
    602604  } else if(typeid(T) == typeid(r_8) ) {
    603605    int_4 lwork = 3*minmn*minmn + supermax;
     
    617619           (r_4*)sloc,(complex<r_4>*)u.Data(),&ldu,(complex<r_4>*)vt.Data(),&ldvt,
    618620           (complex<r_4>*)work,&lwork,(r_4*)rwork,(int_4*)iwork,&info);
    619     for(int_4 i=0;i<minmn;i++) s[i] = sloc[i];
     621    for(int_4 i=0;i<minmn;i++) s(i) = (r_8) sloc[i];
    620622    delete [] sloc; delete [] work; delete [] rwork; delete [] iwork;
    621623  } else if(typeid(T) == typeid(complex<r_8>) )  {
    622     r_8* sloc = new r_8[minmn];
    623624    int_4 lwork = minmn*minmn+2*minmn+maxmn;
    624625    complex<r_8>* work = new complex<r_8>[lwork +5];
     
    626627    int_4* iwork = new int_4[8*minmn +5];
    627628    zgesdd_(&jobz,&m,&n,(complex<r_8>*)a.Data(),&lda,
    628            (r_8*)sloc,(complex<r_8>*)u.Data(),&ldu,(complex<r_8>*)vt.Data(),&ldvt,
     629           (r_8*)s.Data(),(complex<r_8>*)u.Data(),&ldu,(complex<r_8>*)vt.Data(),&ldvt,
    629630           (complex<r_8>*)work,&lwork,(r_8*)rwork,(int_4*)iwork,&info);
    630     for(int_4 i=0;i<minmn;i++) s[i] = sloc[i];
    631     delete [] sloc; delete [] work; delete [] rwork; delete [] iwork;
     631    delete [] work; delete [] rwork; delete [] iwork;
    632632  } else {
    633633    string tn = typeid(T).name();
  • trunk/SophyaExt/LinAlg/intflapack.h

    r2561 r2563  
    2020  virtual int SVD(TArray<T>& a, TArray<T> & s);
    2121  virtual int SVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt);
    22   virtual int SVD_DC(TMatrix<T>& a, TVector<T>& s, TMatrix<T>& u, TMatrix<T>& vt);
     22  virtual int SVD_DC(TMatrix<T>& a, TVector<r_8>& s, TMatrix<T>& u, TMatrix<T>& vt);
    2323 
    2424  virtual int LapackEigenSym(TArray<T>& a, TVector<r_8>& b, bool eigenvector=true);
     
    8484
    8585/*! \ingroup LinAlg
    86     \fn LapackSVD_DC(TMatrix<T>&, TVector<T>&, TMatrix<T>&, TMatrix<T>&)
     86    \fn LapackSVD_DC(TMatrix<T>&, TVector<r_8>&, TMatrix<T>&, TMatrix<T>&)
    8787    \brief SVD decomposition DC using LapackServer.
    8888*/
    8989template <class T>
    90 inline int LapackSVD_DC(TMatrix<T>& a, TVector<T>& s, TMatrix<T>& u, TMatrix<T>& vt)
     90inline int LapackSVD_DC(TMatrix<T>& a, TVector<r_8>& s, TMatrix<T>& u, TMatrix<T>& vt)
    9191{ LapackServer<T> lps; return( lps.SVD_DC(a, s, u, vt) ); }
    9292
Note: See TracChangeset for help on using the changeset viewer.