This is a question about setting proper tolerance ("abstol") for convergence of eigenvalue calculation with LAPACKE_zheevx() function in C++.
When LAPACKE_zheev() fails to converge when calculating eigenvalues/eigenvectors with the default value of "abstol" (i.e. abstol=-1), the LAPACK manual says to set abstol=2*DLAMCH('S'). However, DLAMCH is Fortran function and I use C++ which does not recognize it as a valid C++ function. Could anyone please help me how to properly set "abstol=2*DLAMCH('S')" when using LAPACK with C++ (i.e. when using LAPACKE)?
Thanks very much in advance!!
Background: LAPACKE is C++ interface for LAPACK (Fortran library for numerical algebra). LAPACKE_zheevx() is LAPACKE's C++ interface for LAPACK's ZHEEVX() function.
Keywords: LAPACK, LAPACKE, C++, ABSTOL, DLAMCH, CONVERGENCE, EIGENVALUES, EIGENVECTORS
I don’t know anything about these libraries, but a bit of Googling reveals there is a corresponding LAPACKE_dlamch()
function:
double LAPACKE_dlamch(char cmach)
So you should be able to just pass LAPACKE_dlamch('S')
as the abstol
(12th) parameter of LAPACKE_zheevx()
:
lapack_int LAPACKE_zheevx (
int matrix_layout,
char jobz,
char range,
char uplo,
lapack_int n,
lapack_complex_double *a,
lapack_int lda,
double vl,
double vu,
lapack_int il,
lapack_int iu,
double abstol,
// ^^^^^^^^^^^^^
lapack_int *m,
double *w,
lapack_complex_double *z,
lapack_int ldz,
lapack_int *ifail
)