1 | #ifndef IntfLapack_H_SEEN
|
---|
2 | #define IntfLapack_H_SEEN
|
---|
3 |
|
---|
4 | #include "machdefs.h"
|
---|
5 | #include "tarray.h"
|
---|
6 |
|
---|
7 | namespace SOPHYA {
|
---|
8 |
|
---|
9 | template <class T>
|
---|
10 | class LapackServer {
|
---|
11 | public:
|
---|
12 | LapackServer();
|
---|
13 | virtual ~LapackServer();
|
---|
14 |
|
---|
15 | virtual int LinSolve(TArray<T>& a, TArray<T> & b);
|
---|
16 | virtual int SVD(TArray<T>& a, TArray<T> & s);
|
---|
17 | virtual int SVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt);
|
---|
18 |
|
---|
19 | //! Set the workspace size factor for LAPACK routines
|
---|
20 | inline void SetWorkSpaceSizeFactor(int f = 2)
|
---|
21 | { wspace_size_factor = (f > 1) ? f : 1; }
|
---|
22 |
|
---|
23 | //! Returns the workspace size factor
|
---|
24 | inline int GetWorkSpaceSizeFactor()
|
---|
25 | { return wspace_size_factor; }
|
---|
26 |
|
---|
27 | private:
|
---|
28 | int SVDDriver(TArray<T>& a, TArray<T> & s,
|
---|
29 | TArray<T>* up=NULL, TArray<T> * vtp=NULL);
|
---|
30 |
|
---|
31 | int wspace_size_factor;
|
---|
32 | };
|
---|
33 |
|
---|
34 | /*! \ingroup LinAlg
|
---|
35 | \fn LapackLinSolve(TArray<T>&, TArray<T> &)
|
---|
36 | \brief Solves the linear system A*X = B using LapackServer.
|
---|
37 | */
|
---|
38 | template <class T>
|
---|
39 | inline int LapackLinSolve(TArray<T>& a, TArray<T> & b)
|
---|
40 | { LapackServer<T> lps; return( lps.LinSolve(a, b) ); }
|
---|
41 |
|
---|
42 | /*! \ingroup LinAlg
|
---|
43 | \fn LapackSVD(TArray<T>&, TArray<T> &)
|
---|
44 | \brief SVD decomposition using LapackServer.
|
---|
45 | */
|
---|
46 | template <class T>
|
---|
47 | inline int LapackSVD(TArray<T>& a, TArray<T> & s)
|
---|
48 | { LapackServer<T> lps; return( lps.SVD(a, s) ); }
|
---|
49 |
|
---|
50 |
|
---|
51 | /*! \ingroup LinAlg
|
---|
52 | \fn LapackSVD(TArray<T>&, TArray<T> &, TArray<T> &, TArray<T> &)
|
---|
53 | \brief SVD decomposition using LapackServer.
|
---|
54 | */
|
---|
55 | template <class T>
|
---|
56 | inline int LapackSVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt)
|
---|
57 | { LapackServer<T> lps; return( lps.SVD(a, s, u, vt) ); }
|
---|
58 |
|
---|
59 |
|
---|
60 | } // Fin du namespace
|
---|
61 |
|
---|
62 | #endif
|
---|