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