shun_iwasawa a35b8f
#include <stdio.h></stdio.h>
shun_iwasawa a35b8f
#include <stdlib.h></stdlib.h>
shun_iwasawa a35b8f
#include <fftw3.h></fftw3.h>
shun_iwasawa a35b8f
#include <unistd.h></unistd.h>
shun_iwasawa a35b8f
#include "pstats.h"
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#ifdef DATATYPEdouble
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#define CPXTYPE fftw_complex
shun_iwasawa a35b8f
#define PLAN fftw_plan
shun_iwasawa a35b8f
#define FFTMALLOC fftw_malloc
shun_iwasawa a35b8f
#define MAKEPLAN fftw_plan_dft_1d
shun_iwasawa a35b8f
#define DOFFT fftw_execute
shun_iwasawa a35b8f
#define DESTROYPLAN fftw_destroy_plan
shun_iwasawa a35b8f
#define FFTFREE fftw_free
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#elif defined(DATATYPEfloat)
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#define CPXTYPE fftwf_complex
shun_iwasawa a35b8f
#define PLAN fftwf_plan
shun_iwasawa a35b8f
#define FFTMALLOC fftwf_malloc
shun_iwasawa a35b8f
#define MAKEPLAN fftwf_plan_dft_1d
shun_iwasawa a35b8f
#define DOFFT fftwf_execute
shun_iwasawa a35b8f
#define DESTROYPLAN fftwf_destroy_plan
shun_iwasawa a35b8f
#define FFTFREE fftwf_free
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#endif
shun_iwasawa a35b8f
shun_iwasawa a35b8f
#ifndef CPXTYPE
shun_iwasawa a35b8f
int main(void)
shun_iwasawa a35b8f
{
shun_iwasawa a35b8f
    fprintf(stderr,"Datatype not available in FFTW\n" );
shun_iwasawa a35b8f
    return 0;
shun_iwasawa a35b8f
}
shun_iwasawa a35b8f
#else
shun_iwasawa a35b8f
int main(int argc,char ** argv)
shun_iwasawa a35b8f
{
shun_iwasawa a35b8f
    int nfft=1024;
shun_iwasawa a35b8f
    int isinverse=0;
shun_iwasawa a35b8f
    int numffts=1000,i;
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    CPXTYPE * in=NULL;
shun_iwasawa a35b8f
    CPXTYPE * out=NULL;
shun_iwasawa a35b8f
    PLAN p;
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    pstats_init();
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    while (1) {
shun_iwasawa a35b8f
      int c = getopt (argc, argv, "n:ix:h");
shun_iwasawa a35b8f
      if (c == -1)
shun_iwasawa a35b8f
        break;
shun_iwasawa a35b8f
      switch (c) {
shun_iwasawa a35b8f
      case 'n':
shun_iwasawa a35b8f
        nfft = atoi (optarg);
shun_iwasawa a35b8f
        break;
shun_iwasawa a35b8f
      case 'x':
shun_iwasawa a35b8f
        numffts = atoi (optarg);
shun_iwasawa a35b8f
        break;
shun_iwasawa a35b8f
      case 'i':
shun_iwasawa a35b8f
        isinverse = 1;
shun_iwasawa a35b8f
        break;
shun_iwasawa a35b8f
      case 'h':
shun_iwasawa a35b8f
      case '?':
shun_iwasawa a35b8f
      default:
shun_iwasawa a35b8f
        fprintf(stderr,"options:\n-n N: complex fft length\n-i: inverse\n-x N: number of ffts to compute\n"
shun_iwasawa a35b8f
                "");
shun_iwasawa a35b8f
      }
shun_iwasawa a35b8f
    }
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    in=FFTMALLOC(sizeof(CPXTYPE) * nfft);
shun_iwasawa a35b8f
    out=FFTMALLOC(sizeof(CPXTYPE) * nfft);
shun_iwasawa a35b8f
    for (i=0;i
shun_iwasawa a35b8f
        in[i][0] = rand() - RAND_MAX/2;
shun_iwasawa a35b8f
        in[i][1] = rand() - RAND_MAX/2;
shun_iwasawa a35b8f
    }
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    if ( isinverse )
shun_iwasawa a35b8f
        p = MAKEPLAN(nfft, in, out, FFTW_BACKWARD, FFTW_ESTIMATE);
shun_iwasawa a35b8f
    else    
shun_iwasawa a35b8f
        p = MAKEPLAN(nfft, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    for (i=0;i
shun_iwasawa a35b8f
        DOFFT(p);
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    DESTROYPLAN(p);
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    FFTFREE(in); FFTFREE(out);
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    fprintf(stderr,"fftw\tnfft=%d\tnumffts=%d\n", nfft,numffts);
shun_iwasawa a35b8f
    pstats_report();
shun_iwasawa a35b8f
shun_iwasawa a35b8f
    return 0;
shun_iwasawa a35b8f
}
shun_iwasawa a35b8f
#endif