I have a symmetric, tridiagonal matrix of which I want to compute the eigenvalues and eigenvectors. I'm using the LAPACK dstevd function to do so. I'm coding in C, so I've the following line at the top of my code so I am able to call the fortran function:
extern "C" void dstevd_( char *jobz, int N, double d, double* e, double *z, int *ldz, int *work, int *lwork, int *iwork, int *liwork, int *info);
I need the eigenvectors, so I need to set *z, *work and *iwork. According to the LAPACK manual (Link) the sizes need to be: z: >= n*n, work: >= 1 + 4*n + n**2, iwork: >= 3 + 5*n.
When using these sizes, I am getting errors saying that dstevd_ is accessing memory that was not allocated in these arrays. It works fine for a small (n=4) problem, but I run into problems at bigger sizes (n=36). If I increase the sizes of z, work and iwork it works.
Any suggestions on how to correctly determine the required sizes for z, work and iwork?
thanks.