ARTS  2.3.1285(git:92a29ea9-dirty)
lapack.h
Go to the documentation of this file.
1 
12 #ifndef LAPACK_H
13 #define LAPACK_H
14 
15 #include <complex>
16 #include <vector>
17 
18 #include "matpack.h"
19 
20 namespace lapack_help {
21 
23  template <typename T> struct Inverse {
24  mutable int n;
25  mutable int lwork;
26  mutable std::vector<T> work;
27  mutable std::vector<int> ipiv;
28 
29  explicit Inverse(Index N) noexcept : n(int(N)), lwork(int(N)), work(N), ipiv(N) {}
30 
31  bool resize_if_smaller(Index N) const {
32  if (N>n) {
33  n=int(N);
34  lwork=int(N);
35  work.resize(N);
36  ipiv.resize(N);
37  return true;
38  } else {
39  return false;
40  }
41  }
42 
43  int* size() const noexcept {return &n;}
44  int* lsize() const noexcept {return &lwork;}
45  T* workdata() const noexcept {return work.data();}
46  int* ipivdata() const noexcept {return ipiv.data();}
47  };
48 };
49 
50 namespace lapack {
51 
53 
65 extern "C" void dgetrf_(
66  int *m, int *n, double *A, int *lda, int *ipiv, int *info);
67 
68 extern "C" void zgetrf_(
69  int *m, int *n, std::complex<double> *A, int *lda, int *ipiv, int *info);
70 
72 
94 extern "C" void dgetrs_(char *trans,
95  int *n,
96  int *nrhs,
97  double *A,
98  int *lda,
99  int *ipiv,
100  double *b,
101  int *ldb,
102  int *info);
103 
104 //
106 
119 extern "C" void dgetri_(int *n,
120  double *A,
121  int *lda,
122  int *ipiv,
123  double *work,
124  int *lwork,
125  int *info);
126 
127 extern "C" void zgetri_(int *n,
128  std::complex<double> *A,
129  int *lda,
130  int *ipiv,
131  std::complex<double> *work,
132  int *lwork,
133  int *info);
134 
136 
149 extern "C" void ilaenv_(
150  int *ispec, char *name, char *opts, int *n1, int *n2, int *n3, int *n4);
151 
153 
190 extern "C" void dgesvx_(char *fact,
191  char *trans,
192  int *n,
193  int *nrhs,
194  double *A,
195  int *lda,
196  double *AF,
197  int *ldaf,
198  int *ipiv,
199  char *equed,
200  double *R,
201  double *C,
202  double *B,
203  int *ldb,
204  double *X,
205  int *ldx,
206  double *RCOND,
207  double *FERR,
208  double *BERR,
209  double *WORK,
210  int *IWORK,
211  int *info);
212 
213 /* Computes eigenvalues and eigenvectors for the Complex n-by-n Matrix A
214  * Use-case example diag(VR*A*inv(VR)) = W.
215 
216  \param[in] jobvl calculate left eigenvectors if 'V', otherwise 'N'
217  \param[in] jobvl calculate right eigen vectors if 'V', otherwise 'N'
218  \param[in] n Dimensionality of the system.
219  \param[in,out] A matrix to find eigenvalues and eigenvectors. Changed in execution.
220  \param[in] lda The leading dimension of A.
221  \param[out] W/WR/WI The eigenvalues in a vector (double matrix can have complex eigenvalues)
222  \param[out] VL The left eigenvectors of A.
223  \param[in] ldvl The leading dimension of VL.
224  \param[out] VR The right eigenvectors of A.
225  \param[in] ldvr The leading dimension of VR.
226  \param[out] WORK
227  \param[out] IWORK
228  \param[out] RWORK
229  \param[out] info
230  */
231 
232 extern "C" void dgeev_(char *jobvl,
233  char *jobvr,
234  int *n,
235  double *A,
236  int *lda,
237  double *WR,
238  double *WI,
239  double *VL,
240  int *ldvl,
241  double *VR,
242  int *ldvr,
243  double *work,
244  int *lwork,
245  double *rwork,
246  int *info);
247 
248 extern "C" void zgeev_(char *jobvl,
249  char *jobvr,
250  int *n,
251  std::complex<double> *A,
252  int *lda,
253  std::complex<double> *W,
254  std::complex<double> *VL,
255  int *ldvl,
256  std::complex<double> *VR,
257  int *ldvr,
258  std::complex<double> *work,
259  int *lwork,
260  double *rwork,
261  int *info);
262 } // namespace lapack
263 
264 #endif // LAPACK_H
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
T * workdata() const noexcept
Definition: lapack.h:45
bool resize_if_smaller(Index N) const
Definition: lapack.h:31
#define C(a, b)
Definition: Faddeeva.cc:255
void zgeev_(char *jobvl, char *jobvr, int *n, std::complex< double > *A, int *lda, std::complex< double > *W, std::complex< double > *VL, int *ldvl, std::complex< double > *VR, int *ldvr, std::complex< double > *work, int *lwork, double *rwork, int *info)
void dgeev_(char *jobvl, char *jobvr, int *n, double *A, int *lda, double *WR, double *WI, double *VL, int *ldvl, double *VR, int *ldvr, double *work, int *lwork, double *rwork, int *info)
std::vector< T > work
Definition: lapack.h:26
void dgetrs_(char *trans, int *n, int *nrhs, double *A, int *lda, int *ipiv, double *b, int *ldb, int *info)
Solve linear system of equations.
std::vector< int > ipiv
Definition: lapack.h:27
int * ipivdata() const noexcept
Definition: lapack.h:46
Struct cannot be const, but can be passed as const to allow defaults.
Definition: lapack.h:23
Definition: lapack.h:50
Inverse(Index N) noexcept
Definition: lapack.h:29
void zgetrf_(int *m, int *n, std::complex< double > *A, int *lda, int *ipiv, int *info)
int * lsize() const noexcept
Definition: lapack.h:44
void zgetri_(int *n, std::complex< double > *A, int *lda, int *ipiv, std::complex< double > *work, int *lwork, int *info)
int * size() const noexcept
Definition: lapack.h:43
void dgetri_(int *n, double *A, int *lda, int *ipiv, double *work, int *lwork, int *info)
Matrix inversion.
void dgesvx_(char *fact, char *trans, int *n, int *nrhs, double *A, int *lda, double *AF, int *ldaf, int *ipiv, char *equed, double *R, double *C, double *B, int *ldb, double *X, int *ldx, double *RCOND, double *FERR, double *BERR, double *WORK, int *IWORK, int *info)
Solve linear system.
void ilaenv_(int *ispec, char *name, char *opts, int *n1, int *n2, int *n3, int *n4)
Optimal parameters for computation.
void dgetrf_(int *m, int *n, double *A, int *lda, int *ipiv, int *info)
LU decomposition.