Changeset 1424 in Sophya
- Timestamp:
- Feb 23, 2001, 6:47:44 PM (25 years ago)
- Location:
- trunk/SophyaExt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/IFFTW/fftwserver.cc
r1405 r1424 2 2 #include "FFTW/fftw.h" 3 3 #include "FFTW/rfftw.h" 4 5 /*! 6 \defgroup IFFTW IFFTW module 7 Module containing interface classes between Sophya objects 8 and FFTW Fourier transform package (see http://www.fftw.org ) 9 */ 4 10 5 11 /*! -
trunk/SophyaExt/LinAlg/intflapack.cc
r1344 r1424 4 4 #include "tmatrix.h" 5 5 #include <typeinfo> 6 7 /*! 8 \defgroup LinAlg LinAlg module 9 This module contains classes and functions for complex linear 10 algebra on arrays. This module is intended mainly to have 11 classes implementing C++ interfaces between Sophya objects 12 and external linear algebra libraries, such as LAPACK. 13 */ 14 15 /*! 16 \class SOPHYA::LapackServer 17 \ingroup LinAlg 18 This class implements an interface to LAPACK library driver routines. 19 The LAPACK (Linear Algebra PACKage) is a collection high performance 20 routines to solve common problems in numerical linear algebra. 21 its is available from http://www.netlib.org. 22 23 The present version of our LapackServer (Feb 2001) provides only 24 interfaces for the linear system solver and singular value 25 decomposition (SVD). Only arrays with BaseArray::FortranMemoryMapping 26 can be handled by LapackServer. LapackServer can be instanciated 27 for simple and double precision real or complex array types. 28 29 The example below shows solving a linear system A*X = B 30 31 \code 32 #include "intflapack.h" 33 // ... 34 // Use FortranMemoryMapping as default 35 BaseArray::SetDefaultMemoryMapping(BaseArray::FortranMemoryMapping); 36 // Create an fill the arrays A and B 37 int n = 20; 38 Matrix A(n, n); 39 A = RandomSequence(); 40 Vector X(n),B(n); 41 X = RandomSequence(); 42 B = A*X; 43 // Solve the linear system A*X = B 44 LapackServer<r_8> lps; 45 lps.LinSolve(A,B); 46 // We get the result in B, which should be equal to X ... 47 // Compute the difference B-X ; 48 Vector diff = B-X; 49 \endcode 50 51 */ 6 52 7 53 extern "C" { … … 46 92 } 47 93 94 //! Interface to Lapack linear system solver driver s/d/c/zgesvd(). 95 /*! Solve the linear system a * x = b. Input arrays 96 should have FortranMemory mapping (column packed). 97 \param a : input matrix, overwritten on output 98 \param b : input-output, input vector b, contains x on exit 99 \return : return code from lapack driver _gesv() 100 */ 48 101 template <class T> 49 102 int LapackServer<T>::LinSolve(TArray<T>& a, TArray<T> & b) … … 91 144 } 92 145 146 //! Interface to Lapack SVD driver s/d/c/zgesv(). 147 /*! Computes the vector of singular values of \b a. Input arrays 148 should have FortranMemoryMapping (column packed). 149 \param a : input m-by-n matrix 150 \param s : Vector of min(m,n) singular values (descending order) 151 \return : return code from lapack driver _gesvd() 152 */ 153 93 154 template <class T> 94 155 int LapackServer<T>::SVD(TArray<T>& a, TArray<T> & s) … … 97 158 } 98 159 160 //! Interface to Lapack SVD driver s/d/c/zgesv(). 161 /*! Computes the vector of singular values of \b a, as well as 162 right and left singular vectors of \b a. 163 \f[ 164 A = U \Sigma V^T , ( A = U \Sigma V^H \ complex) 165 \f] 166 \f[ 167 A v_i = \sigma_i u_i \ and A^T u_i = \sigma_i v_i \ (A^H \ complex) 168 \f] 169 U and V are orthogonal (unitary) matrices. 170 \param a : input m-by-n matrix (in FotranMemoryMapping) 171 \param s : Vector of min(m,n) singular values (descending order) 172 \param u : Matrix of left singular vectors 173 \param vt : Transpose of right singular vectors. 174 \return : return code from lapack driver _gesvd() 175 */ 99 176 template <class T> 100 177 int LapackServer<T>::SVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt) … … 103 180 } 104 181 182 183 //! Interface to Lapack SVD driver s/d/c/zgesv(). 105 184 template <class T> 106 185 int LapackServer<T>::SVDDriver(TArray<T>& a, TArray<T> & s, TArray<T>* up, TArray<T>* vtp) -
trunk/SophyaExt/LinAlg/intflapack.h
r1342 r1424 17 17 virtual int SVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt); 18 18 19 //! Set the workspace size factor for LAPACK routines 19 20 inline void SetWorkSpaceSizeFactor(int f = 2) 20 21 { wspace_size_factor = (f > 1) ? f : 1; } 22 23 //! Returns the workspace size factor 21 24 inline int GetWorkSpaceSizeFactor() 22 25 { return wspace_size_factor; } … … 29 32 }; 30 33 34 /*! \ingroup LinAlg 35 \fn LapackLinSolve(TArray<T>&, TArray<T> &) 36 \brief Solves the linear system A*X = B using LapackServer. 37 */ 31 38 template <class T> 32 39 inline int LapackLinSolve(TArray<T>& a, TArray<T> & b) 33 40 { LapackServer<T> lps; return( lps.LinSolve(a, b) ); } 34 41 42 /*! \ingroup LinAlg 43 \fn LapackSVD(TArray<T>&, TArray<T> &) 44 \brief SVD decomposition using LapackServer. 45 */ 35 46 template <class T> 36 47 inline int LapackSVD(TArray<T>& a, TArray<T> & s) 37 48 { LapackServer<T> lps; return( lps.SVD(a, s) ); } 38 49 50 51 /*! \ingroup LinAlg 52 \fn LapackSVD(TArray<T>&, TArray<T> &, TArray<T> &, TArray<T> &) 53 \brief SVD decomposition using LapackServer. 54 */ 39 55 template <class T> 40 56 inline int LapackSVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt) … … 44 60 } // Fin du namespace 45 61 46 void rztest_lapack(TArray<r_4>& a, TArray<r_4>& b);47 48 62 #endif
Note:
See TracChangeset
for help on using the changeset viewer.