/* Ft2dc.c 2-d Fourier transform subroutine using the 1-d FT subroutine and Rocca's column FT routine. Usage: int n1, n2; float sign1, sign2; struct complex cp[][]; ft2d(n1, n2, cp, sign1, sign2); Compile: cc prog.c ft2dc.c colmft.c fft.c -fswitch -lm -o prog Arguments: n1 number of rows of 2-d matrix MUST BE A POWER OF 2 n2 number of columns of matrix, fastest varying MUST BE A POWER OF 2 cp pointer to complex 2-d matrix cp[n1][n2] sign1 sign for row transform sign2 sign for column transform */ /* Include the usual header files */ #include #include /* Define complex multiplication and its conjugate */ #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; }; /* Body of subroutine */ ft2dc(n1, n2, cp, sign1, sign2) /* Declare all argument variables */ int n1, n2; float sign1, sign2; struct complex *cp; { /* Declare all local variables */ int i1; /* Transform over the fast dimension, the rows */ for(i1=0; i1