Point Cloud Library (PCL)  1.8.0
kiss_fft.h
1 #ifndef KISS_FFT_H
2 #define KISS_FFT_H
3 
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <math.h>
7 #include <string.h>
8 
9 #if !defined(__APPLE__)
10 #include <malloc.h>
11 #endif
12 
13 #include <pcl/pcl_exports.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /*
20  ATTENTION!
21  If you would like a :
22  -- a utility that will handle the caching of fft objects
23  -- real-only (no imaginary time component ) FFT
24  -- a multi-dimensional FFT
25  -- a command-line utility to perform ffts
26  -- a command-line utility to perform fast-convolution filtering
27 
28  Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
29  in the tools/ directory.
30 */
31 
32 #ifdef USE_SIMD
33 # include <xmmintrin.h>
34 # define kiss_fft_scalar __m128
35 #define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16)
36 #define KISS_FFT_FREE _mm_free
37 #else
38 #define KISS_FFT_MALLOC malloc
39 #define KISS_FFT_FREE free
40 #endif
41 
42 
43 #ifdef FIXED_POINT
44 #include <sys/types.h>
45 # if (FIXED_POINT == 32)
46 # define kiss_fft_scalar int32_t
47 # else
48 # define kiss_fft_scalar int16_t
49 # endif
50 #else
51 # ifndef kiss_fft_scalar
52 /* default is float */
53 # define kiss_fft_scalar float
54 # endif
55 #endif
56 
57 typedef struct {
58  kiss_fft_scalar r;
59  kiss_fft_scalar i;
61 
62 typedef struct kiss_fft_state* kiss_fft_cfg;
63 
64 /*
65  * kiss_fft_alloc
66  *
67  * Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
68  *
69  * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
70  *
71  * The return value from fft_alloc is a cfg buffer used internally
72  * by the fft routine or NULL.
73  *
74  * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
75  * The returned value should be free()d when done to avoid memory leaks.
76  *
77  * The state can be placed in a user supplied buffer 'mem':
78  * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
79  * then the function places the cfg in mem and the size used in *lenmem
80  * and returns mem.
81  *
82  * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
83  * then the function returns NULL and places the minimum cfg
84  * buffer size in *lenmem.
85  * */
86 
87 kiss_fft_cfg PCL_EXPORTS
88 kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
89 
90 /*
91  * kiss_fft(cfg,in_out_buf)
92  *
93  * Perform an FFT on a complex input buffer.
94  * for a forward FFT,
95  * fin should be f[0] , f[1] , ... ,f[nfft-1]
96  * fout will be F[0] , F[1] , ... ,F[nfft-1]
97  * Note that each element is complex and can be accessed like
98  f[k].r and f[k].i
99  * */
100 void PCL_EXPORTS
101 kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
102 
103 /*
104  A more generic version of the above function. It reads its input from every Nth sample.
105  * */
106 void PCL_EXPORTS
107 kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
108 
109 /* If kiss_fft_alloc allocated a buffer, it is one contiguous
110  buffer and can be simply free()d when no longer needed*/
111 #define kiss_fft_free free
112 
113 /*
114  Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
115  your compiler output to call this before you exit.
116 */
117 void PCL_EXPORTS
118 kiss_fft_cleanup(void);
119 
120 /*
121  * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
122  */
123 int PCL_EXPORTS
124 kiss_fft_next_fast_size(int n);
125 
126 /* for real ffts, we need an even size */
127 #define kiss_fftr_next_fast_size_real(n) \
128  (kiss_fft_next_fast_size( ((n)+1)>>1)<<1)
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif
kiss_fft_scalar i
Definition: kiss_fft.h:59
kiss_fft_scalar r
Definition: kiss_fft.h:58