summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-03-17 18:20:59 -0400
committerTom Rondeau <trondeau@vt.edu>2013-03-17 18:20:59 -0400
commit842db35f8e379df7f8bc8171f13bbe02f3ab0cfd (patch)
treef5e95fb5c5c7a1de6fc54af563a182e3cbcfc3e0 /gnuradio-core/src/lib
parentcab7429540a5790d4fe0997c3fa056386ebaca5f (diff)
core: moving core sincos functions back into core to act as deps for anything else.
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r--gnuradio-core/src/lib/CMakeLists.txt1
-rw-r--r--gnuradio-core/src/lib/filter/CMakeLists.txt38
-rw-r--r--gnuradio-core/src/lib/general/CMakeLists.txt11
-rw-r--r--gnuradio-core/src/lib/general/gr_sincos.c (renamed from gnuradio-core/src/lib/filter/gr_sincos.c)0
-rw-r--r--gnuradio-core/src/lib/general/gr_sincos.h (renamed from gnuradio-core/src/lib/filter/gr_sincos.h)0
-rw-r--r--gnuradio-core/src/lib/general/qa_general.cc2
-rw-r--r--gnuradio-core/src/lib/general/qa_sincos.cc75
-rw-r--r--gnuradio-core/src/lib/general/qa_sincos.h47
8 files changed, 135 insertions, 39 deletions
diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt
index cb3dd18273..b5a41ec430 100644
--- a/gnuradio-core/src/lib/CMakeLists.txt
+++ b/gnuradio-core/src/lib/CMakeLists.txt
@@ -27,7 +27,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/ConfigChecks.cmake)
########################################################################
GR_INCLUDE_SUBDIRECTORY(missing)
GR_INCLUDE_SUBDIRECTORY(runtime)
-GR_INCLUDE_SUBDIRECTORY(filter)
GR_INCLUDE_SUBDIRECTORY(general)
GR_INCLUDE_SUBDIRECTORY(io)
diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt
deleted file mode 100644
index 5c7250c1ea..0000000000
--- a/gnuradio-core/src/lib/filter/CMakeLists.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2010-2011 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.
-
-########################################################################
-# This file included, use CMake directory variables
-########################################################################
-
-########################################################################
-# Append gnuradio-core library sources
-########################################################################
-list(APPEND gnuradio_core_sources
- ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c
-)
-
-########################################################################
-# Install runtime headers
-########################################################################
-install(FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h
- DESTINATION ${GR_INCLUDE_DIR}/gnuradio
- COMPONENT "core_devel"
-)
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt
index 820f300f10..08e5a003c0 100644
--- a/gnuradio-core/src/lib/general/CMakeLists.txt
+++ b/gnuradio-core/src/lib/general/CMakeLists.txt
@@ -53,6 +53,7 @@ list(APPEND gnuradio_core_sources
${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_random.cc
${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.c
${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.cc
${CMAKE_CURRENT_SOURCE_DIR}/malloc16.c
)
@@ -64,6 +65,7 @@ list(APPEND test_gnuradio_core_sources
${CMAKE_CURRENT_SOURCE_DIR}/qa_general.cc
${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_circular_file.cc
${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_math.cc
+ ${CMAKE_CURRENT_SOURCE_DIR}/qa_sincos.cc
)
########################################################################
@@ -79,6 +81,7 @@ install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/gr_misc.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_random.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_reverse.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/gr_sincos.h
${CMAKE_CURRENT_SOURCE_DIR}/gr_test_types.h
${CMAKE_CURRENT_SOURCE_DIR}/gri_debugger_hook.h
${CMAKE_CURRENT_SOURCE_DIR}/gri_lfsr_15_1_0.h
@@ -121,3 +124,11 @@ foreach(file_tt ${gr_core_general_triple_threats})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file_tt}.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig")
endif(ENABLE_PYTHON)
endforeach(file_tt ${gr_core_general_triple_threats})
+
+CHECK_CXX_SOURCE_COMPILES("
+ #define _GNU_SOURCE
+ #include <math.h>
+ int main(){double x, sin, cos; sincos(x, &sin, &cos); return 0;}
+ " HAVE_SINCOS
+)
+GR_ADD_COND_DEF(HAVE_SINCOS)
diff --git a/gnuradio-core/src/lib/filter/gr_sincos.c b/gnuradio-core/src/lib/general/gr_sincos.c
index a8d01b0da4..a8d01b0da4 100644
--- a/gnuradio-core/src/lib/filter/gr_sincos.c
+++ b/gnuradio-core/src/lib/general/gr_sincos.c
diff --git a/gnuradio-core/src/lib/filter/gr_sincos.h b/gnuradio-core/src/lib/general/gr_sincos.h
index 516f43437a..516f43437a 100644
--- a/gnuradio-core/src/lib/filter/gr_sincos.h
+++ b/gnuradio-core/src/lib/general/gr_sincos.h
diff --git a/gnuradio-core/src/lib/general/qa_general.cc b/gnuradio-core/src/lib/general/qa_general.cc
index e2328c2cb2..0fce7d2379 100644
--- a/gnuradio-core/src/lib/general/qa_general.cc
+++ b/gnuradio-core/src/lib/general/qa_general.cc
@@ -28,6 +28,7 @@
#include <qa_general.h>
#include <qa_gr_circular_file.h>
#include <qa_gr_math.h>
+#include <qa_sincos.h>
CppUnit::TestSuite *
qa_general::suite ()
@@ -36,6 +37,7 @@ qa_general::suite ()
s->addTest (qa_gr_circular_file::suite ());
s->addTest (qa_gr_math::suite ());
+ s->addTest(gr::analog::qa_sincos::suite());
return s;
}
diff --git a/gnuradio-core/src/lib/general/qa_sincos.cc b/gnuradio-core/src/lib/general/qa_sincos.cc
new file mode 100644
index 0000000000..0066ff6b92
--- /dev/null
+++ b/gnuradio-core/src/lib/general/qa_sincos.cc
@@ -0,0 +1,75 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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 <qa_sincos.h>
+#include <gr_sincos.h>
+#include <gruel/attributes.h>
+#include <cppunit/TestAssert.h>
+#include <cmath>
+
+namespace gr {
+ namespace analog {
+
+ void
+ qa_sincos::t1()
+ {
+ static const unsigned int N = 1000;
+ double c_sin, c_cos;
+ double gr_sin, gr_cos;
+
+ for(unsigned i = 0; i < N; i++) {
+ double x = i/100.0;
+ c_sin = sin(x);
+ c_cos = cos(x);
+
+ gr_sincos(x, &gr_sin, &gr_cos);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001);
+ }
+ }
+
+ void
+ qa_sincos::t2()
+ {
+ static const unsigned int N = 1000;
+ float c_sin, c_cos;
+ float gr_sin, gr_cos;
+
+ for(unsigned i = 0; i < N; i++) {
+ float x = i/100.0;
+ c_sin = sinf(x);
+ c_cos = cosf(x);
+
+ gr_sincosf(x, &gr_sin, &gr_cos);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001);
+ }
+ }
+
+ } /* namespace analog */
+} /* namespace gr */
diff --git a/gnuradio-core/src/lib/general/qa_sincos.h b/gnuradio-core/src/lib/general/qa_sincos.h
new file mode 100644
index 0000000000..f18e879dd8
--- /dev/null
+++ b/gnuradio-core/src/lib/general/qa_sincos.h
@@ -0,0 +1,47 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2012 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.
+ */
+
+#ifndef _QA_ANALOG_SINCOS_H_
+#define _QA_ANALOG_SINCOS_H_
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+namespace gr {
+ namespace analog {
+
+ class qa_sincos : public CppUnit::TestCase
+ {
+ CPPUNIT_TEST_SUITE(qa_sincos);
+ CPPUNIT_TEST(t1);
+ CPPUNIT_TEST(t2);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void t1();
+ void t2();
+ };
+
+ } /* namespace analog */
+} /* namespace gr */
+
+#endif /* _QA_ANALOG_SINCOS_H_ */