"Fossies" - the Fresh Open Source Software Archive

Member "ccmath-2.2.1/fft/test/tfftiv.c" (6 Nov 2000, 3697 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 /*  tfftiv.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:  fftgc
   10     Uses:  pfac
   11 */
   12 #include <stdio.h>
   13 #include "ccmath.h"
   14 #include <math.h>
   15 #define MPT 100
   16 struct complex ft[MPT],*pc[MPT];
   17 void main(void)
   18 { struct complex *f,**p,**h;
   19   double tpi=6.283185307179586,ang,ann;
   20   int kk[32],n=MPT,i,j;
   21   printf(" Test of FFT Inverse\n");
   22   printf("     F(k)=cos(2pi*5*k/n),sin(2pi*4*k/n)\n");
   23   ang=5*tpi/n; ann=4*tpi/n;
   24   for(i=0,f=ft; i<n ;++i){ f->re=cos(ang*i); (f++)->im=sin(ann*i);}
   25   n=pfac(n,kk,'o');
   26   printf("      n= %d\n",n);
   27   fftgc(pc,ft,n,kk,'d');
   28   fftgc(pc,ft,n,kk,'i');
   29   for(p=pc,h=pc+n/2,i=0,j=n/2; i<n/2 ;++p,++h){
   30     printf("%3d %9.6f %9.6f  ",i++,(*p)->re,(*p)->im);
   31     printf("  %3d %9.6f %9.6f\n",j++,(*h)->re,(*h)->im);
   32    }
   33 }
   34 /* Test output
   35 
   36  Test of FFT Inverse
   37      F(k)=cos(2pi*5*k/n),sin(2pi*4*k/n)
   38       n= 100
   39   0  1.000000 -0.000000     50 -1.000000  0.000000
   40   1  0.951057  0.248690     51 -0.951057  0.248690
   41   2  0.809017  0.481754     52 -0.809017  0.481754
   42   3  0.587785  0.684547     53 -0.587785  0.684547
   43   4  0.309017  0.844328     54 -0.309017  0.844328
   44   5  0.000000  0.951057     55 -0.000000  0.951057
   45   6 -0.309017  0.998027     56  0.309017  0.998027
   46   7 -0.587785  0.982287     57  0.587785  0.982287
   47   8 -0.809017  0.904827     58  0.809017  0.904827
   48   9 -0.951057  0.770513     59  0.951057  0.770513
   49  10 -1.000000  0.587785     60  1.000000  0.587785
   50  11 -0.951057  0.368125     61  0.951057  0.368125
   51  12 -0.809017  0.125333     62  0.809017  0.125333
   52  13 -0.587785 -0.125333     63  0.587785 -0.125333
   53  14 -0.309017 -0.368125     64  0.309017 -0.368125
   54  15 -0.000000 -0.587785     65 -0.000000 -0.587785
   55  16  0.309017 -0.770513     66 -0.309017 -0.770513
   56  17  0.587785 -0.904827     67 -0.587785 -0.904827
   57  18  0.809017 -0.982287     68 -0.809017 -0.982287
   58  19  0.951057 -0.998027     69 -0.951057 -0.998027
   59  20  1.000000 -0.951057     70 -1.000000 -0.951057
   60  21  0.951057 -0.844328     71 -0.951057 -0.844328
   61  22  0.809017 -0.684547     72 -0.809017 -0.684547
   62  23  0.587785 -0.481754     73 -0.587785 -0.481754
   63  24  0.309017 -0.248690     74 -0.309017 -0.248690
   64  25  0.000000  0.000000     75 -0.000000 -0.000000
   65  26 -0.309017  0.248690     76  0.309017  0.248690
   66  27 -0.587785  0.481754     77  0.587785  0.481754
   67  28 -0.809017  0.684547     78  0.809017  0.684547
   68  29 -0.951057  0.844328     79  0.951057  0.844328
   69  30 -1.000000  0.951057     80  1.000000  0.951057
   70  31 -0.951057  0.998027     81  0.951057  0.998027
   71  32 -0.809017  0.982287     82  0.809017  0.982287
   72  33 -0.587785  0.904827     83  0.587785  0.904827
   73  34 -0.309017  0.770513     84  0.309017  0.770513
   74  35 -0.000000  0.587785     85 -0.000000  0.587785
   75  36  0.309017  0.368125     86 -0.309017  0.368125
   76  37  0.587785  0.125333     87 -0.587785  0.125333
   77  38  0.809017 -0.125333     88 -0.809017 -0.125333
   78  39  0.951057 -0.368125     89 -0.951057 -0.368125
   79  40  1.000000 -0.587785     90 -1.000000 -0.587785
   80  41  0.951057 -0.770513     91 -0.951057 -0.770513
   81  42  0.809017 -0.904827     92 -0.809017 -0.904827
   82  43  0.587785 -0.982287     93 -0.587785 -0.982287
   83  44  0.309017 -0.998027     94 -0.309017 -0.998027
   84  45  0.000000 -0.951057     95 -0.000000 -0.951057
   85  46 -0.309017 -0.844328     96  0.309017 -0.844328
   86  47 -0.587785 -0.684547     97  0.587785 -0.684547
   87  48 -0.809017 -0.481754     98  0.809017 -0.481754
   88  49 -0.951057 -0.248690     99  0.951057 -0.248690
   89 */