Changeset 2563 in Sophya
- Timestamp:
- Jul 26, 2004, 12:55:16 PM (21 years ago)
- Location:
- trunk/SophyaExt/LinAlg
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/LinAlg/intflapack.cc
r2561 r2563 209 209 210 210 //////////////////////////////////////////////////////////////////////////////////// 211 //! Interface to Lapack linear system solver driver s/d/c/zgesv d().212 /*! Solve the linear system a * x = b . Input arrays213 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). 214 214 \param a : input matrix, overwritten on output 215 215 \param b : input-output, input vector b, contains x on exit … … 262 262 263 263 //////////////////////////////////////////////////////////////////////////////////// 264 //! Interface to Lapack linear system solver driver s/d/c/zsysv d().265 /*! Solve the linear system a * x = b with a symetric . Input arrays266 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). 267 267 \param a : input matrix symetric , overwritten on output 268 268 \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() 270 270 */ 271 271 template <class T> … … 341 341 //! Interface to Lapack least squares solver driver s/d/c/zgels(). 342 342 /*! 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 . 344 344 A solution \b x to the overdetermined system of linear equations 345 345 b = a * x is computed, minimizing the norm of b-a*x. … … 569 569 /*! Same as SVD but with Divide and Conquer method */ 570 570 template <class T> 571 int LapackServer<T>::SVD_DC(TMatrix<T>& a, TVector< T>& s, TMatrix<T>& u, TMatrix<T>& vt)571 int LapackServer<T>::SVD_DC(TMatrix<T>& a, TVector<r_8>& s, TMatrix<T>& u, TMatrix<T>& vt) 572 572 { 573 573 … … 593 593 594 594 if(typeid(T) == typeid(r_4) ) { 595 r_4* sloc = new r_4[minmn]; 595 596 int_4 lwork = 3*minmn*minmn + supermax; 596 597 r_4* work = new r_4[lwork +5]; 597 598 int_4* iwork = new int_4[8*minmn +5]; 598 599 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, 600 601 (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; 602 604 } else if(typeid(T) == typeid(r_8) ) { 603 605 int_4 lwork = 3*minmn*minmn + supermax; … … 617 619 (r_4*)sloc,(complex<r_4>*)u.Data(),&ldu,(complex<r_4>*)vt.Data(),&ldvt, 618 620 (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]; 620 622 delete [] sloc; delete [] work; delete [] rwork; delete [] iwork; 621 623 } else if(typeid(T) == typeid(complex<r_8>) ) { 622 r_8* sloc = new r_8[minmn];623 624 int_4 lwork = minmn*minmn+2*minmn+maxmn; 624 625 complex<r_8>* work = new complex<r_8>[lwork +5]; … … 626 627 int_4* iwork = new int_4[8*minmn +5]; 627 628 zgesdd_(&jobz,&m,&n,(complex<r_8>*)a.Data(),&lda, 628 (r_8*)s loc,(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, 629 630 (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; 632 632 } else { 633 633 string tn = typeid(T).name(); -
trunk/SophyaExt/LinAlg/intflapack.h
r2561 r2563 20 20 virtual int SVD(TArray<T>& a, TArray<T> & s); 21 21 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); 23 23 24 24 virtual int LapackEigenSym(TArray<T>& a, TVector<r_8>& b, bool eigenvector=true); … … 84 84 85 85 /*! \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>&) 87 87 \brief SVD decomposition DC using LapackServer. 88 88 */ 89 89 template <class T> 90 inline int LapackSVD_DC(TMatrix<T>& a, TVector< T>& s, TMatrix<T>& u, TMatrix<T>& vt)90 inline int LapackSVD_DC(TMatrix<T>& a, TVector<r_8>& s, TMatrix<T>& u, TMatrix<T>& vt) 91 91 { LapackServer<T> lps; return( lps.SVD_DC(a, s, u, vt) ); } 92 92
Note:
See TracChangeset
for help on using the changeset viewer.