COMMON: Refactoring of FFT class to remove repeated fft<x>() functions.

The repeated functions expanded from the original DECL_FFT macros are
now replaced by a recursive fft() function.
This commit is contained in:
D G Turner 2012-04-17 20:23:38 +01:00
parent 422334da5a
commit aa61c9abd3
2 changed files with 15 additions and 147 deletions

View File

@ -218,104 +218,8 @@ void FFT::fft16(Complex *z) {
TRANSFORM(z[3], z[7], z[11], z[15], cosTable[3], cosTable[1]);
}
void FFT::fft32(Complex *z) {
fft16(z);
fft8(z + 8 * 2);
fft8(z + 8 * 3);
assert(_cosTables[1]);
pass(z, _cosTables[1]->getTable(), 8 / 2);
}
void FFT::fft64(Complex *z) {
fft32(z);
fft16(z + 16 * 2);
fft16(z + 16 * 3);
assert(_cosTables[2]);
pass(z, _cosTables[2]->getTable(), 16 / 2);
}
void FFT::fft128(Complex *z) {
fft64(z);
fft32(z + 32 * 2);
fft32(z + 32 * 3);
assert(_cosTables[3]);
pass(z, _cosTables[3]->getTable(), 32 / 2);
}
void FFT::fft256(Complex *z) {
fft128(z);
fft64(z + 64 * 2);
fft64(z + 64 * 3);
assert(_cosTables[4]);
pass(z, _cosTables[4]->getTable(), 64 / 2);
}
void FFT::fft512(Complex *z) {
fft256(z);
fft128(z + 128 * 2);
fft128(z + 128 * 3);
assert(_cosTables[5]);
pass(z, _cosTables[5]->getTable(), 128 / 2);
}
void FFT::fft1024(Complex *z) {
fft512(z);
fft256(z + 256 * 2);
fft256(z + 256 * 3);
assert(_cosTables[6]);
pass_big(z, _cosTables[6]->getTable(), 256 / 2);
}
void FFT::fft2048(Complex *z) {
fft1024(z);
fft512(z + 512 * 2);
fft512(z + 512 * 3);
assert(_cosTables[7]);
pass_big(z, _cosTables[7]->getTable(), 512 / 2);
}
void FFT::fft4096(Complex *z) {
fft2048(z);
fft1024(z + 1024 * 2);
fft1024(z + 1024 * 3);
assert(_cosTables[8]);
pass_big(z, _cosTables[8]->getTable(), 1024 / 2);
}
void FFT::fft8192(Complex *z) {
fft4096(z);
fft2048(z + 2048 * 2);
fft2048(z + 2048 * 3);
assert(_cosTables[9]);
pass_big(z, _cosTables[9]->getTable(), 2048 / 2);
}
void FFT::fft16384(Complex *z) {
fft8192(z);
fft4096(z + 4096 * 2);
fft4096(z + 4096 * 3);
assert(_cosTables[10]);
pass_big(z, _cosTables[10]->getTable(), 4096 / 2);
}
void FFT::fft32768(Complex *z) {
fft16384(z);
fft8192(z + 8192 * 2);
fft8192(z + 8192 * 3);
assert(_cosTables[11]);
pass_big(z, _cosTables[11]->getTable(), 8192 / 2);
}
void FFT::fft65536(Complex *z) {
fft32768(z);
fft16384(z + 16384 * 2);
fft16384(z + 16384 * 3);
assert(_cosTables[12]);
pass_big(z, _cosTables[12]->getTable(), 16384 / 2);
}
void FFT::calc(Complex *z) {
switch (_bits) {
void FFT::fft(int n, int logn, Complex *z) {
switch (logn) {
case 2:
fft4(z);
break;
@ -325,45 +229,20 @@ void FFT::calc(Complex *z) {
case 4:
fft16(z);
break;
case 5:
fft32(z);
break;
case 6:
fft64(z);
break;
case 7:
fft128(z);
break;
case 8:
fft256(z);
break;
case 9:
fft512(z);
break;
case 10:
fft1024(z);
break;
case 11:
fft2048(z);
break;
case 12:
fft4096(z);
break;
case 13:
fft8192(z);
break;
case 14:
fft16384(z);
break;
case 15:
fft32768(z);
break;
case 16:
fft65536(z);
break;
default:
error("Should Not Happen!");
fft((n / 2), logn - 1, z);
fft((n / 4), logn - 2, z + (n / 4) * 2);
fft((n / 4), logn - 2, z + (n / 4) * 3);
assert(_cosTables[logn - 4]);
if (n > 1024)
pass_big(z, _cosTables[logn - 4]->getTable(), (n / 4) / 2);
else
pass(z, _cosTables[logn - 4]->getTable(), (n / 4) / 2);
}
}
void FFT::calc(Complex *z) {
fft(1 << _bits, _bits, z);
}
} // End of namespace Common

View File

@ -76,18 +76,7 @@ private:
void fft4(Complex *z);
void fft8(Complex *z);
void fft16(Complex *z);
void fft32(Complex *z);
void fft64(Complex *z);
void fft128(Complex *z);
void fft256(Complex *z);
void fft512(Complex *z);
void fft1024(Complex *z);
void fft2048(Complex *z);
void fft4096(Complex *z);
void fft8192(Complex *z);
void fft16384(Complex *z);
void fft32768(Complex *z);
void fft65536(Complex *z);
void fft(int n, int logn, Complex *z);
};
} // End of namespace Common