LAPACK Archives

[Lapack] Need help in CLAPACK



Hello,

I just had a quick glance at your C code. I did not check the computation 
of LWORK. Hope it's correct.

You have a problem with your array VR and VL.

If the flags JOBVL is 'N', DGEEV is not going to reference the array VL so 
you might want to set it to JOBVL to simply a pointer on a double:
        double *JOBVL;
no need to allocate anything. Well, your implementation is memory 
inefficient but this can not do any harm.

If the flags JOBVR is set to 'V', then DGEEV is going to output a N-by-N 
matrix for the eigenvectors. So you need something like:
        double VR[SIZE][SIZE];
and not
        double VR[SIZE];

Then when you print your eigenvectors do not forget to have a double loop:
N components per eigenvectors + N eigenvectors.

If you want the eigenvalues, they come as real or complex-conjugate pairs 
and there real/imaginary parts are in WR and WI arrays.

Julien.






On Mon, 27 Nov 2006, rama krishna wrote:

Hi,

I am trying to implement the "eig" function of Matlab in C with the use of 
dgeev().........But when I compare the results obtatined with Matlab and 
CLAPACK library, they resulted in different.

Here I am providing the code for your reference .  If there is any mistake in 
the usage of the function dgeev(), please help me out...

#include"f2c.h"
#include"clapack.h"
#include"stdio.h"
#define SIZE 4
void MAIN_(){}
void MAIN__(){}
void _MAIN_(){}
main()
{

char JOBVL,JOBVR;
int i,j;
integer N=SIZE;
integer LDA=N;
integer LDVL;
integer LDVR;
integer LWORK;
integer INFO;
double 
A[SIZE][SIZE]={{43,216,254,249},{49,198,193,211},{48,194,177,171},{46,214,225,169}};
double WR[SIZE];
double WI[SIZE];
double WORK[201];
double VL[SIZE];
double VR[SIZE];
JOBVL='N';
JOBVR='V';
LWORK=201;
LDVL=2;
LDVR=6;

dgeev_(&JOBVL, &JOBVR, &N, A, &LDA, WR, WI, VL, &LDVL, VR, &LDVR, WORK, &LWORK, 
&INFO);

printf("\n INFO=%d\n", INFO );
printf("The Eigen vector is:\n");

for(i=0;i<SIZE;i++)
printf("%f\t",VR[i]);

return 0;

}


I was expecting to get four eigen vectors, but this program resulted in only 
one eigen vector.

Please help me out ....

Thanks in advance...

Regards,
A.Ramakrishna



____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

<Prev in Thread] Current Thread [Next in Thread>


For additional information you may use the LAPACK/ScaLAPACK Forum.
Or one of the mailing lists, or