summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau2010-10-17 15:25:11 -0400
committerTom Rondeau2010-10-17 15:25:11 -0400
commitb9cbe9c9ca65b620cab9bf1b8e652637a885d3c2 (patch)
tree3969683ed73b38160d75fcb484edbd8fafba72e6
parent4a3fb7eb7481177ae35bb98307a1845a7304d97e (diff)
downloadgnuradio-b9cbe9c9ca65b620cab9bf1b8e652637a885d3c2.tar.gz
gnuradio-b9cbe9c9ca65b620cab9bf1b8e652637a885d3c2.tar.bz2
gnuradio-b9cbe9c9ca65b620cab9bf1b8e652637a885d3c2.zip
Fixing up filters a bit to pass QA tests for all versions.
-rwxr-xr-xgnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py11
-rw-r--r--gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t4
-rw-r--r--gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_ccf.cc2
-rw-r--r--gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc3
-rw-r--r--gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc18
5 files changed, 19 insertions, 19 deletions
diff --git a/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py b/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py
index 7252e26f7..f586b0c27 100755
--- a/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py
+++ b/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py
@@ -26,6 +26,15 @@ from generate_utils import *
roots = ['gri_fir_filter_with_buffer_XXX',]
+def code3_to_acc_code (code3):
+ if i_code (code3) == 'c' or o_code (code3) == 'c' or tap_code (code3) == 'c':
+ return 'c'
+ if i_code (code3) == 'f' or o_code (code3) == 'f' or tap_code (code3) == 'f':
+ return 'f'
+ if i_code (code3) == 'i' or o_code (code3) == 'i' or tap_code (code3) == 'i':
+ return 'i'
+ return 'i' # even short short short needs int accumulator
+
def code3_to_input_cast (code3):
if i_code (code3) == 's' and o_code (code3) == 'c':
return '(float)'
@@ -40,6 +49,8 @@ def init_dict (root, code3):
name = re.sub ('X+', code3, root)
d = standard_dict (name, code3)
d['INPUT_CAST'] = code3_to_input_cast (code3)
+ acc_code = code3_to_acc_code (code3)
+ d['ACC_TYPE'] = char_to_type[acc_code]
return d
diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t
index dd71a55fa..c0d061c81 100644
--- a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t
+++ b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t
@@ -70,11 +70,11 @@ void
if(d_idx >= ntaps())
d_idx = 0;
- @O_TYPE@ out = 0;
+ @ACC_TYPE@ out = 0;
for(i = 0; i < ntaps(); i++) {
out += @INPUT_CAST@ d_buffer[d_idx + i] * d_taps[i];
}
- return out;
+ return (@O_TYPE@)out;
}
void
diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_ccf.cc b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_ccf.cc
index 35020bb78..b2db8ce0a 100644
--- a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_ccf.cc
+++ b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_ccf.cc
@@ -74,7 +74,7 @@ gri_fir_filter_with_buffer_ccf::filter (gr_complex input)
for(i = 0; i < ntaps(); i++) {
out += d_buffer[d_idx + i] * d_taps[i];
}
- return out;
+ return (gr_complex)out;
}
void
diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc
index 518d98ab8..ce689a54b 100644
--- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc
+++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc
@@ -66,7 +66,6 @@ ref_dotprod (const i_type input[], const tap_type taps[], int ntaps)
for (int i = 0; i < ntaps; i++) {
sum += input[i] * taps[i];
}
-
return sum;
}
@@ -129,7 +128,7 @@ qa_gri_fir_filter_with_buffer_fff::t1 ()
for (int o = 0; o < ol; o++){
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_output[o], actual_output[o],
- abs (expected_output[o]) * ERR_DELTA);
+ fabsf (expected_output[o]) * ERR_DELTA);
}
delete f1;
}
diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc
index 1dc869ef7..f09a1d7ac 100644
--- a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc
+++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc
@@ -38,12 +38,10 @@
typedef float i_type;
typedef short o_type;
typedef float tap_type;
-typedef int acc_type;
+typedef float acc_type;
using std::vector;
-#define ERR_DELTA (1e-5)
-
#define NELEM(x) (sizeof (x) / sizeof (x[0]))
static float
@@ -56,7 +54,7 @@ static void
random_floats (float *buf, unsigned n)
{
for (unsigned i = 0; i < n; i++)
- buf[i] = (float) rint (uniform () * 32767);
+ buf[i] = (float) rint (uniform () * 128);
}
static o_type
@@ -66,8 +64,7 @@ ref_dotprod (const i_type input[], const tap_type taps[], int ntaps)
for (int i = 0; i < ntaps; i++) {
sum += input[i] * taps[i];
}
-
- return sum;
+ return (o_type)sum;
}
//
@@ -121,15 +118,8 @@ qa_gri_fir_filter_with_buffer_fsf::t1 ()
f1->filterN (actual_output, input, ol);
// check results
- //
- // we use a sloppy error margin because on the x86 architecture,
- // our reference implementation is using 80 bit floating point
- // arithmetic, while the SSE version is using 32 bit float point
- // arithmetic.
-
for (int o = 0; o < ol; o++){
- CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_output[o], actual_output[o],
- abs (expected_output[o]) * ERR_DELTA);
+ CPPUNIT_ASSERT_EQUAL(expected_output[o], actual_output[o]);
}
delete f1;
}