Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Smallest eigenvalue given by dsyevr

Xylam
Beginner
1,979 Views

Hi I have been trying out LAPACKE_dsyevr using the example from https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_dsyevr_row.c.htm

This works perfectly fine for finding 3 eigenvalues. 

Now when I modify the 'NSELECT' to be 5 (finding all 5 eigenvalues), the program gives me the wrong smallest eigenvalue, though the eigenvector corresponding to the smallest eigenvalue is correct. 

I have also tried using 'A' as RANGE

(instead of 'I', i.e. info = LAPACKE_dsyevr( LAPACK_ROW_MAJOR, 'V', 'A', 'U', n, a, lda, vl, vu, il, iu, abstol, &m, w, z, ldz, isuppz ));

this gives me the same output as before.

The only remedy is perhaps using 'V' as RANGE, in this case when I put 'vl' to be 0 and 'vu' to be 10, I get the correct answer.

Am I doing something wrong? Any help is much appreciated, thanks!! :) 

0 Kudos
9 Replies
mecej4
Honored Contributor III
1,979 Views

I tried the example code for dsyevr_row with the 19.0.4 compilers and MKL 2019.0.4, after changing NSELECT to 5, and the output eigenvalues agreed with those given by Matlab for the same matrix:

  0.43   2.14   3.37   4.28   6.93

Which compiler did you use, and are you using IA32, LP64 or ILP64 libraries?

0 Kudos
Gennady_F_Intel
Moderator
1,979 Views

no problem with MKL 2019 u3 either.

win 10, 64 bit, static linking, LP64 API

Selected eigenvalues
   0.00   0.00   3.37   4.28   6.93

 Selected eigenvectors (stored columnwise)
  -0.98  -0.01  -0.08  -0.01   0.18
   0.01   0.02  -0.93   0.03  -0.36
   0.04  -0.69  -0.07  -0.71   0.10
  -0.18   0.19   0.31  -0.35  -0.84
   0.07   0.69  -0.13  -0.61   0.35

 

0 Kudos
Gennady_F_Intel
Moderator
1,979 Views

set MKL_VERBOSE=1

LAPACKE_dsyevr (row-major, high-level) Example Program Results
MKL_VERBOSE Intel(R) MKL 2019.0 Update 3 Product build 20190125 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions 2 (Intel(R) AVX2) enabled processors, Win 2.60GHz cdecl intel_thread
MKL_VERBOSE DSYEVR(V,I,U,5,0000005A475FF880,5,0000005A475FF5F8,0000005A475FF600,1,5,0000005A475FF618,0,0000005A475FF960,0000005A475FF7B0,5,0000005A475FF948,0000005A475FF690,-1,0000005A475FF6A0,-1,0) 16.65ms CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:2
MKL_VERBOSE DSYEVR(V,I,U,5,000001AC3249EE80,5,0000005A475FF5F8,0000005A475FF600,1,5,0000005A475FF618,5,0000005A475FF960,000001AC3249F000,5,0000005A475FF948,000001AC3248C600,130,000001AC3248C480,50,0) 267.96us CNR:OFF Dyn:1 FastMM:1 TID:0  NThr:2

0 Kudos
mecej4
Honored Contributor III
1,979 Views

Gennady F. (Blackbelt) wrote:

no problem with MKL 2019 u3 either.

win 10, 64 bit, static linking, LP64 API

Selected eigenvalues
   0.00   0.00   3.37   4.28   6.93 

Gennady, the first two eigenvalues that you obtained are both zero, and do not agree with the results that I stated. In fact, it is those two zero eigenvalues that the original post complains about.

Xylam, please state the version of MKL that you used, the version of the compiler used and the options used to compile.

0 Kudos
mecej4
Honored Contributor III
1,979 Views

By comparing the example source code (link given in #1) with the file lapacke_dsyevr_row.c that came with PS2019U1, I see the following possible bugs in the former:

  1. The variables vl and vu are left undefined, instead of being set to 0 (this is not really an error, since the documentation states that when the third argument is 'I' the values of vl and vu are not used; however, the lack of initialization causes the compiler to issue error messages, and that is probably  best avoided in example code).
  2. The array isuppz is of size N, instead of 2*N, as the documentation states (https://software.intel.com/sites/default/files/mkl-2019-developer-reference-c_1.pdf , p. 947). This is probably the cause of the error, although it may be possible that the required array size was just N in some older edition of MKL. The source code at https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_dsyevr_row.c.htm should be corrected.

The year 2015 is listed in the comments in the file linked to in #1. I find that with PS2016 and PS2017 the smaller array size appears to be sufficient and gives correct eigenvalues, whereas with PS2018 and PS2019 it is not sufficient and gives incorrect eigenvalues..

0 Kudos
Xylam
Beginner
1,979 Views

Hi thanks for the reply. I'm using MKL 2018.0.3 and with lp64 options.

Does it mean I need to update my MKL version to get rid of this error? Thanks!

0 Kudos
mecej4
Honored Contributor III
1,979 Views

No, what you need to do is to size the array arguments as prescribed in the MKL reference for the version of the software that you have. You have MKL 2018. So, see the manual for MKL 2018. Do not take an MKL 2015 example code and expect it to work with MKL 2018.

If you declare the array in question as MKL_INT isuppz[2*N], that should take care of the problem for MKL 2015 to MKL 2019.

0 Kudos
Xylam
Beginner
1,979 Views

Thank you very much for all the help! This solves my problem :)

0 Kudos
mecej4
Honored Contributor III
1,979 Views

It would be nice if the MKL developers modified the behavior of the library routine LAPACKE_dsyevr() so that it returns an error code or aborts with an error message when the routine has been called with an insufficiently large array for the argument isuppz, instead of quietly returning wrong eigenvalues to the trusting user.

0 Kudos
Reply