Skip to content

Commit

Permalink
Added default parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
berndporr committed Feb 15, 2021
1 parent 4f17d87 commit a65b47f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 44 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The basic usage for 1-d complex FFT is:
```
#include "kiss_fft.h"
kiss_fft_cfg cfg = kiss_fft_alloc( nfft, is_inverse_fft, nullptr, nullptr );
kiss_fft_cfg cfg = kiss_fft_alloc( nfft, is_inverse_fft );
kiss_fft_cpx *cx_in = new kiss_fft_cpx[nfft];
kiss_fft_cpx *cx_out = new kiss_fft_cpx[nfft];
Expand Down Expand Up @@ -42,7 +42,7 @@ A real valued optimized FFT which takes real valued signals as its input is impl
```
#include "kiss_fftr.h"
kiss_fftr_cfg cfg = kiss_fftr_alloc(nfft, 0, nullptr, nullptr);
kiss_fftr_cfg cfg = kiss_fftr_alloc(nfft, 0);
kiss_fft_scalar *cx_in = new kiss_fft_scalar[nfft];
kiss_fft_cpx *cx_out = new kiss_fft_cpx[nfft/2+1];
Expand All @@ -62,7 +62,7 @@ delete[] cx_out;
```
#include "kiss_fftr.h"
kiss_fftr_cfg cfg = kiss_fftr_alloc(nfft, 1, nullptr, nullptr);
kiss_fftr_cfg cfg = kiss_fftr_alloc(nfft, 1);
kiss_fft_cpx *cx_in = new kiss_fft_cpx[nfft/2+1];
kiss_fft_scalar *cx_out = new kiss_fft_scalar[nfft];
Expand Down
8 changes: 4 additions & 4 deletions jnifft/src/main/cpp/kiss-fft-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Java_uk_me_berndporr_kiss_1fft_KISSFastFourierTransformer_dofft(JNIEnv *env, job
return NULL;
}

kiss_fft_cfg cfg = kiss_fft_alloc(n, is_inverse, 0, 0);
kiss_fft_cfg cfg = kiss_fft_alloc(n, is_inverse);

double *inValues = env->GetDoubleArrayElements(inArray, 0);

Expand Down Expand Up @@ -61,7 +61,7 @@ Java_uk_me_berndporr_kiss_1fft_KISSFastFourierTransformer_dofftdouble(JNIEnv *en
return NULL;
}

kiss_fft_cfg cfg = kiss_fft_alloc(n, is_inverse, 0, 0);
kiss_fft_cfg cfg = kiss_fft_alloc(n, is_inverse);
kiss_fft_cpx *inArray = new kiss_fft_cpx[n];
kiss_fft_cpx *outArray = new kiss_fft_cpx[n];

Expand Down Expand Up @@ -114,7 +114,7 @@ Java_uk_me_berndporr_kiss_1fft_KISSFastFourierTransformer_dofftr(JNIEnv *env, jo
}

int is_inverse = 0;
kiss_fftr_cfg cfg = kiss_fftr_alloc(n, is_inverse, 0, 0);
kiss_fftr_cfg cfg = kiss_fftr_alloc(n, is_inverse);
kiss_fft_cpx *outArray = new kiss_fft_cpx[n];

double *values = env->GetDoubleArrayElements(data, 0);
Expand Down Expand Up @@ -167,7 +167,7 @@ Java_uk_me_berndporr_kiss_1fft_KISSFastFourierTransformer_dofftri(JNIEnv *env, j
// length of real sequence
int real_data_points = 2 * n - 2;

kiss_fftr_cfg cfg = kiss_fftr_alloc(real_data_points, is_inverse, 0, 0);
kiss_fftr_cfg cfg = kiss_fftr_alloc(real_data_points, is_inverse);
kiss_fft_cpx *inArray = new kiss_fft_cpx[n];

for (int j = 0; j < n; j++) {
Expand Down
32 changes: 5 additions & 27 deletions kiss_fft.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,14 @@
#include <math.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

#define KISS_FFT_MALLOC malloc
#define KISS_FFT_FREE free


#ifdef FIXED_POINT
#include <sys/types.h>
# if (FIXED_POINT == 32)
# define kiss_fft_scalar int32_t
# else
# define kiss_fft_scalar int16_t
# endif
#else
# ifndef kiss_fft_scalar
/* default is double */
# define kiss_fft_scalar double
# endif
#endif
#define kiss_fft_scalar double

typedef struct {
kiss_fft_scalar r;
kiss_fft_scalar i;
}kiss_fft_cpx;
} kiss_fft_cpx;

typedef struct kiss_fft_state* kiss_fft_cfg;

Expand All @@ -40,8 +22,8 @@ typedef struct kiss_fft_state* kiss_fft_cfg;
*
* Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
*
* typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL); for FFT
* kiss_fft_cfg mycfg=kiss_fft_alloc(1024,1,NULL,NULL); for IFFT
* typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0); for FFT
* kiss_fft_cfg mycfg=kiss_fft_alloc(1024,1); for IFFT
*
* The return value from fft_alloc is a cfg buffer used internally
* by the fft routine or NULL.
Expand All @@ -61,7 +43,7 @@ typedef struct kiss_fft_state* kiss_fft_cfg;
* buffer size in *lenmem.
* */

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

/*
* kiss_fft(cfg,in_out_buf)
Expand Down Expand Up @@ -93,8 +75,4 @@ int kiss_fft_next_fast_size(int n);
#define kiss_fftr_next_fast_size_real(n) \
(kiss_fft_next_fast_size( ((n)+1)>>1)<<1)

#ifdef __cplusplus
}
#endif

#endif
11 changes: 1 addition & 10 deletions kiss_fftr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
#define KISS_FTR_H

#include "kiss_fft.h"
#ifdef __cplusplus
extern "C" {
#endif


/*
Real optimized version can save about 45% cpu time vs. complex fft of a real seq.
*/

typedef struct kiss_fftr_state *kiss_fftr_cfg;


kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem);
kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem = nullptr, size_t * lenmem = nullptr);
/*
nfft must be even
Expand All @@ -40,7 +34,4 @@ void kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *

#define kiss_fftr_free free

#ifdef __cplusplus
}
#endif
#endif

0 comments on commit a65b47f

Please sign in to comment.