[775] | 1 | #ifndef IntfLapack_H_SEEN
|
---|
| 2 | #define IntfLapack_H_SEEN
|
---|
| 3 |
|
---|
| 4 | #include "machdefs.h"
|
---|
| 5 | #include "tarray.h"
|
---|
[2556] | 6 | #include "tvector.h"
|
---|
[775] | 7 |
|
---|
[814] | 8 | namespace SOPHYA {
|
---|
[775] | 9 |
|
---|
[814] | 10 | template <class T>
|
---|
| 11 | class LapackServer {
|
---|
| 12 | public:
|
---|
[1342] | 13 | LapackServer();
|
---|
| 14 | virtual ~LapackServer();
|
---|
| 15 |
|
---|
| 16 | virtual int LinSolve(TArray<T>& a, TArray<T> & b);
|
---|
[2554] | 17 | virtual int LinSolveSym(TArray<T>& a, TArray<T> & b);
|
---|
[1494] | 18 | virtual int LeastSquareSolve(TArray<T>& a, TArray<T> & b);
|
---|
| 19 |
|
---|
[1342] | 20 | virtual int SVD(TArray<T>& a, TArray<T> & s);
|
---|
[2556] | 21 | virtual int SVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt);
|
---|
| 22 |
|
---|
| 23 | virtual int LapackEigenSym(TArray<T>& a, TVector<r_8>& b, bool eigenvector=true);
|
---|
| 24 | virtual int LapackEigen(TArray<T>& a, TVector< complex<r_8> >& eval, TMatrix<T>& evec, bool eigenvector);
|
---|
[1342] | 25 |
|
---|
[1424] | 26 | //! Set the workspace size factor for LAPACK routines
|
---|
[1342] | 27 | inline void SetWorkSpaceSizeFactor(int f = 2)
|
---|
| 28 | { wspace_size_factor = (f > 1) ? f : 1; }
|
---|
[1424] | 29 |
|
---|
| 30 | //! Returns the workspace size factor
|
---|
[1342] | 31 | inline int GetWorkSpaceSizeFactor()
|
---|
| 32 | { return wspace_size_factor; }
|
---|
| 33 |
|
---|
| 34 | private:
|
---|
| 35 | int SVDDriver(TArray<T>& a, TArray<T> & s,
|
---|
| 36 | TArray<T>* up=NULL, TArray<T> * vtp=NULL);
|
---|
[2554] | 37 | int_4 ilaenv_en_C(int_4 ispec,char *name,char *opts,int_4 n1,int_4 n2,int_4 n3,int_4 n4);
|
---|
[1342] | 38 |
|
---|
| 39 | int wspace_size_factor;
|
---|
[814] | 40 | };
|
---|
| 41 |
|
---|
[1424] | 42 | /*! \ingroup LinAlg
|
---|
| 43 | \fn LapackLinSolve(TArray<T>&, TArray<T> &)
|
---|
| 44 | \brief Solves the linear system A*X = B using LapackServer.
|
---|
| 45 | */
|
---|
[814] | 46 | template <class T>
|
---|
[1042] | 47 | inline int LapackLinSolve(TArray<T>& a, TArray<T> & b)
|
---|
[1342] | 48 | { LapackServer<T> lps; return( lps.LinSolve(a, b) ); }
|
---|
[814] | 49 |
|
---|
[1566] | 50 | /*! \ingroup LinAlg
|
---|
[2554] | 51 | \fn LapackLinSolveSym(TArray<T>&, TArray<T> &)
|
---|
| 52 | \brief Solves the linear system A*X = B with A symetric using LapackServer.
|
---|
| 53 | */
|
---|
| 54 | template <class T>
|
---|
| 55 | inline int LapackLinSolveSym(TArray<T>& a, TArray<T> & b)
|
---|
| 56 | { LapackServer<T> lps; return( lps.LinSolveSym(a, b) ); }
|
---|
| 57 |
|
---|
| 58 | /*! \ingroup LinAlg
|
---|
[1566] | 59 | \fn LapackLeastSquareSolve(TArray<T>&, TArray<T> &)
|
---|
| 60 | \brief Solves the linear least squares problem A*X - B
|
---|
| 61 | */
|
---|
[1494] | 62 | template <class T>
|
---|
| 63 | inline int LapackLeastSquareSolve(TArray<T>& a, TArray<T> & b)
|
---|
| 64 | { LapackServer<T> lps; return( lps.LeastSquareSolve(a, b) ); }
|
---|
| 65 |
|
---|
[1424] | 66 | /*! \ingroup LinAlg
|
---|
| 67 | \fn LapackSVD(TArray<T>&, TArray<T> &)
|
---|
| 68 | \brief SVD decomposition using LapackServer.
|
---|
| 69 | */
|
---|
[1342] | 70 | template <class T>
|
---|
| 71 | inline int LapackSVD(TArray<T>& a, TArray<T> & s)
|
---|
| 72 | { LapackServer<T> lps; return( lps.SVD(a, s) ); }
|
---|
[814] | 73 |
|
---|
[1424] | 74 |
|
---|
| 75 | /*! \ingroup LinAlg
|
---|
| 76 | \fn LapackSVD(TArray<T>&, TArray<T> &, TArray<T> &, TArray<T> &)
|
---|
| 77 | \brief SVD decomposition using LapackServer.
|
---|
| 78 | */
|
---|
[1342] | 79 | template <class T>
|
---|
| 80 | inline int LapackSVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt)
|
---|
| 81 | { LapackServer<T> lps; return( lps.SVD(a, s, u, vt) ); }
|
---|
| 82 |
|
---|
| 83 |
|
---|
[2556] | 84 | /*! \ingroup LinAlg
|
---|
| 85 | \fn LapackEigenSym(TArray<T>&, TArray<T> &)
|
---|
| 86 | \brief Compute the eigenvalues and eigenvectors of A (symetric or hermitian).
|
---|
| 87 | */
|
---|
| 88 | template <class T>
|
---|
| 89 | inline int LapackEigenSym(TArray<T>& a, TVector<r_8>& b, bool eigenvector=true)
|
---|
| 90 | { LapackServer<T> lps; return( lps.LapackEigenSym(a,b,eigenvector) ); }
|
---|
| 91 |
|
---|
| 92 | /*! \ingroup LinAlg
|
---|
| 93 | \fn LapackEigen(TArray<T>&, TArray<T> &)
|
---|
| 94 | \brief Compute the eigenvalues and (right) eigenvectors of A (general square matrix).
|
---|
| 95 | */
|
---|
| 96 | template <class T>
|
---|
| 97 | inline int LapackEigen(TArray<T>& a, TVector< complex<r_8> >& eval, TMatrix<T>& evec, bool eigenvector=true)
|
---|
| 98 | { LapackServer<T> lps; return( lps.LapackEigen(a,eval,evec,eigenvector) ); }
|
---|
| 99 |
|
---|
[814] | 100 | } // Fin du namespace
|
---|
| 101 |
|
---|
[775] | 102 | #endif
|
---|