[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7374 - gnuradio/branches/developers/trondeau/receiver
From: |
trondeau |
Subject: |
[Commit-gnuradio] r7374 - gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general |
Date: |
Mon, 7 Jan 2008 16:31:35 -0700 (MST) |
Author: trondeau
Date: 2008-01-07 16:31:34 -0700 (Mon, 07 Jan 2008)
New Revision: 7374
Modified:
gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general/gr_math.h
gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general/qa_gr_math.cc
Log:
Adding branchless 0deg quad slicer
Modified:
gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general/gr_math.h
===================================================================
---
gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general/gr_math.h
2008-01-07 22:31:04 UTC (rev 7373)
+++
gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general/gr_math.h
2008-01-07 23:31:34 UTC (rev 7374)
@@ -109,7 +109,7 @@
static inline unsigned int gr_quad_0deg_slicer(float r, float i)
{
unsigned int ret = 0;
- if(fabs(r) > fabs(i)) {
+ if(fabsf(r) > fabsf(i)) {
if(r > 0)
ret = 0;
else
@@ -141,6 +141,20 @@
return (x >= 0);
}
+static inline unsigned int gr_branchless_quad_0deg_slicer(float r, float i)
+{
+ unsigned int ret = 0;
+ ret = (fabsf(r) > fabsf(i)) * (((r < 0) << 0x1)); // either 0 (00) or
2 (10)
+ ret |= (fabsf(i) > fabsf(r)) * (((i < 0) << 0x1) | 0x1); // either 1 (01) or
3 (11)
+
+ return ret;
+}
+
+static inline unsigned int gr_branchless_quad_0deg_slicer(gr_complex x)
+{
+ return gr_branchless_quad_0deg_slicer(x.real(), x.imag());
+}
+
static inline unsigned int gr_branchless_quad_45deg_slicer(float r, float i)
{
char ret = (r <= 0);
Modified:
gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general/qa_gr_math.cc
===================================================================
---
gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general/qa_gr_math.cc
2008-01-07 22:31:04 UTC (rev 7373)
+++
gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general/qa_gr_math.cc
2008-01-07 23:31:34 UTC (rev 7374)
@@ -34,17 +34,17 @@
//printf("\nBinary\n");
for (unsigned int i = 0; i < 5; i++) {
y = gr_binary_slicer(x[i]);
+ //printf("in: %f out: %d desired: %d\n", x[i], y, z[i]);
+
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
-
- //printf("in: %f out: %d desired: %d\n", x[i], y, z[i]);
}
//printf("\nBranchless Binary\n");
for (unsigned int i = 0; i < 5; i++) {
y = gr_branchless_binary_slicer(x[i]);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
-
//printf("in: %f out: %d desired: %d\n", x[i], y, z[i]);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
}
}
@@ -62,9 +62,17 @@
//printf("\nQuad0\n");
for (unsigned int i = 0; i < 4; i++) {
y = gr_quad_0deg_slicer(x[i]);
+ //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(),
x[i].imag(), y, z[i]);
+
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
+ }
+
+ //printf("\nBranchless Quad0\n");
+ for (unsigned int i = 0; i < 4; i++) {
+ y = gr_branchless_quad_0deg_slicer(x[i]);
+ //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(),
x[i].imag(), y, z[i]);
- //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(),
x[i].imag(), y, z[i]);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
}
}
@@ -82,16 +90,16 @@
//printf("\nQuad45\n");
for (unsigned int i = 0; i < 4; i++) {
y = gr_quad_45deg_slicer(x[i]);
+ //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(),
x[i].imag(), y, z[i]);
+
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
-
- //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(),
x[i].imag(), y, z[i]);
}
//printf("\nBranchless Quad45\n");
for (unsigned int i = 0; i < 4; i++) {
y = gr_branchless_quad_45deg_slicer(x[i]);
+ //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(),
x[i].imag(), y, z[i]);
+
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
-
- //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(),
x[i].imag(), y, z[i]);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7374 - gnuradio/branches/developers/trondeau/receiver/gnuradio-core/src/lib/general,
trondeau <=