ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
kiss_fft.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
+ Include dependency graph for kiss_fft.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  kiss_fft_cpx
 

Macros

#define KISS_FFT_MALLOC   malloc
 
#define KISS_FFT_FREE   free
 
#define kiss_fft_scalar   float
 
#define kiss_fft_free   free
 
#define kiss_fftr_next_fast_size_real(n)   (kiss_fft_next_fast_size( ((n)+1)>>1)<<1)
 

Typedefs

typedef struct kiss_fft_statekiss_fft_cfg
 

Functions

kiss_fft_cfg kiss_fft_alloc (int nfft, int inverse_fft, void *mem, size_t *lenmem)
 
void kiss_fft (kiss_fft_cfg cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout)
 
void kiss_fft_stride (kiss_fft_cfg cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout, int fin_stride)
 
void kiss_fft_cleanup (void)
 
int kiss_fft_next_fast_size (int n)
 

Data Structure Documentation

struct kiss_fft_cpx

Definition at line 51 of file kiss_fft.h.

+ Collaboration diagram for kiss_fft_cpx:
Data Fields
float i
float r

Macro Definition Documentation

#define KISS_FFT_FREE   free

Definition at line 33 of file kiss_fft.h.

#define kiss_fft_free   free

Definition at line 102 of file kiss_fft.h.

Referenced by getFreqDec().

#define KISS_FFT_MALLOC   malloc

Definition at line 32 of file kiss_fft.h.

Referenced by kiss_fft_alloc(), and kiss_fftr_alloc().

#define kiss_fft_scalar   float

Definition at line 47 of file kiss_fft.h.

#define kiss_fftr_next_fast_size_real (   n)    (kiss_fft_next_fast_size( ((n)+1)>>1)<<1)

Definition at line 117 of file kiss_fft.h.

Typedef Documentation

typedef struct kiss_fft_state* kiss_fft_cfg

Definition at line 56 of file kiss_fft.h.

Function Documentation

void kiss_fft ( kiss_fft_cfg  cfg,
const kiss_fft_cpx fin,
kiss_fft_cpx fout 
)

Definition at line 385 of file kiss_fft.c.

References kiss_fft_stride().

Referenced by getFreqDec(), kiss_fftr(), and kiss_fftri().

386 {
387  kiss_fft_stride(cfg,fin,fout,1);
388 }
void kiss_fft_stride(kiss_fft_cfg st, const kiss_fft_cpx *fin, kiss_fft_cpx *fout, int in_stride)
Definition: kiss_fft.c:371

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

kiss_fft_cfg kiss_fft_alloc ( int  nfft,
int  inverse_fft,
void *  mem,
size_t *  lenmem 
)

Definition at line 339 of file kiss_fft.c.

References kiss_fft_state::factors, kiss_fft_state::inverse, kf_cexp, kf_factor(), KISS_FFT_MALLOC, kiss_fft_state::nfft, phase, and kiss_fft_state::twiddles.

Referenced by getFreqDec(), and kiss_fftr_alloc().

340 {
341  kiss_fft_cfg st=NULL;
342  size_t memneeded = sizeof(struct kiss_fft_state)
343  + sizeof(kiss_fft_cpx)*(nfft-1); /* twiddle factors*/
344 
345  if ( lenmem==NULL ) {
346  st = ( kiss_fft_cfg)KISS_FFT_MALLOC( memneeded );
347  }else{
348  if (mem != NULL && *lenmem >= memneeded)
349  st = (kiss_fft_cfg)mem;
350  *lenmem = memneeded;
351  }
352  if (st) {
353  int i;
354  st->nfft=nfft;
355  st->inverse = inverse_fft;
356 
357  for (i=0;i<nfft;++i) {
358  const double pi=3.141592653589793238462643383279502884197169399375105820974944;
359  double phase = -2*pi*i / nfft;
360  if (st->inverse)
361  phase *= -1;
362  kf_cexp(st->twiddles+i, phase );
363  }
364 
365  kf_factor(nfft,st->factors);
366  }
367  return st;
368 }
#define kf_cexp(x, phase)
kiss_fft_cpx twiddles[1]
struct kiss_fft_state * kiss_fft_cfg
Definition: kiss_fft.h:56
double phase
Definition: main.c:48
static void kf_factor(int n, int *facbuf)
Definition: kiss_fft.c:309
int factors[2 *32]
#define KISS_FFT_MALLOC
Definition: kiss_fft.h:32

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void kiss_fft_cleanup ( void  )

Definition at line 391 of file kiss_fft.c.

Referenced by getFreqDec().

392 {
393  // nothing needed any more
394 }

+ Here is the caller graph for this function:

int kiss_fft_next_fast_size ( int  n)

Definition at line 396 of file kiss_fft.c.

397 {
398  while(1) {
399  int m=n;
400  while ( (m%2) == 0 ) m/=2;
401  while ( (m%3) == 0 ) m/=3;
402  while ( (m%5) == 0 ) m/=5;
403  if (m<=1)
404  break; /* n is completely factorable by twos, threes, and fives */
405  n++;
406  }
407  return n;
408 }
void kiss_fft_stride ( kiss_fft_cfg  cfg,
const kiss_fft_cpx fin,
kiss_fft_cpx fout,
int  fin_stride 
)

Definition at line 371 of file kiss_fft.c.

References kiss_fft_state::factors, kf_work(), KISS_FFT_TMP_ALLOC, KISS_FFT_TMP_FREE, and kiss_fft_state::nfft.

Referenced by kiss_fft().

372 {
373  if (fin == fout) {
374  //NOTE: this is not really an in-place FFT algorithm.
375  //It just performs an out-of-place FFT into a temp buffer
376  kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft);
377  kf_work(tmpbuf,fin,1,in_stride, st->factors,st);
378  memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft);
379  KISS_FFT_TMP_FREE(tmpbuf);
380  }else{
381  kf_work( fout, fin, 1,in_stride, st->factors,st );
382  }
383 }
#define KISS_FFT_TMP_ALLOC(nbytes)
#define KISS_FFT_TMP_FREE(ptr)
static void kf_work(kiss_fft_cpx *Fout, const kiss_fft_cpx *f, const size_t fstride, int in_stride, int *factors, const kiss_fft_cfg st)
Definition: kiss_fft.c:238

+ Here is the call graph for this function:

+ Here is the caller graph for this function: