[PATCH] osmo-trx[master]: sigProcLib: Remove trigonometric tables

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Tom Tsou gerrit-no-reply at lists.osmocom.org
Sat Jun 17 00:25:57 UTC 2017


Review at  https://gerrit.osmocom.org/2941

sigProcLib: Remove trigonometric tables

Trigonometric sin/cos tables are unused after initialization.
There is no benefit to implementing lookup tables for run-once
operations. Also perform initial calculations in double width
because there is no penalty for doing so.

Change-Id: I45bba5daf8610cbba6af95b92c2142f2256491ff
---
M Transceiver52M/sigProcLib.cpp
1 file changed, 8 insertions(+), 36 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/41/2941/1

diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index a72ec43..c776501 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -46,14 +46,10 @@
 #define CLIP_THRESH		30000.0f
 
 /** Lookup tables for trigonometric approximation */
-static float cosTable[TABLESIZE+1]; // add 1 element for wrap around
-static float sinTable[TABLESIZE+1];
-static float sincTable[TABLESIZE+1];
+static float sincTable[TABLESIZE+1]; // add 1 element for wrap around
 
 /** Constants */
 static const float M_PI_F = (float)M_PI;
-static const float M_2PI_F = (float)(2.0*M_PI);
-static const float M_1_2PI_F = 1/M_2PI_F;
 
 /* Precomputed rotation vectors */
 static signalVector *GMSKRotation4 = NULL;
@@ -182,29 +178,6 @@
   return Energy;
 }
 
-/** compute e^(-jx) via lookup table. */
-static complex expjLookup(float x)
-{
-  float arg = x*M_1_2PI_F;
-  while (arg > 1.0F) arg -= 1.0F;
-  while (arg < 0.0F) arg += 1.0F;
-
-  const float argT = arg*((float)TABLESIZE);
-  const int argI = (int)argT;
-  const float delta = argT-argI;
-  const float iDelta = 1.0F-delta;
-   return complex(iDelta*cosTable[argI] + delta*cosTable[argI+1],
-		   iDelta*sinTable[argI] + delta*sinTable[argI+1]);
-}
-
-/** Library setup functions */
-static void initTrigTables() {
-  for (int i = 0; i < TABLESIZE+1; i++) {
-    cosTable[i] = cos(2.0*M_PI*i/TABLESIZE);
-    sinTable[i] = sin(2.0*M_PI*i/TABLESIZE);
-  }
-}
-
 /*
  * Initialize 4 sps and 1 sps rotation tables
  */
@@ -216,11 +189,11 @@
   GMSKReverseRotation4 = new signalVector(len4);
   signalVector::iterator rotPtr = GMSKRotation4->begin();
   signalVector::iterator revPtr = GMSKReverseRotation4->begin();
-  float phase = 0.0;
+  auto phase = 0.0;
   while (rotPtr != GMSKRotation4->end()) {
-    *rotPtr++ = expjLookup(phase);
-    *revPtr++ = expjLookup(-phase);
-    phase += M_PI_F / 2.0F / 4.0;
+    *rotPtr++ = complex(cos(phase), sin(phase));
+    *revPtr++ = complex(cos(-phase), sin(-phase));
+    phase += M_PI / 2.0 / 4.0;
   }
 
   GMSKRotation1 = new signalVector(len1);
@@ -229,9 +202,9 @@
   revPtr = GMSKReverseRotation1->begin();
   phase = 0.0;
   while (rotPtr != GMSKRotation1->end()) {
-    *rotPtr++ = expjLookup(phase);
-    *revPtr++ = expjLookup(-phase);
-    phase += M_PI_F / 2.0F;
+    *rotPtr++ = complex(cos(phase), sin(phase));
+    *revPtr++ = complex(cos(-phase), sin(-phase));
+    phase += M_PI / 2.0;
   }
 }
 
@@ -1887,7 +1860,6 @@
 
 bool sigProcLibSetup()
 {
-  initTrigTables();
   generateSincTable();
   initGMSKRotationTables();
 

-- 
To view, visit https://gerrit.osmocom.org/2941
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45bba5daf8610cbba6af95b92c2142f2256491ff
Gerrit-PatchSet: 1
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Tom Tsou <tom at tsou.cc>



More information about the gerrit-log mailing list