/* Colmft.c Rocca's "row" Fourier transform, from Claerbout (1985) p. 73-74, modified for the indexing scheme used by C. Usage: int n1, n2; float sign2, scale; struct complex *cx; colmft(n1, n2, cx, sign2, scale); Compile: cc prog.c colmft.c -fswitch -lm -o prog.c Arguments: n1 number of rows of 2-d matrix MUST BE A POWER OF 2 n2 number of columns of matrix, fastest varying cx matrix of complex elements cx[n1][n2] sign2 sign of the transform scale scale factor to apply to data before transform */ /* The usual includes */ #include #include /* Define complex multiplication and conjugate for declared struct complex */ #define rmul(x,y) (x.re * y.re - x.im * y.im) #define imul(x,y) (x.im * y.re + x.re * y.im) #define rcmul(x,y) (x.re * y.re + x.im * y.im) #define icmul(x,y) (x.im * y.re - x.re * y.im) /* Declare the structure to hold complex numbers */ struct complex { float re; float im; }; colmft(n1, n2, cx, sign2, scale) int n1, n2; float sign2, scale; struct complex *cx; { int i, i1, i2, j, m, lstep, istep; float arg; struct complex cw, cdel, ctemp; /* Multiply each element in matrix by scale factor */ for (i1=0; i1 m-1) { j = j - m; m = m/2; if (m < 1) break; } j = j + m; } lstep = 1; do { istep = 2*lstep; cw.re = 1; cw.im = 0; arg = sign2*3.14159265/lstep; cdel.re = (float)(cos((double)(arg))); cdel.im = (float)(sin((double)(arg))); for (m=0; mre; cw.im = cwp->im; for (i=0; i