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

LAPACK_zheev with matrix_layout=LAPACK_ROW_MAJOR

kumar__prashant
Beginner
978 Views

There seems to be a bug in the routine LAPACK_zheev in MKL 2019 update 3 version. This routine is used for finding eigenvectors and eigenvalues of a Hermitian matrix 'a'. Its syntax is:

lapack_int LAPACKE_zheev ( int matrix_layout , char jobz , char uplo , lapack_int n , lapack_complex_double* a , lapack_int lda , double* w );

The problem seems to occur for only "matrix_layout = LAPACK_ROW_MAJOR" argument with jobz = 'V'. The eigenvectors are outputted in 'a' by rewriting it. However, the routine rewrites only upper triangular portion of 'a' and the rest of the matrix is unchanged.

For example, the following code calculates the eigenvectors of the 2x2 Pauli matrix sigma_x.

filename: lapack_zheev

#include <iostream>
#include <complex>
#define MKL_Complex16 std::complex<double>
#include "mkl.h"
#include "mkl_types.h"

using namespace std;

int main() {
    complex<double> a[4];
    a[0] = 0;
    a[1] = 1;
    a[2] = 1;
    a[3] = 0;

    double eigs[2];

    int info = LAPACKE_zheev(LAPACK_ROW_MAJOR, 'V', 'U', 2, a, 2, eigs);

    cout << "Info = " << info << endl;
    cout << a[0] << " " << a[1] << endl;
    cout << a[2] << " " << a[3] << endl;
}

I compile it with:

icpc -std=c++14 -qopenmp -DMKL_ILP64 -m64 -I${MKLROOT}/include -O3 -DNDEBUG -ansi-alias -o lapack_zheev.out lapack_zheev.cpp -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -liomp5 -lpthread -lm -ldl

./lapack_zheev.out

The output is:

Info = 0
(-0.707107,0) (0.707107,0)
(1,0) (0.707107,0)

while it is supposed to be:

Info = 0
(-0.707107,0)   (0.707107,0)
(0.707107,0)   (0.707107,0)

Replacing LAPACK_ROW_MAJOR by LAPACK_COL_MAJOR produces the correct output.

0 Kudos
4 Replies
Gennady_F_Intel
Moderator
978 Views

Yes, this is an known issue which was introduced the last update. We will fix this into on the future updates. As a work-around - please try e.x the version of MKL  2019.0.

We will keep this tread updated when the fix of the problem will be available into product version of MKL.

0 Kudos
Gennady_F_Intel
Moderator
978 Views

the small remark - the latest correct update - MKL 2019 u1.

0 Kudos
Mishra__Ashirbad
Beginner
978 Views

Hi,

Even in the older version of MKL there is bug which gives incorrect values when using LAPACK_ROW_MAJOR. In the version 18.04 that I am using the signs (+/-) of the elements of the matrix are incorrect, even though the absolute values are correct. The incorrectness is not uniform, i.e I can't take the negative(-) of the elements to reverse their signs to the correct values. 

However, the only configuration that works is LAPACK_COLUMN_MAJOR.

0 Kudos
Gennady_F_Intel
Moderator
978 Views

please try to check version 2019 u4

0 Kudos
Reply