## CODE not working properly

Open discussion regarding features, bugs, issues, vendors, etc.

### CODE not working properly

I have tried to solve for the eigenvalues of a general symmetric matrix.
To test that in C I have written the following programm for a diagonal 4x4 unit matrix:

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<lapacke.h>

main()
{

double *AP,*w,*z,*WORK;
char JOBZ='V',UPLO='U';
lapack_int INFO,M=4;
float A[M*(M+2)+1];

AP=calloc(M*(M+1)/2+1,sizeof(double));
w=calloc(M+1,sizeof(double));
z=calloc(M*(M+2)+1,sizeof(double));
WORK=calloc(3*M+1,sizeof(double));

int ii,jj;

// initialization
for(ii=0;ii<=M;++ii)
{
for(jj=0;jj<=M;++jj)
{

A[(M+1)*jj+ii]=0;
}
}

//filling the matrix

for(ii=1;ii<=M;++ii)
{

A[(M+1)*ii+ii]=1.0;
}
// filling done

//filling AP

for(ii=1;ii<=M;++ii)
{
for(jj=ii;jj<=M;++jj)
{

AP[ii+jj*(jj-1)/2]=A[(M+1)*jj+ii];
}
}
//AP done

INFO=LAPACKE_dspev(LAPACK_COL_MAJOR,JOBZ,UPLO,M,AP,w,z,M); // finding the eigenvalues

//printing the eigenvalues

for(ii=1;ii<=M;++ii)
{

printf("%e\n",w[ii]);

}
//done

}

Anjan
anjansarkarbhp

Posts: 2
Joined: Thu Aug 27, 2015 1:08 am

### Re: CODE not working properly

LAPACKE_dspev is for matrices in packed format.

See LAPACK routine name scheme
http://www.netlib.org/lapack/lug/node24.html

You may want to use DSYEV (symmetric format )
Hope it helps

Posts: 616
Joined: Wed Dec 08, 2004 7:07 pm

### Re: CODE not working properly

Thank you very much. It works.

Anjan
anjansarkarbhp

Posts: 2
Joined: Thu Aug 27, 2015 1:08 am