Doxygen Source Code Documentation
fft3.c File Reference
#include "mrilib.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
Function Documentation
|
\** File : SUMA.c
Input paramters :
Definition at line 3 of file fft3.c. References argc, csfft_cox(), csfft_nextup(), i, complex::i, malloc, r, complex::r, and strtod().
00004 { 00005 int N ; 00006 complex * cx , * cs ; 00007 int ii ; 00008 float f , sum , xx,yy ; 00009 00010 if( argc < 3 ){ printf("Usage: fft3 N nf\n"); exit(1); } 00011 00012 N = strtod( argv[1] , NULL ) ; 00013 00014 if( N > 0 && N != csfft_nextup(N) ){ 00015 fprintf(stderr,"Can't do FFT of length %d\n",N) ; exit(1) ; 00016 } else if ( N < 0 ){ 00017 N = -N ; 00018 } 00019 00020 f = strtod( argv[2] , NULL ) / N ; 00021 00022 cs = (complex *) malloc(sizeof(complex)*N) ; 00023 cx = (complex *) malloc(sizeof(complex)*N) ; 00024 00025 for( ii=0 ; ii < N ; ii++ ){ 00026 cx[ii].r = cos(2*PI*f*ii) ; cx[ii].i = sin(2*PI*f*ii) ; 00027 cs[ii] = cx[ii] ; 00028 } 00029 00030 csfft_cox( -1 , N , cx ) ; 00031 00032 for( ii=0 ; ii < N ; ii++ ) 00033 printf("%2d: %12.5g %12.5g\n" , ii , cx[ii].r , cx[ii].i ) ; 00034 00035 csfft_cox( 1 , N , cx ) ; 00036 sum = 0.0 ; 00037 for( ii=0 ; ii < N ; ii++ ){ 00038 xx = cx[ii].r/N - cs[ii].r ; 00039 yy = cx[ii].i/N - cs[ii].i ; sum += xx*xx + yy*yy ; 00040 } 00041 sum = sqrt( sum/N ) ; 00042 printf("RMS error = %g\n",sum) ; 00043 exit(0) ; 00044 } |