summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/math
diff options
context:
space:
mode:
authorAndrej Rode <mail@andrejro.de>2018-02-17 23:24:10 +0100
committerAndrej Rode <mail@andrejro.de>2018-02-17 23:24:10 +0100
commit886ce0f13b4135c1206c26786e06a524e92fc271 (patch)
treefdf89824d4a5925c44f9b30d1e8d44b713c46b19 /gnuradio-runtime/lib/math
parent201031790ec8c855ec2eaf7883652ad37b164208 (diff)
math: replace M_PI and derivatives with GR_M_PI defines
Diffstat (limited to 'gnuradio-runtime/lib/math')
-rw-r--r--gnuradio-runtime/lib/math/qa_fxpt.cc17
-rw-r--r--gnuradio-runtime/lib/math/qa_fxpt_nco.cc12
-rw-r--r--gnuradio-runtime/lib/math/random.cc6
-rw-r--r--gnuradio-runtime/lib/math/vco.h14
4 files changed, 28 insertions, 21 deletions
diff --git a/gnuradio-runtime/lib/math/qa_fxpt.cc b/gnuradio-runtime/lib/math/qa_fxpt.cc
index d3aadf85b1..5b045a69a1 100644
--- a/gnuradio-runtime/lib/math/qa_fxpt.cc
+++ b/gnuradio-runtime/lib/math/qa_fxpt.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -26,6 +26,7 @@
#include <qa_fxpt.h>
#include <gnuradio/fxpt.h>
+#include <gnuradio/math.h>
#include <cppunit/TestAssert.h>
#include <iostream>
#include <stdio.h>
@@ -37,9 +38,9 @@ static const float SIN_COS_TOLERANCE = 1e-5;
void
qa_fxpt::t0()
{
- CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/2, gr::fxpt::fixed_to_float(0x40000000), SIN_COS_TOLERANCE);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(GR_M_PI/2, gr::fxpt::fixed_to_float(0x40000000), SIN_COS_TOLERANCE);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, gr::fxpt::fixed_to_float(0x00000000), SIN_COS_TOLERANCE);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-M_PI, gr::fxpt::fixed_to_float(0x80000000), SIN_COS_TOLERANCE);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-GR_M_PI, gr::fxpt::fixed_to_float(0x80000000), SIN_COS_TOLERANCE);
if(0) {
/*
@@ -51,9 +52,9 @@ qa_fxpt::t0()
* sometimes the answer is off by a few bits at the bottom.
* Hence, the disabled check.
*/
- CPPUNIT_ASSERT_EQUAL((int32_t)0x40000000, gr::fxpt::float_to_fixed(M_PI/2));
+ CPPUNIT_ASSERT_EQUAL((int32_t)0x40000000, gr::fxpt::float_to_fixed(GR_M_PI/2));
CPPUNIT_ASSERT_EQUAL((int32_t)0, gr::fxpt::float_to_fixed(0));
- CPPUNIT_ASSERT_EQUAL((int32_t)0x80000000, gr::fxpt::float_to_fixed(-M_PI));
+ CPPUNIT_ASSERT_EQUAL((int32_t)0x80000000, gr::fxpt::float_to_fixed(-GR_M_PI));
}
}
@@ -70,7 +71,7 @@ qa_fxpt::t1()
CPPUNIT_ASSERT_DOUBLES_EQUAL(-1, gr::fxpt::sin(-0x40000000), SIN_COS_TOLERANCE);
CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.707106781, gr::fxpt::sin(-0x20000000), SIN_COS_TOLERANCE);
- for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) {
+ for(float p = -GR_M_PI; p < GR_M_PI; p += 2 * GR_M_PI / 3600) {
float expected = sin(p);
float actual = gr::fxpt::sin(gr::fxpt::float_to_fixed (p));
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, SIN_COS_TOLERANCE);
@@ -80,7 +81,7 @@ qa_fxpt::t1()
void
qa_fxpt::t2()
{
- for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) {
+ for(float p = -GR_M_PI; p < GR_M_PI; p += 2 * GR_M_PI / 3600) {
float expected = cos(p);
float actual = gr::fxpt::cos(gr::fxpt::float_to_fixed(p));
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, SIN_COS_TOLERANCE);
@@ -90,7 +91,7 @@ qa_fxpt::t2()
void
qa_fxpt::t3()
{
- for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) {
+ for(float p = -GR_M_PI; p < GR_M_PI; p += 2 * GR_M_PI / 3600) {
float expected_sin = sin(p);
float expected_cos = cos(p);
float actual_sin;
diff --git a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
index 16ea120381..0b1ef16dd9 100644
--- a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
+++ b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -27,6 +27,8 @@
#include <qa_fxpt_nco.h>
#include <gnuradio/fxpt_nco.h>
#include <gnuradio/nco.h>
+#include <gnuradio/math.h>
+
#include <cppunit/TestAssert.h>
#include <iostream>
#include <stdio.h>
@@ -52,8 +54,8 @@ qa_fxpt_nco::t0()
gr::fxpt_nco new_nco;
double max_error = 0, max_phase_error = 0;
- ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
- new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
+ ref_nco.set_freq((float)(2 * GR_M_PI / SIN_COS_FREQ));
+ new_nco.set_freq((float)(2 * GR_M_PI / SIN_COS_FREQ));
CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE);
@@ -90,8 +92,8 @@ qa_fxpt_nco::t1()
gr_complex* new_block = new gr_complex[SIN_COS_BLOCK_SIZE];
double max_error = 0;
- ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
- new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ));
+ ref_nco.set_freq((float)(2 * GR_M_PI / SIN_COS_FREQ));
+ new_nco.set_freq((float)(2 * GR_M_PI / SIN_COS_FREQ));
CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE);
diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc
index 5ebe174914..152db77b78 100644
--- a/gnuradio-runtime/lib/math/random.cc
+++ b/gnuradio-runtime/lib/math/random.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2002, 2015 Free Software Foundation, Inc.
+ * Copyright 2002,2015,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -39,8 +39,10 @@
#include <config.h>
#endif
-#include <math.h>
#include <gnuradio/random.h>
+#include <gnuradio/math.h>
+
+#include <cmath>
namespace gr {
diff --git a/gnuradio-runtime/lib/math/vco.h b/gnuradio-runtime/lib/math/vco.h
index d8a6fbb415..7ac1e1ca6d 100644
--- a/gnuradio-runtime/lib/math/vco.h
+++ b/gnuradio-runtime/lib/math/vco.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2013 Free Software Foundation, Inc.
+ * Copyright 2005,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -25,6 +25,8 @@
#include <gnuradio/sincos.h>
#include <gnuradio/gr_complex.h>
+#include <gnuradio/math.h>
+
#include <vector>
#include <cmath>
@@ -49,13 +51,13 @@ namespace gr {
void adjust_phase(double delta_phase) {
d_phase += delta_phase;
- if(fabs (d_phase) > M_PI){
+ if(fabs (d_phase) > GR_M_PI){
- while(d_phase > M_PI)
- d_phase -= 2*M_PI;
+ while(d_phase > GR_M_PI)
+ d_phase -= 2*GR_M_PI;
- while(d_phase < -M_PI)
- d_phase += 2*M_PI;
+ while(d_phase < -GR_M_PI)
+ d_phase += 2*GR_M_PI;
}
}