aboutsummaryrefslogtreecommitdiffstats
path: root/Transceiver52M/sigProcLib.cpp
diff options
context:
space:
mode:
authorTom Tsou <tom.tsou@ettus.com>2017-06-16 17:14:31 -0700
committerTom Tsou <tom@tsou.cc>2017-06-19 17:04:04 +0000
commita3dce85ffca6b3eceb0bcd84719797a6443a217c (patch)
treef63f6fea23a8500536733bf7abbb9650448dfb96 /Transceiver52M/sigProcLib.cpp
parentbb0c68ae61757a470e5c90783b190815faf057d8 (diff)
sigProcLib: Use explicit NaN check in sinc table generation
Using "x < 0.01" is a crude check for detecting NaN condition, which occurs in a sinc call when x = 0 due to divide-by-zero. Use stdlib isnan() call for this purpose. Also, as the table is created only once during initialization, use double floats for table value generation. Change-Id: I3a838fe3139fa977dfe906246020a14451185714
Diffstat (limited to 'Transceiver52M/sigProcLib.cpp')
-rw-r--r--Transceiver52M/sigProcLib.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index c776501..9d1ef49 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -979,16 +979,10 @@ signalVector *modulateBurst(const BitVector &wBurst, int guardPeriodLength,
static void generateSincTable()
{
- float x;
-
for (int i = 0; i < TABLESIZE; i++) {
- x = (float) i / TABLESIZE * 8 * M_PI;
- if (fabs(x) < 0.01) {
- sincTable[i] = 1.0f;
- continue;
- }
-
- sincTable[i] = sinf(x) / x;
+ auto x = (double) i / TABLESIZE * 8 * M_PI;
+ auto y = sin(x) / x;
+ sincTable[i] = isnan(y) ? 1.0 : y;
}
}