summaryrefslogtreecommitdiff
path: root/gnuradio-runtime
diff options
context:
space:
mode:
authorTom Rondeau <tom@trondeau.com>2014-12-04 10:31:10 -0500
committerTom Rondeau <tom@trondeau.com>2014-12-04 10:31:10 -0500
commit8236ec001ecacc8580325209bb79fee622939926 (patch)
treeb3a41dd6a70e1b59cb1c20188b47889672d3ae4d /gnuradio-runtime
parentb2e6c0f247784ba4119cd6aa32998e7fcfa43f77 (diff)
parentec05c9bf90dcf612ba3e8b52a5d74df82a4ac868 (diff)
Merge branch 'maint'
Diffstat (limited to 'gnuradio-runtime')
-rw-r--r--gnuradio-runtime/lib/math/fast_atan2f.cc18
-rw-r--r--gnuradio-runtime/lib/math/qa_fast_atan2f.cc46
-rw-r--r--gnuradio-runtime/python/gnuradio/gr/__init__.py12
3 files changed, 40 insertions, 36 deletions
diff --git a/gnuradio-runtime/lib/math/fast_atan2f.cc b/gnuradio-runtime/lib/math/fast_atan2f.cc
index 20e21be32b..f968310ff8 100644
--- a/gnuradio-runtime/lib/math/fast_atan2f.cc
+++ b/gnuradio-runtime/lib/math/fast_atan2f.cc
@@ -31,7 +31,7 @@ namespace gr {
#define TAN_MAP_RES 0.003921569 /* (smallest non-zero value in table) */
#define RAD_PER_DEG 0.017453293
- #define TAN_MAP_SIZE 256
+ #define TAN_MAP_SIZE 255
/* arctangents from 0 to pi/4 radians */
static float
@@ -99,8 +99,8 @@ namespace gr {
7.551044e-01, 7.571798e-01, 7.592472e-01, 7.613064e-01,
7.633576e-01, 7.654008e-01, 7.674360e-01, 7.694633e-01,
7.714826e-01, 7.734940e-01, 7.754975e-01, 7.774932e-01,
- 7.794811e-01, 7.814612e-01, 7.834335e-01, 7.853983e-01,
- 7.853983e-01
+ 7.794811e-01, 7.814612e-01, 7.834335e-01, 7.853982e-01,
+ 7.853982e-01
};
@@ -118,7 +118,7 @@ namespace gr {
determine the final angle value in the range of -180 to 180
degrees. Note that this function uses the small angle approximation
for values close to zero. This routine calculates the arc tangent
- with an average error of +/- 0.045 degrees.
+ with an average error of +/- 3.56e-5 degrees (6.21e-7 radians).
*****************************************************************************/
float
@@ -135,7 +135,6 @@ namespace gr {
if(!((y_abs > 0.0f) || (x_abs > 0.0f)))
return 0.0;
- //z = (y_abs < x_abs ? y_abs / x_abs : x_abs / y_abs);
if(y_abs < x_abs)
z = y_abs / x_abs;
else
@@ -147,14 +146,13 @@ namespace gr {
base_angle = z;
else {
/* find index and interpolation value */
- alpha = z * (float)TAN_MAP_SIZE - .5;
- index = (int)alpha & 0xff;
+ alpha = z * (float)TAN_MAP_SIZE;
+ index = ((int)alpha) & 0xff;
alpha -= (float)index;
/* determine base angle based on quadrant and */
/* add or subtract table value from base angle based on quadrant */
- base_angle = fast_atan_table[index];
- base_angle +=
- (fast_atan_table[index + 1] - fast_atan_table[index]) * alpha;
+ base_angle = fast_atan_table[index];
+ base_angle += (fast_atan_table[index + 1] - fast_atan_table[index]) * alpha;
}
if(x_abs > y_abs) { /* -45 -> 45 or 135 -> 225 */
diff --git a/gnuradio-runtime/lib/math/qa_fast_atan2f.cc b/gnuradio-runtime/lib/math/qa_fast_atan2f.cc
index b704756798..154998f79a 100644
--- a/gnuradio-runtime/lib/math/qa_fast_atan2f.cc
+++ b/gnuradio-runtime/lib/math/qa_fast_atan2f.cc
@@ -47,11 +47,11 @@ qa_fast_atan2f::t1()
for(float j =-N/2; i < N/2; i++) {
float x = i/10.0;
float y = j/10.0;
- c_atan2 = atan2(x, y);
+ c_atan2 = atan2(y, x);
- gr_atan2f = gr::fast_atan2f(x, y);
+ gr_atan2f = gr::fast_atan2f(y, x);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0);
}
}
}
@@ -69,71 +69,69 @@ qa_fast_atan2f::t2()
/* Test x as INF */
x = inf;
y = 0;
- c_atan2 = atan2(x, y);
- gr_atan2f = gr::fast_atan2f(x, y);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0001);
+ c_atan2 = atan2(y, x);
+ gr_atan2f = gr::fast_atan2f(y, x);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0);
x = -inf;
y = 0;
- c_atan2 = atan2(x, y);
- gr_atan2f = gr::fast_atan2f(x, y);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0001);
+ c_atan2 = atan2(y, x);
+ gr_atan2f = gr::fast_atan2f(y, x);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0);
/* Test y as INF */
x = 0;
y = inf;
- c_atan2 = atan2(x, y);
- gr_atan2f = gr::fast_atan2f(x, y);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0001);
+ c_atan2 = atan2(y, x);
+ gr_atan2f = gr::fast_atan2f(y, x);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0);
x = 0;
y = -inf;
- c_atan2 = atan2(x, y);
- gr_atan2f = gr::fast_atan2f(x, y);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0001);
+ c_atan2 = atan2(y, x);
+ gr_atan2f = gr::fast_atan2f(y, x);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0);
/* Test x and y as INF */
x = inf;
y = inf;
- gr_atan2f = gr::fast_atan2f(x, y);
+ gr_atan2f = gr::fast_atan2f(y, x);
CPPUNIT_ASSERT(isnan(gr_atan2f));
/* Test x as NAN */
x = nan;
y = 0;
- gr_atan2f = gr::fast_atan2f(x, y);
+ gr_atan2f = gr::fast_atan2f(y, x);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0f, gr_atan2f, 0.0001);
x = -nan;
y = 0;
- gr_atan2f = gr::fast_atan2f(x, y);
+ gr_atan2f = gr::fast_atan2f(y, x);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0f, gr_atan2f, 0.0001);
/* Test y as NAN */
x = 0;
y = nan;
- gr_atan2f = gr::fast_atan2f(x, y);
+ gr_atan2f = gr::fast_atan2f(y, x);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0f, gr_atan2f, 0.0001);
x = 0;
y = -nan;
- gr_atan2f = gr::fast_atan2f(x, y);
+ gr_atan2f = gr::fast_atan2f(y, x);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0f, gr_atan2f, 0.0001);
-
/* Test mixed NAN and INF */
x = inf;
y = nan;
- gr_atan2f = gr::fast_atan2f(x, y);
+ gr_atan2f = gr::fast_atan2f(y, x);
CPPUNIT_ASSERT(isnan(gr_atan2f));
x = nan;
y = inf;
- gr_atan2f = gr::fast_atan2f(x, y);
+ gr_atan2f = gr::fast_atan2f(y, x);
CPPUNIT_ASSERT(isnan(gr_atan2f));
}
-
diff --git a/gnuradio-runtime/python/gnuradio/gr/__init__.py b/gnuradio-runtime/python/gnuradio/gr/__init__.py
index 4fc55c68b2..9717390e3e 100644
--- a/gnuradio-runtime/python/gnuradio/gr/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/gr/__init__.py
@@ -50,9 +50,17 @@ from gateway import basic_block, sync_block, decim_block, interp_block
prefs = prefs.singleton
log = gr.logger("log")
-log.add_console_appender(prefs().get_string("LOG", "log_level", "off"), 'gr::log %d :%p: %m%n')
log.set_level(prefs().get_string("LOG", "log_level", "notset"))
+log_file = gr.prefs().get_string("LOG", "log_file", "");
+if(log_file == "stderr" or log_file == "stdout"):
+ log.add_console_appender(log_file, "gr::log %d :%p: %m%n")
+else:
+ log.add_file_appender(log_file, True, "%r :%p: %c{1} - %m%n")
log_debug = gr.logger("log_debug")
-log_debug.add_console_appender(prefs().get_string("LOG", "debug_level", "off"), 'gr::debug %d :%p: %m%n')
log_debug.set_level(prefs().get_string("LOG", "debug_level", "notset"))
+log_debug_file = gr.prefs().get_string("LOG", "debug_file", "");
+if(log_debug_file == "stderr" or log_file == "stdout"):
+ log_debug.add_console_appender(log_debug_file, "gr::log %d :%p: %m%n")
+else:
+ log_debug.add_file_appender(log_debug_file, True, "%r :%p: %c{1} - %m%n")