summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/math/gen_sine_table.py
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/lib/math/gen_sine_table.py')
-rw-r--r--gnuradio-runtime/lib/math/gen_sine_table.py20
1 files changed, 4 insertions, 16 deletions
diff --git a/gnuradio-runtime/lib/math/gen_sine_table.py b/gnuradio-runtime/lib/math/gen_sine_table.py
index b84f9b2f3e..ae31b6b81a 100644
--- a/gnuradio-runtime/lib/math/gen_sine_table.py
+++ b/gnuradio-runtime/lib/math/gen_sine_table.py
@@ -11,14 +11,9 @@
import math
import sys
-def wrap (x):
- if x >= 2**31:
- return x - 2**32
- return x
-
def gen_approx_table (f, nentries, min_x, max_x):
"""return a list of nentries containing tuples of the form:
- (m, c, abs_error). min_x and max_x specify the domain
+ (m, c). min_x and max_x specify the domain
of the table.
"""
r = []
@@ -27,9 +22,8 @@ def gen_approx_table (f, nentries, min_x, max_x):
a = (i * incx) + min_x
b = ((i + 1) * incx) + min_x
m = (f(b)-f(a)) / (b-a)
- c = (3.0*a+b)*(f(a)-f(b))/(4.0*(b-a)) + (f((a+b)/2.0) + f(a))/2.0
- abs_error = c+m*a-f(a)
- r.append ((m, c, abs_error))
+ c = f(a)
+ r.append ((m, c))
return r
def scaled_sine (x):
@@ -45,19 +39,13 @@ def gen_sine_table ():
max_x = 2**32-1
t = gen_approx_table (scaled_sine, nentries, min_x, max_x)
- max_error = 0
- for e in t:
- max_error = max (max_error, abs (e[2]))
-
# sys.stdout.write ('static const int WORDBITS = 32;\n')
# sys.stdout.write ('static const int NBITS = %d;\n' % (nbits,))
- sys.stdout.write (' // max_error = %22.15e\n' % (max_error,))
-
# sys.stdout.write ('static const double sine_table[%d][2] = {\n'% (nentries,))
for e in t:
- sys.stdout.write (' { %22.15e, %22.15e },\n' % (2.0 * e[0], e[1]))
+ sys.stdout.write (' { %22.15e, %22.15e },\n' % (e[0], e[1]))
# sys.stdout.write ('};\n')