## "Fossies" - the Fresh Open Source Software Archive

### Member "ccmath-2.2.1/fft/test/tfft2.c" (1 Nov 2000, 2650 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 /*  tfft2.c    CCMATH mathematics library source code.
2  *
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
10 */
11 #include "ccmath.h"
12 #include <math.h>
13 #define MPT 64
14 void main(void)
15 hlOpen(15,1);{ Cpx *f,*p,ft[MPT];
16   double tpi=6.283185307179586,ang,ann;
17   int n=MPT,i,j,m=6;
18   printf(" Test of Radix 2 Complex FFT\n");
19   printf("     F(k)=cos(2pi*5*k/n),cos(2pi*3*k/n)\n");
20   ang=5.*tpi/n; ann=3.*tpi/n;
21   for(i=0,f=ft; i<n ;++i)hlOpen(21,2);{ f->re=cos(ang*i); (f++)->im=cos(ann*i);hlClose(2, 21);}
22   printf("      m= %d\n",n);
23   fft2(ft,m,'d');
24   for(f=ft,p=ft+n/2,i=0,j=n/2; i<n/2 ;++p,++f)hlOpen(24,2);{
25     printf("%3d %9.6f %9.6f  ",i++,f->re,f->im);
26     printf("  %3d %9.6f %9.6f\n",j++,p->re,p->im);
27    hlClose(3, 27);}
28 hlClose(1, 28);}
29 /* Test output
30
31  Test of Radix 2 Complex FFT
32      F(k)=cos(2pi*5*k/n),cos(2pi*3*k/n)
33       m= 64
34   0 -0.000000 -0.000000     32 -0.000000 -0.000000
35   1  0.000000 -0.000000     33 -0.000000  0.000000
36   2 -0.000000  0.000000     34  0.000000 -0.000000
37   3  0.000000  0.500000     35 -0.000000 -0.000000
38   4 -0.000000  0.000000     36  0.000000 -0.000000
39   5  0.500000 -0.000000     37 -0.000000 -0.000000
40   6  0.000000  0.000000     38  0.000000 -0.000000
41   7  0.000000 -0.000000     39  0.000000  0.000000
42   8 -0.000000  0.000000     40 -0.000000  0.000000
43   9  0.000000 -0.000000     41 -0.000000 -0.000000
44  10  0.000000 -0.000000     42 -0.000000 -0.000000
45  11  0.000000  0.000000     43  0.000000 -0.000000
46  12 -0.000000  0.000000     44  0.000000 -0.000000
47  13  0.000000 -0.000000     45  0.000000  0.000000
48  14  0.000000  0.000000     46  0.000000  0.000000
49  15 -0.000000  0.000000     47  0.000000  0.000000
50  16 -0.000000  0.000000     48 -0.000000  0.000000
51  17 -0.000000  0.000000     49  0.000000  0.000000
52  18 -0.000000  0.000000     50  0.000000  0.000000
53  19 -0.000000 -0.000000     51 -0.000000  0.000000
54  20 -0.000000 -0.000000     52  0.000000  0.000000
55  21  0.000000 -0.000000     53  0.000000 -0.000000
56  22  0.000000  0.000000     54 -0.000000  0.000000
57  23  0.000000  0.000000     55  0.000000  0.000000
58  24 -0.000000 -0.000000     56 -0.000000 -0.000000
59  25  0.000000 -0.000000     57  0.000000  0.000000
60  26  0.000000  0.000000     58  0.000000 -0.000000
61  27 -0.000000  0.000000     59  0.500000  0.000000
62  28 -0.000000  0.000000     60 -0.000000  0.000000
63  29 -0.000000 -0.000000     61 -0.000000  0.500000
64  30  0.000000 -0.000000     62 -0.000000 -0.000000
65  31 -0.000000  0.000000     63 -0.000000  0.000000
66 */
```