BRL-CAD
fftc.c
Go to the documentation of this file.
1 /* F F T C . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @file libfft/fftc.c
21  *
22  * Split Radix Decimation in Time
23  * FFT C code generator.
24  *
25  */
26 
27 #include "common.h"
28 
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <math.h>
32 
33 #include "./fft.h"
34 
35 
36 extern int rfft_adds, rfft_mults;
37 
38 
39 int
40 main(int argc, char *argv[])
41 {
42  int n, m;
43 
44  if ( argc != 2 ) {
45  fprintf( stderr, "Usage: fftc length > fftlength.c\n" );
46  return 1;
47  }
48 
49  n = atoi(argv[1]);
50  if (n < 0 || n >= INT32_MAX) {
51  fprintf( stderr, "fftc: bad length - %s\n", argv[1]);
52  return 1;
53  }
54 
55  m = log((double)n)/log(2.0) + 0.5; /* careful truncation */
56  splitdit( n, m );
57  fprintf( stderr, "adds = %d, mults = %d\n", rfft_adds, rfft_mults );
58  return 0;
59 }
60 
61 /*
62  * Local Variables:
63  * mode: C
64  * tab-width: 8
65  * indent-tabs-mode: t
66  * c-file-style: "stroustrup"
67  * End:
68  * ex: shiftwidth=4 tabstop=8
69  */
Header file for the BRL-CAD common definitions.
int rfft_mults
Definition: splitdit.c:33
int main(int argc, char *argv[])
Definition: fftc.c:40
void splitdit(int N, int M)
Definition: splitditc.c:38
int rfft_adds
Definition: splitdit.c:33