"Fossies" - the Fresh Open Source Software Archive

Member "ccmath-2.2.1/fft/test/t2dfft.c" (1 Nov 2000, 3047 Bytes) of package /linux/misc/old/ccmath-2.2.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*  t2dfft.c    CCMATH mathematics library source code.
    2  *
    3  *  Copyright (C)  2000   Daniel A. Atkinson    All rights reserved.
    4  *  This code may be redistributed under the terms of the GNU library
    5  *  public license (LGPL). ( See the lgpl.license file for details.)
    6  * ------------------------------------------------------------------------
    7  */
    8 /*
    9     Test:  fft2_d
   10 */
   11 #include "ccmath.h"
   12 #include <math.h>
   13 struct complex *pa;
   14 void main(int na,char **av)
   15 { int n,nd,f;
   16   struct complex *p; int i,j;
   17   double tp=6.28318530717958648;
   18   if(na!=3){ printf("para: log2(n) cd(0/1)\n"); exit(1);}
   19   printf("  Test of 2D FFT\n");
   20   n=atoi(*++av); nd=1<<n; tp/=nd;
   21   f=atoi(*++av); if(f) f='i'; else f='d';
   22   pa=(struct complex *)calloc(sizeof(*pa),nd*nd);
   23   for(i=0,p=pa; i<nd ;++i){
   24     for(j=0; j<nd ;++j){
   25        p->re=sin(i*tp)*sin(j*tp);
   26        (p++)->im=0.;
   27      }
   28    }
   29   fft2_d(pa,n,n,f);
   30   printf(" %d complex values in output\n",nd*nd);
   31   for(i=0,p=pa; i<nd ;++i){
   32     for(j=0; j<nd ;++j,++p)
   33       printf(" %2d %2d  %10.6f %10.6f\n",i,j,p->re,p->im);
   34    }
   35 }
   36 /* Test output
   37 
   38   Test of 2D FFT
   39  64 complex values in output
   40   0  0    0.000000   0.000000
   41   0  1    0.000000  -0.000000
   42   0  2    0.000000   0.000000
   43   0  3   -0.000000  -0.000000
   44   0  4    0.000000   0.000000
   45   0  5   -0.000000   0.000000
   46   0  6    0.000000  -0.000000
   47   0  7    0.000000   0.000000
   48   1  0   -0.000000  -0.000000
   49   1  1   -0.250000   0.000000
   50   1  2   -0.000000  -0.000000
   51   1  3   -0.000000  -0.000000
   52   1  4    0.000000  -0.000000
   53   1  5    0.000000  -0.000000
   54   1  6    0.000000  -0.000000
   55   1  7    0.250000   0.000000
   56   2  0   -0.000000   0.000000
   57   2  1   -0.000000  -0.000000
   58   2  2   -0.000000  -0.000000
   59   2  3    0.000000  -0.000000
   60   2  4    0.000000  -0.000000
   61   2  5   -0.000000  -0.000000
   62   2  6    0.000000   0.000000
   63   2  7    0.000000   0.000000
   64   3  0    0.000000  -0.000000
   65   3  1   -0.000000  -0.000000
   66   3  2   -0.000000  -0.000000
   67   3  3    0.000000  -0.000000
   68   3  4   -0.000000   0.000000
   69   3  5    0.000000   0.000000
   70   3  6    0.000000   0.000000
   71   3  7    0.000000   0.000000
   72   4  0    0.000000   0.000000
   73   4  1   -0.000000  -0.000000
   74   4  2    0.000000  -0.000000
   75   4  3    0.000000   0.000000
   76   4  4    0.000000   0.000000
   77   4  5    0.000000  -0.000000
   78   4  6    0.000000   0.000000
   79   4  7   -0.000000   0.000000
   80   5  0    0.000000   0.000000
   81   5  1    0.000000  -0.000000
   82   5  2    0.000000   0.000000
   83   5  3   -0.000000   0.000000
   84   5  4   -0.000000  -0.000000
   85   5  5    0.000000  -0.000000
   86   5  6   -0.000000  -0.000000
   87   5  7   -0.000000   0.000000
   88   6  0    0.000000  -0.000000
   89   6  1    0.000000  -0.000000
   90   6  2    0.000000   0.000000
   91   6  3   -0.000000   0.000000
   92   6  4   -0.000000   0.000000
   93   6  5    0.000000   0.000000
   94   6  6   -0.000000  -0.000000
   95   6  7   -0.000000   0.000000
   96   7  0   -0.000000   0.000000
   97   7  1    0.250000   0.000000
   98   7  2    0.000000   0.000000
   99   7  3   -0.000000   0.000000
  100   7  4    0.000000   0.000000
  101   7  5   -0.000000   0.000000
  102   7  6   -0.000000   0.000000
  103   7  7   -0.250000  -0.000000
  104 */