Statistics
| Branch: | Revision:

root / synthbench / euroben-ports / base / C-MPI / mod2f / .svn / text-base / nflops.c.svn-base @ 0:839f52ef7657

History | View | Annotate | Download (1.9 kB)

1
#include <stdio.h>
2
#include <math.h>
3

    
4
void nflops( int m, int *mfli, int *mflt )
5
// ---------------------------------------------------------------------
6
// --- nflops calculates the number of flops for the complex-to-
7
//     complex Radix-4 FFT of length 2**m.
8
//     m should be >= 2.
9
// --- In the initialisation part it is assumed that the evaluation
10
//     of a Sine or Cosine function takes 10 flops.
11
// ---------------------------------------------------------------------
12
{
13
   int mfl2, mfl3, mdiv, mmod, m2, n, n12, n14, n24, n4;
14
// ---------------------------------------------------------------------
15
// --- Test input parameter.
16

    
17
   if ( m < 2 ) {
18
      printf( " *** Error in routine Nflops: m < 2 : m = %d\n", m );
19
      return;
20
   }
21
// ---------------------------------------------------------------------
22
// --- Marginal cases:
23

    
24
   if ( m == 2 ) {
25
      *mfli = 22; *mflt = 20;
26
      return;
27
   }
28
   if ( m == 3 ) {
29
      *mfli = 107; *mflt = 86;
30
      return;
31
   }
32
// ---------------------------------------------------------------------
33
// --- Initialisation part.
34

    
35
   m2    = ( m + 1 )/2;
36
   *mfli = 21* ( (int)pow( 4, m2 ) - 1 )/3  + m2;
37
// ---------------------------------------------------------------------
38
// --- Transform part:
39

    
40
   n = (int)pow( 2, m );
41
   if ( n < 64 ) {
42
      if ( n == 16 ) {
43
         *mflt = 264;
44
      }
45
      else if ( n == 32 ) {
46
         *mflt = 644;
47
      }
48
   }
49
   else {
50
      n4   = n/4;
51
      mfl2 = 54*n4 + 48;
52
      mmod = m%4;
53
      mdiv = ( m - 1 )/4;
54
      n12  = 23*n4;
55
      n14  = 48*n4;
56
      n24  = n14 + n14;
57
      mfl3 = ( mdiv - 1 )*n24;
58
      switch( mmod ) {
59
      case 0:
60
         mfl3 = mfl3 + n24;
61
         break;
62
      case 1:
63
         mfl3 = mfl3 + n12;
64
         break;
65
      case 2:
66
         mfl3 = mfl3 + n14;
67
         break;
68
      case 3:
69
         mfl3 = mfl3 + n14 + n12;
70
         break;
71
      }
72
      *mflt = mfl2 + mfl3;
73
   }
74
}