johnfitzpat
02-27-2004, 07:07 AM
Can someone please help. I am trying to use the SVD algorithm on a 2D vector a[n][m].
Please can someone give a a main function that calls the svd algorithm in C. I just cant get my head around the ** stuff. How do I call and use it. Thanks for any help!!
geofizyk
04-13-2004, 12:29 PM
Hello John,
In your main you should declare:
float **a = matrix (1,m,1,n);
float **v = matrix(1,n,1,n);
float *w = vector(1,n);
m, n should be declared and initialized at the beggining.
then you can use:
...
a[1][1] = something;
...
next you can use:
...
svdcmp(a, m, n, w, v);
...
You can access the matrices a (this will become u) and v and vector w (with eigenvalues).
don't forget to free the memory by writing:
void free_matrix(float **a, long nrl, long nrh, long ncl, long nch);
....
P.S.
You need to have two more files:
nrutils.h with declarations
nrutils.c with definitions
Regards
Pawel Zych
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.