"Fossies" - the Fresh Open Source Software Archive

Member "ccmath-2.2.1/fft/test/tftuns.c" (6 Nov 2000, 3950 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 /*  tftuns.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:  ftuns
   10     Uses:  fftgc  pfac
   11 */
   12 #include "ccmath.h"
   13 #include <math.h>
   14 #define MPT 100
   15 struct complex ft[MPT],*pc[MPT];
   16 void main(void)
   17 { struct complex *f,**p,**h; double y;
   18   int kk[32],n=MPT,i;
   19   printf("     Test of FT Unscrambling (2 real series)\n");
   20   printf(" F1=-1, F2=1-2k/n for k<n/2 and F1=1, F2=2k/n-1 for k>n/2\n");
   21   for(i=0,y=2./n,f=ft; i<n ;++i,++f){
   22     if(i<n/2){ f->re= -1.; f->im=1.-i*y;}
   23     else{ f->re=1.; f->im=y*i-1.;}
   24    }
   25   ft[0].re=ft[n/2].re=0.;
   26   n=pfac(n,kk,'o');
   27   printf("      n= %d\n",n);
   28   fftgc(pc,ft,n,kk,'d');
   29   ftuns(pc,n);
   30   printf("%3d %10f %10f    %10f %10f\n",0,(*pc)->re,0.,(*pc)->im,0.);
   31   for(p=pc+1,h=pc+n-1,i=1; i<n/2 ;++p,--h){
   32     printf("%3d %10f %10f  ",i++,(*p)->re,(*p)->im);
   33     printf("  %10f %10f\n",(*h)->re,(*h)->im);
   34    }
   35   printf("%3d %10f %10f    %10f %10f\n",i,(*p)->re,0.,(*h)->im,0.);
   36 }
   37 /* Test output
   38 
   39      Test of FT Unscrambling (2 real series)
   40  F1=-1, F2=1-2k/n for k<n/2 and F1=1, F2=2k/n-1 for k>n/2
   41       n= 100
   42   0   0.000000   0.000000      0.500000   0.000000
   43   1   0.000000   0.636410      0.202709  -0.000000
   44   2   0.000000  -0.000000      0.000000  -0.000000
   45   3  -0.000000   0.211578      0.022583  -0.000000
   46   4  -0.000000  -0.000000      0.000000   0.000000
   47   5   0.000000   0.126275      0.008173  -0.000000
   48   6   0.000000  -0.000000      0.000000  -0.000000
   49   7  -0.000000   0.089475      0.004203  -0.000000
   50   8   0.000000  -0.000000     -0.000000   0.000000
   51   9   0.000000   0.068840      0.002570  -0.000000
   52  10   0.000000  -0.000000      0.000000  -0.000000
   53  11  -0.000000   0.055552      0.001743  -0.000000
   54  12   0.000000  -0.000000      0.000000   0.000000
   55  13   0.000000   0.046217      0.001268  -0.000000
   56  14   0.000000  -0.000000      0.000000  -0.000000
   57  15   0.000000   0.039252      0.000970  -0.000000
   58  16   0.000000  -0.000000      0.000000  -0.000000
   59  17   0.000000   0.033818      0.000772  -0.000000
   60  18   0.000000  -0.000000      0.000000   0.000000
   61  19   0.000000   0.029429      0.000633   0.000000
   62  20   0.000000  -0.000000      0.000000  -0.000000
   63  21   0.000000   0.025784      0.000532   0.000000
   64  22   0.000000  -0.000000     -0.000000   0.000000
   65  23  -0.000000   0.022686      0.000457  -0.000000
   66  24   0.000000  -0.000000      0.000000  -0.000000
   67  25   0.000000   0.020000      0.000400  -0.000000
   68  26   0.000000  -0.000000      0.000000   0.000000
   69  27  -0.000000   0.017632      0.000355  -0.000000
   70  28   0.000000  -0.000000      0.000000  -0.000000
   71  29   0.000000   0.015514      0.000320  -0.000000
   72  30   0.000000  -0.000000     -0.000000   0.000000
   73  31   0.000000   0.013592      0.000292   0.000000
   74  32   0.000000  -0.000000     -0.000000  -0.000000
   75  33   0.000000   0.011828      0.000270   0.000000
   76  34   0.000000  -0.000000     -0.000000  -0.000000
   77  35   0.000000   0.010191      0.000252  -0.000000
   78  36   0.000000  -0.000000      0.000000  -0.000000
   79  37   0.000000   0.008655      0.000237  -0.000000
   80  38   0.000000  -0.000000     -0.000000  -0.000000
   81  39   0.000000   0.007200      0.000226  -0.000000
   82  40   0.000000  -0.000000      0.000000  -0.000000
   83  41   0.000000   0.005811      0.000217   0.000000
   84  42   0.000000  -0.000000     -0.000000  -0.000000
   85  43   0.000000   0.004471      0.000210   0.000000
   86  44   0.000000  -0.000000     -0.000000   0.000000
   87  45   0.000000   0.003168      0.000205   0.000000
   88  46   0.000000  -0.000000     -0.000000  -0.000000
   89  47   0.000000   0.001891      0.000202  -0.000000
   90  48   0.000000  -0.000000      0.000000  -0.000000
   91  49   0.000000   0.000629      0.000200   0.000000
   92  50   0.000000   0.000000      0.000000   0.000000
   93 */