summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau2011-01-22 15:23:51 -0500
committerTom Rondeau2011-01-22 15:23:51 -0500
commitf54dde22e71bf393ad4519d099384af38d43ee72 (patch)
treea38eed0332586e457ce4b7c8f586fa9ce74b6d3e
parent85759ff0f893b9377b156609d68c6453feb304c9 (diff)
parent48f9ca90e0cbcbfe67b0e10889c60928d9be5c49 (diff)
downloadgnuradio-f54dde22e71bf393ad4519d099384af38d43ee72.tar.gz
gnuradio-f54dde22e71bf393ad4519d099384af38d43ee72.tar.bz2
gnuradio-f54dde22e71bf393ad4519d099384af38d43ee72.zip
Merge branch 'mergeme/math/gr_math_simplification' into next
-rw-r--r--config/lf_cxx.m417
-rw-r--r--gnuradio-core/src/lib/general/Makefile.am1
-rw-r--r--gnuradio-core/src/lib/general/gr_math.cc102
-rw-r--r--gnuradio-core/src/lib/general/gr_math.h13
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.cc3
-rw-r--r--gr-atsc/src/lib/atsci_equalizer_lms2.cc5
-rw-r--r--gr-atsc/src/lib/atsci_sssr.cc3
-rw-r--r--gr-howto-write-a-block/config/lf_cxx.m417
-rw-r--r--volk/config/lf_cxx.m417
9 files changed, 7 insertions, 171 deletions
diff --git a/config/lf_cxx.m4 b/config/lf_cxx.m4
index dfc6bfbfe..7cce5f8a4 100644
--- a/config/lf_cxx.m4
+++ b/config/lf_cxx.m4
@@ -46,22 +46,5 @@ AC_DEFUN([LF_CXX_PORTABILITY],[
dnl Check for common C++ portability problems
dnl
- dnl AC_LANG_PUSH
- dnl AC_LANG_CPLUSPLUS
- AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
-
-
- dnl Test whether C++ has std::isnan
- AC_MSG_CHECKING(whether C++ has std::isnan)
- AC_TRY_COMPILE([#include <cmath>], [
- std::isnan(0);
-], [ AC_MSG_RESULT(yes)
- AC_DEFINE(CXX_HAS_STD_ISNAN,[],[Define if has std::isnan]) ],
- [ AC_MSG_RESULT(no) ])
-
- dnl Done with the portability checks
- dnl AC_LANG_POP([C++])
- AC_LANG_RESTORE
])
diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am
index 08610c58a..3ceea7a6d 100644
--- a/gnuradio-core/src/lib/general/Makefile.am
+++ b/gnuradio-core/src/lib/general/Makefile.am
@@ -100,7 +100,6 @@ libgeneral_la_SOURCES = \
gr_lms_dfe_cc.cc \
gr_lms_dfe_ff.cc \
gr_map_bb.cc \
- gr_math.cc \
gr_misc.cc \
gr_mpsk_receiver_cc.cc \
gr_nlog10_ff.cc \
diff --git a/gnuradio-core/src/lib/general/gr_math.cc b/gnuradio-core/src/lib/general/gr_math.cc
deleted file mode 100644
index 82dff469c..000000000
--- a/gnuradio-core/src/lib/general/gr_math.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2003 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gr_math.h>
-#include <math.h>
-
-/*
- * Greatest Common Divisor, using Euclid's algorithm.
- * [There are faster algorithms. See Knuth 4.5.2 if you care]
- */
-
-long
-gr_gcd (long m, long n)
-{
- if (m < 0)
- m = -m;
-
- if (n < 0)
- n = -n;
-
- while (n != 0){
- long t = m % n;
- m = n;
- n = t;
- }
-
- return m;
-}
-
-
-/*
- * These really need some configure hacking to figure out the right answer.
- * As a stop gap, try for a macro, and if not that, then try std::
- */
-
-// returns a non-zero value if value is "not-a-number" (NaN), and 0 otherwise
-
-#if defined(isnan) || !defined(CXX_HAS_STD_ISNAN)
-
-int
-gr_isnan (double value)
-{
- return isnan (value);
-}
-
-#else
-
-int
-gr_isnan (double value)
-{
- return std::isnan (value);
-}
-
-#endif
-
-// returns a non-zero value if the value of x has its sign bit set.
-//
-// This is not the same as `x < 0.0', because IEEE 754 floating point
-// allows zero to be signed. The comparison `-0.0 < 0.0' is false, but
-// `gr_signbit (-0.0)' will return a nonzero value.
-
-#ifdef signbit
-
-int
-gr_signbit (double x)
-{
- return signbit (x);
-}
-
-#else
-
-int
-gr_signbit (double x)
-{
- return std::signbit (x);
-}
-
-
-#endif
diff --git a/gnuradio-core/src/lib/general/gr_math.h b/gnuradio-core/src/lib/general/gr_math.h
index ea0f20027..f5935c1da 100644
--- a/gnuradio-core/src/lib/general/gr_math.h
+++ b/gnuradio-core/src/lib/general/gr_math.h
@@ -35,19 +35,6 @@ gr_is_power_of_2(long x)
return x != 0 && (x & (x-1)) == 0;
}
-long gr_gcd (long m, long n);
-
-// returns a non-zero value if value is "not-a-number" (NaN), and 0 otherwise
-int gr_isnan (double value);
-
-// returns a non-zero value if the value of x has its sign bit set.
-//
-// This is not the same as `x < 0.0', because IEEE 754 floating point
-// allows zero to be signed. The comparison `-0.0 < 0.0' is false, but
-// `gr_signbit (-0.0)' will return a nonzero value.
-
-int gr_signbit (double x);
-
/*!
* \brief Fast arc tangent using table lookup and linear interpolation
* \ingroup misc
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc
index 03d5a8738..fa3722714 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.cc
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc
@@ -31,6 +31,7 @@
#include <iostream>
#include <assert.h>
#include <algorithm>
+#include <boost/math/common_factor_rt.hpp>
static long s_buffer_count = 0; // counts for debugging storage mgmt
static long s_buffer_reader_count = 0;
@@ -73,7 +74,7 @@ static long s_buffer_reader_count = 0;
static long
minimum_buffer_items (long type_size, long page_size)
{
- return page_size / gr_gcd (type_size, page_size);
+ return page_size / boost::math::gcd (type_size, page_size);
}
diff --git a/gr-atsc/src/lib/atsci_equalizer_lms2.cc b/gr-atsc/src/lib/atsci_equalizer_lms2.cc
index 345f6209f..f9fb57c7b 100644
--- a/gr-atsc/src/lib/atsci_equalizer_lms2.cc
+++ b/gr-atsc/src/lib/atsci_equalizer_lms2.cc
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <gr_math.h>
#include <stdio.h>
+#include <boost/math/special_functions/fpclassify.hpp>
using std::min;
using std::max;
@@ -55,7 +56,7 @@ wrap (int d)
static inline float
slice (float d)
{
- if (gr_isnan (d))
+ if (boost::math::isnan (d))
return 0.0;
if (d >= 0.0){
@@ -247,7 +248,7 @@ atsci_equalizer_lms2::filter1 (const float input[])
acc -= d_taps_fb[i] * d_old_output[wrap(i + d_output_ptr)];
}
- if (gr_isnan (acc)){
+ if (boost::math::isnan (acc)){
abort ();
}
diff --git a/gr-atsc/src/lib/atsci_sssr.cc b/gr-atsc/src/lib/atsci_sssr.cc
index dc5c01b0d..4ccee85de 100644
--- a/gr-atsc/src/lib/atsci_sssr.cc
+++ b/gr-atsc/src/lib/atsci_sssr.cc
@@ -28,6 +28,7 @@
#include <atsci_diag_output.h>
#include <gr_math.h>
#include <stdio.h>
+#include <boost/math/special_functions/sign.hpp>
/*
* ----------------------------------------------------------------
@@ -141,7 +142,7 @@ atsci_sssr::update (sssr::sample_t sample_in, // input
double qo = d_quad_filter.update (sample_in);
d_quad_output[d_counter] = qo;
- int bit = gr_signbit (sample_in) ^ 1; // slice on sign: + => 1, - => 0
+ int bit = boost::math::signbit (sample_in) ^ 1; // slice on sign: + => 1, - => 0
int corr_out = d_correlator.update (bit);
int weight = sipp (corr_out);
int corr_value = d_integrator.update (weight, d_counter);
diff --git a/gr-howto-write-a-block/config/lf_cxx.m4 b/gr-howto-write-a-block/config/lf_cxx.m4
index dfc6bfbfe..7cce5f8a4 100644
--- a/gr-howto-write-a-block/config/lf_cxx.m4
+++ b/gr-howto-write-a-block/config/lf_cxx.m4
@@ -46,22 +46,5 @@ AC_DEFUN([LF_CXX_PORTABILITY],[
dnl Check for common C++ portability problems
dnl
- dnl AC_LANG_PUSH
- dnl AC_LANG_CPLUSPLUS
- AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
-
-
- dnl Test whether C++ has std::isnan
- AC_MSG_CHECKING(whether C++ has std::isnan)
- AC_TRY_COMPILE([#include <cmath>], [
- std::isnan(0);
-], [ AC_MSG_RESULT(yes)
- AC_DEFINE(CXX_HAS_STD_ISNAN,[],[Define if has std::isnan]) ],
- [ AC_MSG_RESULT(no) ])
-
- dnl Done with the portability checks
- dnl AC_LANG_POP([C++])
- AC_LANG_RESTORE
])
diff --git a/volk/config/lf_cxx.m4 b/volk/config/lf_cxx.m4
index dfc6bfbfe..7cce5f8a4 100644
--- a/volk/config/lf_cxx.m4
+++ b/volk/config/lf_cxx.m4
@@ -46,22 +46,5 @@ AC_DEFUN([LF_CXX_PORTABILITY],[
dnl Check for common C++ portability problems
dnl
- dnl AC_LANG_PUSH
- dnl AC_LANG_CPLUSPLUS
- AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
-
-
- dnl Test whether C++ has std::isnan
- AC_MSG_CHECKING(whether C++ has std::isnan)
- AC_TRY_COMPILE([#include <cmath>], [
- std::isnan(0);
-], [ AC_MSG_RESULT(yes)
- AC_DEFINE(CXX_HAS_STD_ISNAN,[],[Define if has std::isnan]) ],
- [ AC_MSG_RESULT(no) ])
-
- dnl Done with the portability checks
- dnl AC_LANG_POP([C++])
- AC_LANG_RESTORE
])