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

Possible corruption on the heap while using the dsyevr function from LAPACK

Erasmo_Coletti
Beginner
349 Views

Hi,

I am using the function dsyevr in Visual Studio 2008 todo eigenvalue and eigenvectordecomposition for an input matrix. The function is used in a console application.
The code is as below:


#include "stdafx.h"
#include
#include
#include "mkl.h"
using namespace std;

#definen 5

int main()
{


double a[n*n] = {

0.67, 0.00, 0.00, 0.00, 0.00,

-0.20, 3.82, 0.00, 0.00, 0.00,

0.19, -0.13, 3.27, 0.00, 0.00,

-1.06, 1.06, 0.11, 5.86, 0.00,

0.46, -0.48, 1.10, -0.98, 3.54

};


char JOBZ = 'V';
char range = 'A';
char UPLO = 'L';
int info;
int lda = n;
int lwork;
double vl, vu;
int il = 1, iu = n;
double abstol = -1.0;
int ldz = n;
double wkopt;
int liwork;
int iwkopt;
int m;
vector w(n);
vector z(n*n);
vector isuppz(n);

lwork = n*26;
liwork = n*10;
vector work(lwork);
vector iwork(liwork);

dsyevr(&JOBZ, &range, &UPLO, &n, &a[0], &lda, &vl, &vu, &il, &iu,
&abstol, &m, &w[0], &z[0], &ldz, &isuppz[0], &work[0], &lwork, &iwork[0], &liwork, &info);



return 0;

}


When I step in the codefor the Debug version I can see that the function dsyevr returns the correct eigenvalues and eigenvectors. However, when the main function is returning I get the below error message:

Windows has triggered a breakpoint in SVD_testing.exe.

This may be due to a corruption of the heap, which indicates a bug in SVD_testing.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while SVD_testing.exe has focus.

The output window may have more diagnostic information.

Does anybody know whyI get this error message?

Thank you.

Erasmo.

0 Kudos
5 Replies
Gennady_F_Intel
Moderator
349 Views
Erasmo,
What MKL version are you using?
Is it ia32 or Intel64 architecture?
What was your linking line?
--Gennady
0 Kudos
Gennady_F_Intel
Moderator
349 Views
Erasmo,
instead ofvector isuppz(n);
allocate 2 times larger
vector isuppz(2*n); // see the description:isuppz --Array, DIMENSION at least 2 *max(1, m).
and try again.
--Gennady
0 Kudos
Erasmo_Coletti
Beginner
349 Views
Gennady,

it seems to work now.

Thank you very much.

Erasmo.
0 Kudos
petr_gamov
Beginner
349 Views
wondering whether your program works with an arbitrary size of input data?
0 Kudos
Gennady_F_Intel
Moderator
349 Views
I'm not sure.I think it depends on how to implement stl.
Array very long, it is likely it will not work . Lapack's routines assume that the input data stored in contiguous memory, but if I'm not mistaken this is not always the case if we are talking about the stl.
--Gennady
0 Kudos
Reply