I am using LAPACKE_chbevd to calculate the eigenvalues and eigenvectors of a matrix, but the results are incorrect.
LAPACKE_chbevd
From LAPACKE_chbevd:-11919.6, -8524.17, -6111.67, -2497.23, 2114.36, 3121.9, 9681.48, 14156.4
The correct eigenvalues should be approximately:
-0.0141504, -0.00595834, -0.0012536, 0.000805093, 0.00987138, 204.135, 7947.25, and 24044.7.
Could you help me verify this? Thank you.
#define N 8 lapack_complex_float h_cov_arm[N * N] = { {4140.65f, -2.24197e-06f}, {137.897f, 3938.01f}, {-158.647f, -1241.86f}, {-1936.52f, 2616.06f}, {-743.871f, 2664.88f}, {623.323f, -4050.98f}, {-1115.17f, 1268.56f}, {-1067.13f, 133.398f}, {137.897f, -3938.01f}, {4154.02f, 3.32665e-06f}, {-1563.14f, -967.872f}, {2961.04f, 2489.75f}, {3325.31f, 1229.58f}, {-3941.03f, -737.05f}, {1463.98f, 2163.99f}, {-995.137f, 1257.28f}, {-158.647f, 1241.86f}, {-1563.14f, 967.872f}, {3843.31f, -2.39818e-07f}, {-2763.36f, 255.503f}, {-2805.64f, 1415.83f}, {1326.26f, 228.303f}, {-3621.11f, -722.38f}, {584.441f, -3733.83f}, {-1936.52f, -2616.06f}, {2961.04f, -2489.75f}, {-2763.36f, -255.503f}, {4067.95f, -3.1887e-06f}, {3742.5f, -1311.93f}, {-2992.45f, 1599.3f}, {3214.86f, 1165.23f}, {-611.432f, 2481.71f}, {-743.871f, -2664.88f}, {3325.31f, -1229.58f}, {-2805.64f, -1415.83f}, {3742.5f, 1311.94f}, {4021.9f, -3.66673e-06f}, {-2973.91f, 342.678f}, {2854.54f, 2360.54f}, {-1725.97f, 2476.39f}, {623.323f, 4050.98f}, {-3941.03f, 737.05f}, {1326.26f, -228.303f}, {-2992.45f, -1599.3f}, {-2973.91f, -342.678f}, {4204.25f, 3.96076e-06f}, {-1613.83f, -1059.15f}, {-198.559f, -1266.46f}, {-1115.17f, -1268.56f}, {1463.98f, -2163.99f}, {-3621.11f, 722.38f}, {3214.86f, -1165.23f}, {2854.54f, -2360.54f}, {-1613.83f, 1059.15f}, {3900.07f, -1.04732e-06f}, {171.296f, 3648.69f}, {-1067.13f, -133.398f}, {-995.137f, -1257.28f}, {584.441f, 3733.84f}, {-611.432f, -2481.71f}, {-1725.97f, -2476.39f}, {-198.559f, 1266.46f}, {171.296f, -3648.69f}, {3863.89f, -2.28193e-06f} }; void ver_armpl(lapack_complex_float *cov_arm) { float w[N]; lapack_complex_float z[N*N]; armpl_int_t stat = LAPACKE_chbevd(LAPACK_ROW_MAJOR, 'V', 'U', N, N-1, cov_arm, N, w, z, N); std::cout << stat << std::endl; std::cout<<"LAPACK:"<<std::endl; for (int i=0;i<N;++i) { std::cout<<w[i]<<std::endl; } }
Hi Weiwei,I have executed your code using the Netlib reference implementation, and the output is:
-11919.6 -8524.17 -6111.67 -2497.23 2114.36 3121.9 9681.48 14156.4
Which is consistent with your output using ArmPL. This suggests, the issue reported is not related to ArmPL. However, When I have computed the eigenvalues using CHEEVD with your matrix as an input, I got a result similar to your expected result. This suggests the expected results have been computed using CHEEVD.
The difference in outputs between CHBEVD and CHEEVD occurs because you're using different matrix formats and possibly not converting the matrix correctly.Note that when using a band matrix, if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j). Ensure this conversion is in case the input matrix is in general format. Below the a note from the ARM PL manual on use to set the input matrix AB.
AB Input and output parameter. AB is COMPLEX AB is an array, dimension (LDAB, N). On entry, the upper or lower triangle of the Hermitian band matrix A, stored in the first KD+1 rows of the array. The j-th column of A is stored in the j-th column of the array AB as follows: if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). On exit, AB is overwritten by values generated during the reduction to tridiagonal form. If UPLO = 'U', the first superdiagonal and the diagonal of the tridiagonal matrix T are returned in rows KD and KD+1 of AB, and if UPLO = 'L', the diagonal and first subdiagonal of T are returned in the first two rows of AB.
This notation assumes column major. It should be adjusted for row major.
Hi Weiwei,If you have more questions related to the eigenvalue problem solver, or ArmPL in general, please contact us directly at support-hpc-sw@arm.com Best