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 LeastSquareSolve(TArray<T>& a, TArray<T> & b);
|
---|
17 |
|
---|
18 | virtual int SVD(TArray<T>& a, TArray<T> & s);
|
---|
19 | virtual int SVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt);
|
---|
20 |
|
---|
21 | //! Set the workspace size factor for LAPACK routines
|
---|
22 | inline void SetWorkSpaceSizeFactor(int f = 2)
|
---|
23 | { wspace_size_factor = (f > 1) ? f : 1; }
|
---|
24 |
|
---|
25 | //! Returns the workspace size factor
|
---|
26 | inline int GetWorkSpaceSizeFactor()
|
---|
27 | { return wspace_size_factor; }
|
---|
28 |
|
---|
29 | private:
|
---|
30 | int SVDDriver(TArray<T>& a, TArray<T> & s,
|
---|
31 | TArray<T>* up=NULL, TArray<T> * vtp=NULL);
|
---|
32 |
|
---|
33 | int wspace_size_factor;
|
---|
34 | };
|
---|
35 |
|
---|
36 | /*! \ingroup LinAlg
|
---|
37 | \fn LapackLinSolve(TArray<T>&, TArray<T> &)
|
---|
38 | \brief Solves the linear system A*X = B using LapackServer.
|
---|
39 | */
|
---|
40 | template <class T>
|
---|
41 | inline int LapackLinSolve(TArray<T>& a, TArray<T> & b)
|
---|
42 | { LapackServer<T> lps; return( lps.LinSolve(a, b) ); }
|
---|
43 |
|
---|
44 | template <class T>
|
---|
45 | inline int LapackLeastSquareSolve(TArray<T>& a, TArray<T> & b)
|
---|
46 | { LapackServer<T> lps; return( lps.LeastSquareSolve(a, b) ); }
|
---|
47 |
|
---|
48 | /*! \ingroup LinAlg
|
---|
49 | \fn LapackSVD(TArray<T>&, TArray<T> &)
|
---|
50 | \brief SVD decomposition using LapackServer.
|
---|
51 | */
|
---|
52 | template <class T>
|
---|
53 | inline int LapackSVD(TArray<T>& a, TArray<T> & s)
|
---|
54 | { LapackServer<T> lps; return( lps.SVD(a, s) ); }
|
---|
55 |
|
---|
56 |
|
---|
57 | /*! \ingroup LinAlg
|
---|
58 | \fn LapackSVD(TArray<T>&, TArray<T> &, TArray<T> &, TArray<T> &)
|
---|
59 | \brief SVD decomposition using LapackServer.
|
---|
60 | */
|
---|
61 | template <class T>
|
---|
62 | inline int LapackSVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt)
|
---|
63 | { LapackServer<T> lps; return( lps.SVD(a, s, u, vt) ); }
|
---|
64 |
|
---|
65 |
|
---|
66 | } // Fin du namespace
|
---|
67 |
|
---|
68 | #endif
|
---|