Posted by Robert Yowell on August 14, 1997 at 15:49:43:
I am having trouble using ssyev.f. I have a c program
(testeig.c) that I am using to test the ssyev.f function
in the lapack library and it seems to be giving me an
erroneous output. I am using matlab to test the results.
Listed below is the output derived from using the
ssyev.f function, then the output from matlab, then
the c code that calls and displays the results. The
numeric values of each row in the matlab output
correspond to those in the column for the lapack code
but some of the signs are wrong and the eigenvalues
are not calculated. Any suggestions would be great.
Output from testeig.c subroutine.
****** input ********
a =
1.000000 2.000000 3.000000
2.000000 5.000000 7.000000
3.000000 7.000000 8.000000
****** output ********
****** Info is 0 ******
V =
0.347265 0.671893 -0.654192
0.902359 -0.429299 0.038086
0.255254 0.603542 0.755369
v =
0.000000
0.000000
0.000000
>> a=[[1 2 3];[2 5 7];[3 7 8]]
a =
1 2 3
2 5 7
3 7 8
Output from Matlab
>> [V v]=eig(a)
V =
-0.9024 0.3473 0.2553
0.4293 0.6719 0.6035
-0.0381 -0.6542 0.7554
v =
0.1751 0 0
0 -0.7819 0
0 0 14.6068
/* C-code for testing ssyev.f */ char jobz; printf("Output from testeig.c subroutine.\n"); dsyev_(&jobz,&uplo,&lda,a,&lda,w,work,&lwork,&info); exit(-1);
#define N 3
#include
main()
{
char uplo;
double a[N][N];
int lda;
double w[N];
double work[15*N];
int lwork= 15*N;
int info;
int i,j;
a[0][0] = 1; a[0][1] = 2; a[0][2] = 3;
a[1][0] = 2; a[1][1] = 5; a[1][2] = 7;
a[2][0] = 3; a[2][1] = 7; a[2][2] = 8;
jobz = 'V';
uplo = 'u';
lda = N;
printf(" ****** input ********\n");
printf("a = \n\n");
for(i=0;i
printf("\n");
}
printf(" ****** output ********\n");
printf("****** Info is %d ******\n",info);
printf("V = \n\n");
for(i=0;i
printf("\n");
}
printf("\nv = \n\n");
for(i=0;i
printf("\n");
}
~