diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-08-21 18:56:25 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-09-28 13:36:48 +0200 |
commit | 63ae20781af39e9cb6673e910e99e28f86c6adb0 (patch) | |
tree | cc4594c0bb887d0d4746c86516b7d7d485fb775b /src/OfdmGenerator.cpp | |
parent | 571d57c591b23d212934f0bb969c33d15c729982 (diff) | |
download | dabmod-63ae20781af39e9cb6673e910e99e28f86c6adb0.tar.gz dabmod-63ae20781af39e9cb6673e910e99e28f86c6adb0.tar.bz2 dabmod-63ae20781af39e9cb6673e910e99e28f86c6adb0.zip |
Normalise the CFR FFT
Diffstat (limited to 'src/OfdmGenerator.cpp')
-rw-r--r-- | src/OfdmGenerator.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp index 41c1c85..8d1a560 100644 --- a/src/OfdmGenerator.cpp +++ b/src/OfdmGenerator.cpp @@ -173,6 +173,10 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut) myNumClip = 0; myNumErrorClip = 0; + // It is not guaranteed that fftw keeps the FFT input vector intact. + // That's why we copy it to the reference. + std::vector<complexf> reference; + for (size_t i = 0; i < myNbSymbols; ++i) { myFftIn[0][0] = 0; myFftIn[0][1] = 0; @@ -183,7 +187,6 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut) memcpy(&myFftIn[myNegDst], &in[myNegSrc], myNegSize * sizeof(FFT_TYPE)); - std::vector<complexf> reference; if (myCfr) { reference.resize(mySpacing); memcpy(reference.data(), myFftIn, mySpacing * sizeof(FFT_TYPE)); @@ -240,8 +243,13 @@ void OfdmGenerator::cfr_one_iteration(complexf *symbol, const complexf *referenc const float err_clip_squared = myCfrErrorClip * myCfrErrorClip; for (size_t i = 0; i < mySpacing; i++) { + // FFTW computes an unnormalised trasform, i.e. a FFT-IFFT pair + // or vice-versa give back the original vector scaled by a factor + // FFT-size. Because we're comparing our constellation point + // (calculated with IFFT-clip-FFT) against reference (input to + // the IFFT), we need to divide by our FFT size. const complexf constellation_point = - reinterpret_cast<complexf*>(myCfrPostFft)[i]; + reinterpret_cast<complexf*>(myCfrPostFft)[i] / (float)mySpacing; complexf error = reference[i] - constellation_point; |