?sy(he)evx
Compute a selected range of eigenvalues and eigenvectors (optional) of a symmetric (Hermitian) matrix.
Interface Definition
C Interface:
ssyevx_(const char *jobz, const char *range, const char *uplo, const int *n, float *a, const int *lda, const float *vl, const float *vu, const int *il, const int *iu, const float *abstol, int *m, float *w, float *z,
const int *ldz, float *work, const int *lwork, int *iwork, int *ifail, int *info);
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, int *m, double *w,
double *z, const int *ldz, double *work, const int *lwork, int *iwork, int *ifail, int *info);
cheevx_(const char *jobz, const char *range, const char *uplo, const int *n, kml_complex_float *a, const int *lda, const float *vl, const float *vu, const int *il, const int *iu, const float *abstol, int *m,
float *w, kml_complex_float *z, const int *ldz, kml_complex_float *work, const int *lwork, float *rwork, int *iwork, int *ifail, int *info);
zheevx_(const char *jobz, const char *range, const char *uplo, const int *n, kml_complex_double *a, const int *lda, const double *vl, const double *vu, const int *il, const int *iu, const double *abstol, int *m,
double *w, kml_complex_double *z, const int *ldz, kml_complex_double *work, const int *lwork, double *rwork, int *iwork, int *ifail, int *info);
Fortran Interface:
SSYEVX(JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, LWORK, IWORK, IFAIL, INFO);
DSYEVX(JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, LWORK, IWORK, IFAIL, INFO);
CHEEVX(JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, LWORK, RWORK, IWORK, IFAIL, INFO);
ZHEEVX(JOBZ, RANGE, UPLO, N, A, LDA, VL, VU, IL, IU, ABSTOL, M, W, Z, LDZ, WORK, LWORK, RWORK, IWORK, IFAIL, INFO);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
jobz |
Character |
|
Input |
range |
Character |
|
Input |
uplo |
Character |
|
Input |
n |
Integer |
Dimension of matrix A. |
Input |
a |
|
Matrix A. |
Input/Output |
lda |
Integer |
Leading dimension of matrix A. |
Input |
vl |
|
|
Input |
vu |
Single-/Double-precision floating point |
|
Input |
il |
Integer |
|
Input |
iu |
Integer |
|
Input |
abstol |
Single-/Double-precision floating point |
Absolute error tolerance for eigenvalues. |
Input |
m |
Integer |
Number of eigenvalues to compute. If range = A, m = n. If range = I, m = iu - il + 1. |
Output |
w |
Single-/Double-precision floating point |
A floating-point array of length n, where the first m elements store the computed eigenvalues in ascending order. |
Output |
z |
|
|
Output |
ldz |
Integer |
Leading dimension of z. |
Input |
work |
|
Workspace array. After this function is called, work[0] returns the optimal lwork value. |
Output |
lwork |
Integer |
Length of the work array. If lwork = -1, the optimal size of the work array is queried and the result is saved in work[0]. If lwork ≠ -1:
|
Input |
rwork (only for complex types) |
|
Works array of length 7*n, used for temporary data storage. |
Output |
iwork |
Integer |
Workspace array of length 5*n, used for temporary data storage. |
Output |
ifail |
Integer |
Output array, indicating which eigenvalues failed to converge. |
Output |
info |
Integer |
Function execution status. 0: The execution is successful. Smaller than 0: The value of the -info-th parameter is invalid. Greater than 0: The info-th eigenvalue failed to converge. |
Output |
Dependencies
#include "klapack.h"
Examples
char jobz = 'V';
char range = 'A';
char uplo = 'L';
int n = 5;
double a[] = {7.027, 8.710, 1.015, 6.929, 7.584,
8.710, 0.839, 2.469, 3.850, 0.559,
1.015, 2.469, 1.930, 6.761, 7.207,
6.929, 3.850, 6.761, 4.344, 4.804,
7.584, 0.559, 7.207, 4.804, 6.177};
int lda = 5;
double vl = 0.0;
double vu = 1.0;
int il = 1;
int iu = 2;
double abstol = 1e-5;
int m = 5;
double w[5];
double z[25];
int ldz = 5;
double work[40];
int lwork = 40;
int iwork[25];
int ifail[5];
int info = 0;
dsyevx_(&jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il, &iu, &abstol, &m, w, z, &ldz, work, lwork, iwork, ifail, &info);
/*
* Output:
* Eigenvalues (in w)
* -8.842215 -3.341090 1.188784 6.204987 25.106533
* Eigenvectors (in a)
* 0.540506 -0.491256 0.488567 -0.240992 -0.412003
* -0.161613 0.597461 0.498950 -0.606212 0.021854
* -0.305939 0.243208 0.345443 0.583128 -0.622802
* 0.523491 0.488212 -0.521315 -0.103794 -0.452839
* -0.560440 -0.322810 -0.348211 -0.472883 -0.486653
*/
Fortran Interface:
CHARACTER :: jobz = "V"
CHARACTER :: range = "A"
CHARACTER :: uplo = "L"
PARAMETER (n = 5)
PARAMETER (lda = 5)
PARAMETER (ldz = 5)
PARAMETER (lwork = 40)
PARAMETER (m = 5)
REAL(8) :: a(lda, n)
REAL(8) :: vl = 0.0
REAL(8) :: vu = 1.0
INTEGER :: il = 1
INTEGER :: iu = 2
REAL(8) :: abstol = 1e-5
REAL(8) :: w(m)
REAL(8) :: z(ldz, n)
REAL(8) :: work(lwork)
INTEGER :: iwork(5*n)
INTEGER :: info = 0
DATA a / 7.027, 8.710, 1.015, 6.929, 7.584,
8.710, 0.839, 2.469, 3.850, 0.559,
1.015, 2.469, 1.930, 6.761, 7.207,
6.929, 3.850, 6.761, 4.344, 4.804,
7.584, 0.559, 7.207, 4.804, 6.177 /
EXTERNAL DSYEVX
CALL DSYEVX(jobz, range, uplo, n, a, lda, vl, vu, il, iu, abstol, m, w, z, ldz, work, lwork, iwork, ifail, info)