mirror of
https://github.com/mborgerding/kissfft.git
synced 2025-05-27 21:20:27 -04:00
added kiss_fft_next_fast_size() to determine the next number divisible by the radices 2,3,5
This commit is contained in:
parent
a2c69eb8ea
commit
2cce2ea306
14
kiss_fft.c
14
kiss_fft.c
@ -383,3 +383,17 @@ void kiss_fft_cleanup(void)
|
|||||||
tmpbuf=NULL;
|
tmpbuf=NULL;
|
||||||
ntmpbuf=0;
|
ntmpbuf=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int kiss_fft_next_fast_size(int n)
|
||||||
|
{
|
||||||
|
while(1) {
|
||||||
|
int m=n;
|
||||||
|
while ( (m%2) == 0 ) m/=2;
|
||||||
|
while ( (m%3) == 0 ) m/=3;
|
||||||
|
while ( (m%5) == 0 ) m/=5;
|
||||||
|
if (m<=1)
|
||||||
|
break; /* n is completely factorable by twos, threes, and fives */
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
@ -107,6 +107,11 @@ void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout
|
|||||||
void kiss_fft_cleanup(void);
|
void kiss_fft_cleanup(void);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
|
||||||
|
*/
|
||||||
|
int kiss_fft_next_fast_size(int n);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,6 +23,10 @@ int main(int argc,char ** argv)
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case 'n':
|
case 'n':
|
||||||
nfft = atoi (optarg);
|
nfft = atoi (optarg);
|
||||||
|
if (nfft != kiss_fft_next_fast_size(nfft) ) {
|
||||||
|
int ng = kiss_fft_next_fast_size(nfft);
|
||||||
|
fprintf(stderr,"warning: %d might be a better choice for speed than %d\n",ng,nfft);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
numffts = atoi (optarg);
|
numffts = atoi (optarg);
|
||||||
|
@ -73,7 +73,7 @@ kiss_fftnd_cfg kiss_fftnd_alloc(const int *dims,int ndims,int inverse_fft,void*m
|
|||||||
st->states[i] = kiss_fft_alloc (st->dims[i], inverse_fft, ptr,&len);
|
st->states[i] = kiss_fft_alloc (st->dims[i], inverse_fft, ptr,&len);
|
||||||
ptr += len;
|
ptr += len;
|
||||||
}
|
}
|
||||||
if ( ptr - (char*)st != memneeded ) {
|
if ( ptr - (char*)st != (int)memneeded ) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"################################################################################\n"
|
"################################################################################\n"
|
||||||
"Internal error! Memory allocation miscalculation\n"
|
"Internal error! Memory allocation miscalculation\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user