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

Last change on this file since 2556 was 2556, checked in by cmv, 21 years ago
  • Introduction de l'interface Lapack d'inversion des matrices symetriques
  • Introduction de l'interface Lapack de recherche de valeurs et vecteurs propres (cas general, symetrique et hermitique)
  • Introduction d'un fonction d'interface pour le calculateur de workspace (ilaenv_)
  • Commentaires sur les diverses methodes et sur les matrices FORTRAN
  • Pour tester cf Tests/tsttminv.cc

(cmv, 21/07/04)

File size: 3.2 KB
RevLine 
[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]8namespace SOPHYA {
[775]9
[814]10template <class T>
11class LapackServer {
12public:
[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
34private:
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]46template <class T>
[1042]47inline 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*/
54template <class T>
55inline 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]62template <class T>
63inline 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]70template <class T>
71inline 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]79template <class T>
80inline 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*/
88template <class T>
89inline 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*/
96template <class T>
97inline 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
Note: See TracBrowser for help on using the repository browser.