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)'
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
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
for(i = 0; i < ntaps(); i++) {
out += d_buffer[d_idx + i] * d_taps[i];
}
- return out;
+ return (gr_complex)out;
}
void
for (int i = 0; i < ntaps; i++) {
sum += input[i] * taps[i];
}
-
return sum;
}
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;
}
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
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
for (int i = 0; i < ntaps; i++) {
sum += input[i] * taps[i];
}
-
- return sum;
+ return (o_type)sum;
}
//
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;
}