[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);
|
---|
[2563] | 22 | virtual int SVD_DC(TMatrix<T>& a, TVector<r_8>& s, TMatrix<T>& u, TMatrix<T>& vt);
|
---|
[2556] | 23 |
|
---|
| 24 | virtual int LapackEigenSym(TArray<T>& a, TVector<r_8>& b, bool eigenvector=true);
|
---|
| 25 | virtual int LapackEigen(TArray<T>& a, TVector< complex<r_8> >& eval, TMatrix<T>& evec, bool eigenvector);
|
---|
[1342] | 26 |
|
---|
[1424] | 27 | //! Set the workspace size factor for LAPACK routines
|
---|
[1342] | 28 | inline void SetWorkSpaceSizeFactor(int f = 2)
|
---|
| 29 | { wspace_size_factor = (f > 1) ? f : 1; }
|
---|
[1424] | 30 |
|
---|
| 31 | //! Returns the workspace size factor
|
---|
[1342] | 32 | inline int GetWorkSpaceSizeFactor()
|
---|
| 33 | { return wspace_size_factor; }
|
---|
| 34 |
|
---|
| 35 | private:
|
---|
| 36 | int SVDDriver(TArray<T>& a, TArray<T> & s,
|
---|
| 37 | TArray<T>* up=NULL, TArray<T> * vtp=NULL);
|
---|
[2554] | 38 | 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] | 39 |
|
---|
| 40 | int wspace_size_factor;
|
---|
[814] | 41 | };
|
---|
| 42 |
|
---|
[1424] | 43 | /*! \ingroup LinAlg
|
---|
| 44 | \fn LapackLinSolve(TArray<T>&, TArray<T> &)
|
---|
| 45 | \brief Solves the linear system A*X = B using LapackServer.
|
---|
| 46 | */
|
---|
[814] | 47 | template <class T>
|
---|
[1042] | 48 | inline int LapackLinSolve(TArray<T>& a, TArray<T> & b)
|
---|
[1342] | 49 | { LapackServer<T> lps; return( lps.LinSolve(a, b) ); }
|
---|
[814] | 50 |
|
---|
[1566] | 51 | /*! \ingroup LinAlg
|
---|
[2554] | 52 | \fn LapackLinSolveSym(TArray<T>&, TArray<T> &)
|
---|
| 53 | \brief Solves the linear system A*X = B with A symetric using LapackServer.
|
---|
| 54 | */
|
---|
| 55 | template <class T>
|
---|
| 56 | inline int LapackLinSolveSym(TArray<T>& a, TArray<T> & b)
|
---|
| 57 | { LapackServer<T> lps; return( lps.LinSolveSym(a, b) ); }
|
---|
| 58 |
|
---|
| 59 | /*! \ingroup LinAlg
|
---|
[1566] | 60 | \fn LapackLeastSquareSolve(TArray<T>&, TArray<T> &)
|
---|
| 61 | \brief Solves the linear least squares problem A*X - B
|
---|
| 62 | */
|
---|
[1494] | 63 | template <class T>
|
---|
| 64 | inline int LapackLeastSquareSolve(TArray<T>& a, TArray<T> & b)
|
---|
| 65 | { LapackServer<T> lps; return( lps.LeastSquareSolve(a, b) ); }
|
---|
| 66 |
|
---|
[1424] | 67 | /*! \ingroup LinAlg
|
---|
| 68 | \fn LapackSVD(TArray<T>&, TArray<T> &)
|
---|
| 69 | \brief SVD decomposition using LapackServer.
|
---|
| 70 | */
|
---|
[1342] | 71 | template <class T>
|
---|
| 72 | inline int LapackSVD(TArray<T>& a, TArray<T> & s)
|
---|
| 73 | { LapackServer<T> lps; return( lps.SVD(a, s) ); }
|
---|
[814] | 74 |
|
---|
[1424] | 75 |
|
---|
| 76 | /*! \ingroup LinAlg
|
---|
| 77 | \fn LapackSVD(TArray<T>&, TArray<T> &, TArray<T> &, TArray<T> &)
|
---|
| 78 | \brief SVD decomposition using LapackServer.
|
---|
| 79 | */
|
---|
[1342] | 80 | template <class T>
|
---|
| 81 | inline int LapackSVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt)
|
---|
| 82 | { LapackServer<T> lps; return( lps.SVD(a, s, u, vt) ); }
|
---|
| 83 |
|
---|
| 84 |
|
---|
[2556] | 85 | /*! \ingroup LinAlg
|
---|
[2563] | 86 | \fn LapackSVD_DC(TMatrix<T>&, TVector<r_8>&, TMatrix<T>&, TMatrix<T>&)
|
---|
[2561] | 87 | \brief SVD decomposition DC using LapackServer.
|
---|
| 88 | */
|
---|
| 89 | template <class T>
|
---|
[2563] | 90 | inline int LapackSVD_DC(TMatrix<T>& a, TVector<r_8>& s, TMatrix<T>& u, TMatrix<T>& vt)
|
---|
[2561] | 91 | { LapackServer<T> lps; return( lps.SVD_DC(a, s, u, vt) ); }
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 | /*! \ingroup LinAlg
|
---|
[2556] | 95 | \fn LapackEigenSym(TArray<T>&, TArray<T> &)
|
---|
| 96 | \brief Compute the eigenvalues and eigenvectors of A (symetric or hermitian).
|
---|
| 97 | */
|
---|
| 98 | template <class T>
|
---|
| 99 | inline int LapackEigenSym(TArray<T>& a, TVector<r_8>& b, bool eigenvector=true)
|
---|
| 100 | { LapackServer<T> lps; return( lps.LapackEigenSym(a,b,eigenvector) ); }
|
---|
| 101 |
|
---|
| 102 | /*! \ingroup LinAlg
|
---|
| 103 | \fn LapackEigen(TArray<T>&, TArray<T> &)
|
---|
| 104 | \brief Compute the eigenvalues and (right) eigenvectors of A (general square matrix).
|
---|
| 105 | */
|
---|
| 106 | template <class T>
|
---|
| 107 | inline int LapackEigen(TArray<T>& a, TVector< complex<r_8> >& eval, TMatrix<T>& evec, bool eigenvector=true)
|
---|
| 108 | { LapackServer<T> lps; return( lps.LapackEigen(a,eval,evec,eigenvector) ); }
|
---|
| 109 |
|
---|
[814] | 110 | } // Fin du namespace
|
---|
| 111 |
|
---|
[775] | 112 | #endif
|
---|