|
| 1 | +/** |
| 2 | + * @file lapack.h |
| 3 | + * @brief This is a direct wrapper of some LAPACK routines. |
| 4 | + * \b Column-Major version. |
| 5 | + * Direct wrapping of standard LAPACK routines. (Column-Major, fortran style) |
| 6 | + * |
| 7 | + * @warning For Row-major version, please refer to \c source/source_base/module_external/lapack_connector.h. |
| 8 | + * |
| 9 | + * @note |
| 10 | + * Some slight modification are made to fit the C++ style for overloading purpose. |
| 11 | + * You can find some function with different parameter list than the original LAPACK routine. |
| 12 | + * And some of these parameters are not referred in the function body. They are included just to |
| 13 | + * ensure the same parameter list for overloaded functions with a uniform name. |
| 14 | + */ |
| 15 | + |
1 | 16 | #ifndef BASE_THIRD_PARTY_LAPACK_H_ |
2 | 17 | #define BASE_THIRD_PARTY_LAPACK_H_ |
3 | 18 |
|
|
10 | 25 | #include <base/third_party/hipsolver.h> |
11 | 26 | #endif |
12 | 27 |
|
| 28 | +/// This is a wrapper of some LAPACK routines. |
| 29 | +/// Direct wrapping of standard LAPACK routines. (column major, fortran style) |
| 30 | +/// with some slight modification to fit the C++ style for overloading purpose. |
| 31 | + |
13 | 32 | //Naming convention of lapack subroutines : ammxxx, where |
14 | 33 | //"a" specifies the data type: |
15 | 34 | // - d stands for double |
@@ -46,6 +65,27 @@ void chegvd_(const int* itype, const char* jobz, const char* uplo, const int* n, |
46 | 65 | std::complex<float>* work, int* lwork, float* rwork, int* lrwork, |
47 | 66 | int* iwork, int* liwork, int* info); |
48 | 67 |
|
| 68 | +void ssygvx_(const int* itype, const char* jobz, const char* range, const char* uplo, |
| 69 | + const int* n, float* A, const int* lda, float* B, const int* ldb, |
| 70 | + const float* vl, const float* vu, const int* il, const int* iu, |
| 71 | + const float* abstol, const int* m, float* w, float* Z, const int* ldz, |
| 72 | + float* work, const int* lwork, int* iwork, int* ifail, int* info); |
| 73 | +void dsygvx_(const int* itype, const char* jobz, const char* range, const char* uplo, |
| 74 | + const int* n, double* A, const int* lda, double* B, const int* ldb, |
| 75 | + const double* vl, const double* vu, const int* il, const int* iu, |
| 76 | + const double* abstol, const int* m, double* w, double* Z, const int* ldz, |
| 77 | + double* work, const int* lwork, int* iwork, int* ifail, int* info); |
| 78 | +void chegvx_(const int* itype, const char* jobz, const char* range, const char* uplo, |
| 79 | + const int* n, std::complex<float>* A, const int* lda, std::complex<float>* B, const int* ldb, |
| 80 | + const float* vl, const float* vu, const int* il, const int* iu, |
| 81 | + const float* abstol, const int* m, float* w, std::complex<float>* Z, const int* ldz, |
| 82 | + std::complex<float>* work, const int* lwork, float* rwork, int* iwork, int* ifail, int* info); |
| 83 | +void zhegvx_(const int* itype, const char* jobz, const char* range, const char* uplo, |
| 84 | + const int* n, std::complex<double>* A, const int* lda, std::complex<double>* B, const int* ldb, |
| 85 | + const double* vl, const double* vu, const int* il, const int* iu, |
| 86 | + const double* abstol, const int* m, double* w, std::complex<double>* Z, const int* ldz, |
| 87 | + std::complex<double>* work, const int* lwork, double* rwork, int* iwork, int* ifail, int* info); |
| 88 | + |
49 | 89 | void zhegvd_(const int* itype, const char* jobz, const char* uplo, const int* n, |
50 | 90 | std::complex<double>* a, const int* lda, |
51 | 91 | const std::complex<double>* b, const int* ldb, double* w, |
@@ -190,6 +230,68 @@ void hegvd(const int itype, const char jobz, const char uplo, const int n, |
190 | 230 | iwork, &liwork, &info); |
191 | 231 | } |
192 | 232 |
|
| 233 | +// Note |
| 234 | +// rwork is only needed for complex version |
| 235 | +// and we include rwork in the function parameter list |
| 236 | +// for simplicity of function overloading |
| 237 | +// and unification of function parameter list |
| 238 | +static inline |
| 239 | +void hegvx(const int itype, const char jobz, const char range, const char uplo, const int n, |
| 240 | + float* a, const int lda, float* b, const int ldb, |
| 241 | + const float vl, const float vu, const int il, const int iu, const float abstol, |
| 242 | + const int m, float* w, float* z, const int ldz, |
| 243 | + float* work, const int lwork, float* rwork, int* iwork, int* ifail, int& info) |
| 244 | +{ |
| 245 | + ssygvx_(&itype, &jobz, &range, &uplo, &n, |
| 246 | + a, &lda, b, &ldb, |
| 247 | + &vl, &vu, &il, &iu, |
| 248 | + &abstol, &m, w, z, &ldz, |
| 249 | + work, &lwork, iwork, ifail, &info); |
| 250 | +} |
| 251 | + |
| 252 | +static inline |
| 253 | +void hegvx(const int itype, const char jobz, const char range, const char uplo, const int n, |
| 254 | + double* a, const int lda, double* b, const int ldb, |
| 255 | + const double vl, const double vu, const int il, const int iu, const double abstol, |
| 256 | + const int m, double* w, double* z, const int ldz, |
| 257 | + double* work, const int lwork, double* rwork, int* iwork, int* ifail, int& info) |
| 258 | +{ |
| 259 | + dsygvx_(&itype, &jobz, &range, &uplo, &n, |
| 260 | + a, &lda, b, &ldb, |
| 261 | + &vl, &vu, &il, &iu, |
| 262 | + &abstol, &m, w, z, &ldz, |
| 263 | + work, &lwork, iwork, ifail, &info); |
| 264 | +} |
| 265 | + |
| 266 | +static inline |
| 267 | +void hegvx(const int itype, const char jobz, const char range, const char uplo, const int n, |
| 268 | + std::complex<float>* a, const int lda, std::complex<float>* b, const int ldb, |
| 269 | + const float vl, const float vu, const int il, const int iu, const float abstol, |
| 270 | + const int m, float* w, std::complex<float>* z, const int ldz, |
| 271 | + std::complex<float>* work, const int lwork, float* rwork, int* iwork, int* ifail, int& info) |
| 272 | +{ |
| 273 | + chegvx_(&itype, &jobz, &range, &uplo, &n, |
| 274 | + a, &lda, b, &ldb, |
| 275 | + &vl, &vu, &il, &iu, |
| 276 | + &abstol, &m, w, z, &ldz, |
| 277 | + work, &lwork, rwork, iwork, ifail, &info); |
| 278 | +} |
| 279 | + |
| 280 | +static inline |
| 281 | +void hegvx(const int itype, const char jobz, const char range, const char uplo, const int n, |
| 282 | + std::complex<double>* a, const int lda, std::complex<double>* b, const int ldb, |
| 283 | + const double vl, const double vu, const int il, const int iu, const double abstol, |
| 284 | + const int m, double* w, std::complex<double>* z, const int ldz, |
| 285 | + std::complex<double>* work, const int lwork, double* rwork, int* iwork, int* ifail, int& info) |
| 286 | +{ |
| 287 | + zhegvx_(&itype, &jobz, &range, &uplo, &n, |
| 288 | + a, &lda, b, &ldb, |
| 289 | + &vl, &vu, &il, &iu, |
| 290 | + &abstol, &m, w, z, &ldz, |
| 291 | + work, &lwork, rwork, iwork, ifail, &info); |
| 292 | +} |
| 293 | + |
| 294 | + |
193 | 295 | // wrap function of fortran lapack routine zheevx. |
194 | 296 | static inline |
195 | 297 | void heevx( const int itype, const char jobz, const char range, const char uplo, const int n, |
|
0 commit comments