Tham khảo tài liệu 'biến đổi fourier rời rạc part 6', khoa học tự nhiên, toán học phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | wr float malloc n2 sizeof float wi float malloc n2 sizeof float Generating LUT for twiddle factors. WTS wr wi N -1 FFT2D fptr fptro wr wi L N m -1 void FFT2D FILE fptr FILE fptro float wr float wi unsigned int L int N int m int sign . 2-D FFT Algorithm. fptr file pointer to input file. fptro file pointer to output file. Note fptr fptro should be opened in the main routine. They are closed before return to @he main routine. wr 1 wj I input arrays for twiddle factors calculated by calling procedure WTS. L I look-up table for bit reversal. N input array size NxN words. 2 to the power m. sign -1 for 2-D FFT 1 for 2-D IFFT. For FFT sign 1 the input data is assumed to be real. The result of the FFT has its origin shifted to N 2 N 2 . int N2 i j k kk long loc NB float xr xi buff N2 N 1 NB sizeof float N2 Allocating memory for FFT arrays real and imag. xr float malloc N sizeof float xi float malloc N sizeof float buff float malloc NB First stage. 125 gotoxy 1 3 printf First stage. for j 0 j N j gotoxy 1 4 printf FFT of row 4d j if sign int 1 fread buff NB 1 fptr for i 0 i N i k L i kk i 1 xr k buff kk xi k buff kk 1 _ else for i 0 i N i k L i xr k float getc fptr if i j 2 0 xr k -xr k xi k _ FFT xr xi wr wi m N for i 0 i N i k i 1 buff k xr i buff k 1 xi 1 fwrite buff NB 1 fptro fclose fptr Transpose. 126 gotoxy 1 5 printf Transposing of intermediate file. rewind fptro transpose fptro N m rewind fptro Second stage. printf n Second stage. for j 0 j N j gotoxy 1 7 printf FFT of row 4d j loc long j NB fseek fptro loc SEEK_SET fread buff NB 1 fptro for i 0 i N i k L i kk i 1 xr k buff kk xi k buff kk 1 FFT xr xi wr wi m N for i 0 i N i k i 1 if sign int 1 i j 2 int 0 _ buff k -xr i buff k 1 -xi i else buff k xr i buff k 1 xi i if fseek fptro loc SEEK_SET 0 .