diff --git a/source/source_base/module_external/lapack_connector.h b/source/source_base/module_external/lapack_connector.h index da90261dd0..ebc558e409 100644 --- a/source/source_base/module_external/lapack_connector.h +++ b/source/source_base/module_external/lapack_connector.h @@ -241,9 +241,8 @@ void zhegvx_i(const int* itype, // Class LapackConnector provide the connector to fortran lapack routine. // The entire function in this class are static and inline function. // Usage example: LapackConnector::functionname(parameter list). -class LapackConnector +namespace LapackConnector { -private: // Transpose the std::complex matrix to the fortran-form real-std::complex array. static inline std::complex* transpose(const ModuleBase::ComplexMatrix& a, const int n, const int lda) @@ -350,7 +349,6 @@ class LapackConnector } } -public: // wrap function of fortran lapack routine zheev. static inline void zheev( const char jobz, @@ -490,5 +488,5 @@ class LapackConnector const char trans_changed = change_trans_NC(trans); cherk_(&uplo_changed, &trans_changed, &n, &k, &alpha, A, &lda, &beta, C, &ldc); } -}; +} // namespace LapackConnector #endif // LAPACK_CONNECTOR_HPP diff --git a/source/source_base/module_external/lapack_wrapper.h b/source/source_base/module_external/lapack_wrapper.h deleted file mode 100644 index a797c31f6d..0000000000 --- a/source/source_base/module_external/lapack_wrapper.h +++ /dev/null @@ -1,494 +0,0 @@ -#ifndef LAPACK_HPP -#define LAPACK_HPP - -/// This is a wrapper of some LAPACK routines. -/// Direct wrapping of standard LAPACK routines. (column major, fortran style) -/// including: -/// 1. hegvd: compute all the eigenvalues and eigenvectors of a generalized Hermitian-definite eigenproblem -/// 2. heevx: compute the first m eigenvalues and their corresponding eigenvectors of a generalized Hermitian-definite eigenproblem -/// 3. hegvx: compute the first m eigenvalues and their corresponding eigenvectors of a generalized Hermitian-definite eigenproblem -/// 4. hegv: compute all the eigenvalues and eigenvectors of a generalized Hermitian-definite eigenproblem - - -#include -extern "C" -{ - // ================================================================================= - // gvd: - void dsygvd_(const int* itype, const char* jobz, const char* uplo, const int* n, - double* a, const int* lda, - const double* b, const int* ldb, double* w, - double* work, int* lwork, - int* iwork, int* liwork, int* info); - - void chegvd_(const int* itype, const char* jobz, const char* uplo, const int* n, - std::complex* a, const int* lda, - const std::complex* b, const int* ldb, float* w, - std::complex* work, int* lwork, float* rwork, int* lrwork, - int* iwork, int* liwork, int* info); - - void zhegvd_(const int* itype, const char* jobz, const char* uplo, const int* n, - std::complex* a, const int* lda, - const std::complex* b, const int* ldb, double* w, - std::complex* work, int* lwork, double* rwork, int* lrwork, - int* iwork, int* liwork, int* info); - // ================================================================================= - - // ================================================================================= - // evx - void dsyevx_(const char* jobz, const char* range, const char* uplo, const int* n, - double* a, const int* lda, - const double* vl, const double* vu, const int* il, const int* iu, const double* abstol, - const int* m, double* w, double* z, const int* ldz, - double* work, const int* lwork, double* rwork, int* iwork, int* ifail, int* info); - - void cheevx_(const char* jobz, const char* range, const char* uplo, const int* n, - std::complex *a, const int* lda, - const float* vl, const float* vu, const int* il, const int* iu, const float* abstol, - const int* m, float* w, std::complex *z, const int *ldz, - std::complex *work, const int* lwork, float* rwork, int* iwork, int* ifail, int* info); - - void zheevx_(const char* jobz, const char* range, const char* uplo, const int* n, - std::complex *a, const int* lda, - const double* vl, const double* vu, const int* il, const int* iu, const double* abstol, - const int* m, double* w, std::complex *z, const int *ldz, - std::complex *work, const int* lwork, double* rwork, int* iwork, int* ifail, int* info); - // ================================================================================= - - - // ================================================================================= - // gvx - void dsygvx_(const int* itype, const char* jobz, const char* range, const char* uplo, - const int* n, double* A, const int* lda, double* B, const int* ldb, - const double* vl, const double* vu, const int* il, const int* iu, - const double* abstol, const int* m, double* w, double* Z, const int* ldz, - double* work, const int* lwork, int* iwork, int* ifail, int* info); - - void chegvx_(const int* itype,const char* jobz,const char* range,const char* uplo, - const int* n,std::complex *a,const int* lda,std::complex *b, - const int* ldb,const float* vl,const float* vu,const int* il, - const int* iu,const float* abstol,const int* m,float* w, - std::complex *z,const int *ldz,std::complex *work,const int* lwork, - float* rwork,int* iwork,int* ifail,int* info); - - void zhegvx_(const int* itype,const char* jobz,const char* range,const char* uplo, - const int* n,std::complex *a,const int* lda,std::complex *b, - const int* ldb,const double* vl,const double* vu,const int* il, - const int* iu,const double* abstol,const int* m,double* w, - std::complex *z,const int *ldz,std::complex *work,const int* lwork, - double* rwork,int* iwork,int* ifail,int* info); - // ================================================================================= - - // ================================================================================= - // gv - void zhegv_(const int* itype,const char* jobz,const char* uplo,const int* n, - std::complex* a,const int* lda,std::complex* b,const int* ldb, - double* w,std::complex* work,int* lwork,double* rwork,int* info); - void chegv_(const int* itype,const char* jobz,const char* uplo,const int* n, - std::complex* a,const int* lda,std::complex* b,const int* ldb, - float* w,std::complex* work,int* lwork,float* rwork,int* info); - void dsygv_(const int* itype, const char* jobz,const char* uplo, const int* n, - double* a,const int* lda,double* b,const int* ldb, - double* w,double* work,int* lwork,int* info); - // ================================================================================= - -} - -class LapackWrapper -{ - private: - public: - // wrap function of fortran lapack routine zhegvd. (pointer version) - static inline void xhegvd(const int itype, - const char jobz, - const char uplo, - const int n, - double* a, - const int lda, - const double* b, - const int ldb, - double* w, - double* work, - int lwork, - double* rwork, - int lrwork, - int* iwork, - int liwork, - int& info) - { - // call the fortran routine - dsygvd_(&itype, &jobz, &uplo, &n, a, &lda, b, &ldb, w, work, &lwork, iwork, &liwork, &info); - } - - // wrap function of fortran lapack routine zhegvd. (pointer version) - static inline void xhegvd(const int itype, - const char jobz, - const char uplo, - const int n, - std::complex* a, - const int lda, - const std::complex* b, - const int ldb, - float* w, - std::complex* work, - int lwork, - float* rwork, - int lrwork, - int* iwork, - int liwork, - int& info) - { - // call the fortran routine - chegvd_(&itype, &jobz, &uplo, &n, a, &lda, b, &ldb, w, work, &lwork, rwork, &lrwork, iwork, &liwork, &info); - } - - // wrap function of fortran lapack routine zhegvd. - static inline void xhegvd(const int itype, - const char jobz, - const char uplo, - const int n, - std::complex* a, - const int lda, - const std::complex* b, - const int ldb, - double* w, - std::complex* work, - int lwork, - double* rwork, - int lrwork, - int* iwork, - int liwork, - int& info) - { - // call the fortran routine - zhegvd_(&itype, &jobz, &uplo, &n, a, &lda, b, &ldb, w, work, &lwork, rwork, &lrwork, iwork, &liwork, &info); - } - - // wrap function of fortran lapack routine dsyevx. - static inline void xheevx(const int itype, - const char jobz, - const char range, - const char uplo, - const int n, - double* a, - const int lda, - const double vl, - const double vu, - const int il, - const int iu, - const double abstol, - const int m, - double* w, - double* z, - const int ldz, - double* work, - const int lwork, - double* rwork, - int* iwork, - int* ifail, - int& info) - { - dsyevx_(&jobz, - &range, - &uplo, - &n, - a, - &lda, - &vl, - &vu, - &il, - &iu, - &abstol, - &m, - w, - z, - &ldz, - work, - &lwork, - rwork, - iwork, - ifail, - &info); - } - - // wrap function of fortran lapack routine cheevx. - static inline void xheevx(const int itype, - const char jobz, - const char range, - const char uplo, - const int n, - std::complex* a, - const int lda, - const float vl, - const float vu, - const int il, - const int iu, - const float abstol, - const int m, - float* w, - std::complex* z, - const int ldz, - std::complex* work, - const int lwork, - float* rwork, - int* iwork, - int* ifail, - int& info) - { - cheevx_(&jobz, - &range, - &uplo, - &n, - a, - &lda, - &vl, - &vu, - &il, - &iu, - &abstol, - &m, - w, - z, - &ldz, - work, - &lwork, - rwork, - iwork, - ifail, - &info); - } - - // wrap function of fortran lapack routine zheevx. - static inline void xheevx(const int itype, - const char jobz, - const char range, - const char uplo, - const int n, - std::complex* a, - const int lda, - const double vl, - const double vu, - const int il, - const int iu, - const double abstol, - const int m, - double* w, - std::complex* z, - const int ldz, - std::complex* work, - const int lwork, - double* rwork, - int* iwork, - int* ifail, - int& info) - { - zheevx_(&jobz, - &range, - &uplo, - &n, - a, - &lda, - &vl, - &vu, - &il, - &iu, - &abstol, - &m, - w, - z, - &ldz, - work, - &lwork, - rwork, - iwork, - ifail, - &info); - } - - // wrap function of fortran lapack routine xhegvx ( pointer version ). - static inline void xhegvx(const int itype, - const char jobz, - const char range, - const char uplo, - const int n, - std::complex* a, - const int lda, - std::complex* b, - const int ldb, - const float vl, - const float vu, - const int il, - const int iu, - const float abstol, - const int m, - float* w, - std::complex* z, - const int ldz, - std::complex* work, - const int lwork, - float* rwork, - int* iwork, - int* ifail, - int& info) - { - chegvx_(&itype, - &jobz, - &range, - &uplo, - &n, - a, - &lda, - b, - &ldb, - &vl, - &vu, - &il, - &iu, - &abstol, - &m, - w, - z, - &ldz, - work, - &lwork, - rwork, - iwork, - ifail, - &info); - } - - // wrap function of fortran lapack routine xhegvx ( pointer version ). - static inline void xhegvx(const int itype, - const char jobz, - const char range, - const char uplo, - const int n, - std::complex* a, - const int lda, - std::complex* b, - const int ldb, - const double vl, - const double vu, - const int il, - const int iu, - const double abstol, - const int m, - double* w, - std::complex* z, - const int ldz, - std::complex* work, - const int lwork, - double* rwork, - int* iwork, - int* ifail, - int& info) - { - zhegvx_(&itype, - &jobz, - &range, - &uplo, - &n, - a, - &lda, - b, - &ldb, - &vl, - &vu, - &il, - &iu, - &abstol, - &m, - w, - z, - &ldz, - work, - &lwork, - rwork, - iwork, - ifail, - &info); - } - // wrap function of fortran lapack routine xhegvx ( pointer version ). - static inline void xhegvx(const int itype, - const char jobz, - const char range, - const char uplo, - const int n, - double* a, - const int lda, - double* b, - const int ldb, - const double vl, - const double vu, - const int il, - const int iu, - const double abstol, - const int m, - double* w, - double* z, - const int ldz, - double* work, - const int lwork, - double* rwork, - int* iwork, - int* ifail, - int& info) - { - dsygvx_(&itype, &jobz, &range, &uplo, &n, a, &lda, b, &ldb, &vl, - &vu, &il, &iu, &abstol, &m, w, z, &ldz, work, &lwork, iwork, ifail, &info); - } - - // wrap function of fortran lapack routine xhegvx ( pointer version ). - static inline void xhegv(const int itype, - const char jobz, - const char uplo, - const int n, - double* a, - const int lda, - double* b, - const int ldb, - double* w, - double* work, - int lwork, - double* rwork, - int& info) - { - // TODO - } - - // wrap function of fortran lapack routine xhegvx ( pointer version ). - static inline void xhegv(const int itype, - const char jobz, - const char uplo, - const int n, - std::complex* a, - const int lda, - std::complex* b, - const int ldb, - float* w, - std::complex* work, - int lwork, - float* rwork, - int& info) - { - // TODO - } - // wrap function of fortran lapack routine xhegvx ( pointer version ). - static inline void xhegv(const int itype, - const char jobz, - const char uplo, - const int n, - std::complex* a, - const int lda, - std::complex* b, - const int ldb, - double* w, - std::complex* work, - int lwork, - double* rwork, - int& info) - { - zhegv_(&itype, &jobz, &uplo, &n, a, &lda, b, &ldb, w, work, &lwork, rwork, &info); - } -}; -#endif // LAPACK_HPP \ No newline at end of file