source: Sophya/trunk/SophyaExt/LinAlg/intflapack.h@ 2554

Last change on this file since 2554 was 2554, checked in by cmv, 21 years ago

intro inversion matrices symetriques + ilaenv (cmv 19/07/04)

File size: 2.4 KB
Line 
1#ifndef IntfLapack_H_SEEN
2#define IntfLapack_H_SEEN
3
4#include "machdefs.h"
5#include "tarray.h"
6
7namespace SOPHYA {
8
9template <class T>
10class LapackServer {
11public:
12 LapackServer();
13 virtual ~LapackServer();
14
15 virtual int LinSolve(TArray<T>& a, TArray<T> & b);
16 virtual int LinSolveSym(TArray<T>& a, TArray<T> & b);
17 virtual int LeastSquareSolve(TArray<T>& a, TArray<T> & b);
18
19 virtual int SVD(TArray<T>& a, TArray<T> & s);
20 virtual int SVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt);
21
22 //! Set the workspace size factor for LAPACK routines
23 inline void SetWorkSpaceSizeFactor(int f = 2)
24 { wspace_size_factor = (f > 1) ? f : 1; }
25
26 //! Returns the workspace size factor
27 inline int GetWorkSpaceSizeFactor()
28 { return wspace_size_factor; }
29
30private:
31 int SVDDriver(TArray<T>& a, TArray<T> & s,
32 TArray<T>* up=NULL, TArray<T> * vtp=NULL);
33 int_4 ilaenv_en_C(int_4 ispec,char *name,char *opts,int_4 n1,int_4 n2,int_4 n3,int_4 n4);
34
35 int wspace_size_factor;
36};
37
38/*! \ingroup LinAlg
39 \fn LapackLinSolve(TArray<T>&, TArray<T> &)
40 \brief Solves the linear system A*X = B using LapackServer.
41*/
42template <class T>
43inline int LapackLinSolve(TArray<T>& a, TArray<T> & b)
44{ LapackServer<T> lps; return( lps.LinSolve(a, b) ); }
45
46/*! \ingroup LinAlg
47 \fn LapackLinSolveSym(TArray<T>&, TArray<T> &)
48 \brief Solves the linear system A*X = B with A symetric using LapackServer.
49*/
50template <class T>
51inline int LapackLinSolveSym(TArray<T>& a, TArray<T> & b)
52{ LapackServer<T> lps; return( lps.LinSolveSym(a, b) ); }
53
54/*! \ingroup LinAlg
55 \fn LapackLeastSquareSolve(TArray<T>&, TArray<T> &)
56 \brief Solves the linear least squares problem A*X - B
57*/
58template <class T>
59inline int LapackLeastSquareSolve(TArray<T>& a, TArray<T> & b)
60{ LapackServer<T> lps; return( lps.LeastSquareSolve(a, b) ); }
61
62/*! \ingroup LinAlg
63 \fn LapackSVD(TArray<T>&, TArray<T> &)
64 \brief SVD decomposition using LapackServer.
65*/
66template <class T>
67inline int LapackSVD(TArray<T>& a, TArray<T> & s)
68{ LapackServer<T> lps; return( lps.SVD(a, s) ); }
69
70
71/*! \ingroup LinAlg
72 \fn LapackSVD(TArray<T>&, TArray<T> &, TArray<T> &, TArray<T> &)
73 \brief SVD decomposition using LapackServer.
74*/
75template <class T>
76inline int LapackSVD(TArray<T>& a, TArray<T> & s, TArray<T> & u, TArray<T> & vt)
77{ LapackServer<T> lps; return( lps.SVD(a, s, u, vt) ); }
78
79
80} // Fin du namespace
81
82#endif
Note: See TracBrowser for help on using the repository browser.