Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

fftcheck.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Functions

int main (int argc, char *argv[])

Function Documentation

int main int    argc,
char *    argv[]
 

\** File : SUMA.c

Author:
: Ziad Saad Date : Thu Dec 27 16:21:01 EST 2001
Purpose :

Input paramters :

Parameters:
param  Usage : SUMA ( )
Returns :
Returns:
Support :
See also:
OpenGL prog. Guide 3rd edition , varray.c from book's sample code
Side effects :

Definition at line 9 of file fftcheck.c.

References argc, csfft_cox(), csfft_nextup(), csfft_scale_inverse(), i, complex::i, malloc, r, complex::r, and strtod().

00010 {
00011    int N ;
00012    complex * cx , * cs ;
00013    int ii ;
00014    float f , sum , xx,yy ;
00015 
00016    if( argc < 3 ){ printf("Usage: fftcheck N nfreq | more\n"); exit(1); }
00017 
00018    N = strtod( argv[1] , NULL ) ;
00019 
00020    if( N > 0 && N != csfft_nextup(N) ){
00021       fprintf(stderr,"Can't do FFT of length %d\n",N) ; exit(1) ;
00022    } else if ( N < 0 ){
00023       N = -N ;
00024    }
00025 
00026    f = strtod( argv[2] , NULL ) / N ;
00027 
00028    cs = (complex *) malloc(sizeof(complex)*N) ;
00029    cx = (complex *) malloc(sizeof(complex)*N) ;
00030 
00031    for( ii=0 ; ii < N ; ii++ ){
00032       cx[ii].r = cos(2*PI*f*ii) ; cx[ii].i = sin(2*PI*f*ii) ;
00033       cs[ii] = cx[ii] ;
00034    }
00035 
00036    csfft_scale_inverse(1) ;
00037 
00038    csfft_cox( -1 , N , cx ) ;
00039 
00040    for( ii=0 ; ii < N ; ii++ )
00041       printf("%2d: %12.5g %12.5g\n" , ii , cx[ii].r , cx[ii].i ) ;
00042 
00043    csfft_cox( 1 , N , cx ) ;
00044    sum = 0.0 ;
00045    for( ii=0 ; ii < N ; ii++ ){
00046       xx = cx[ii].r - cs[ii].r ;
00047       yy = cx[ii].i - cs[ii].i ; sum += xx*xx + yy*yy ;
00048    }
00049    sum = sqrt( sum/N ) ;
00050    printf("RMS error = %g\n",sum) ;
00051    exit(0) ;
00052 }
 

Powered by Plone

This site conforms to the following standards: