summaryrefslogtreecommitdiff
path: root/gnuradio-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r--gnuradio-core/src/lib/gengen/Makefile.am6
-rw-r--r--gnuradio-core/src/lib/gengen/Makefile.gen18
-rwxr-xr-xgnuradio-core/src/lib/gengen/generate_common.py4
-rw-r--r--gnuradio-core/src/lib/gengen/gengen_generated.i12
-rw-r--r--gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t79
-rw-r--r--gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t51
-rw-r--r--gnuradio-core/src/lib/gengen/gr_argmax_XX.i.t34
-rw-r--r--gnuradio-core/src/lib/gengen/gr_max_XX.cc.t71
-rw-r--r--gnuradio-core/src/lib/gengen/gr_max_XX.h.t51
-rw-r--r--gnuradio-core/src/lib/gengen/gr_max_XX.i.t34
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/Makefile.am2
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/qa_argmax.py77
-rw-r--r--gnuradio-core/src/python/gnuradio/gr/qa_max.py56
13 files changed, 494 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/gengen/Makefile.am b/gnuradio-core/src/lib/gengen/Makefile.am
index c566570e2..7c585dda9 100644
--- a/gnuradio-core/src/lib/gengen/Makefile.am
+++ b/gnuradio-core/src/lib/gengen/Makefile.am
@@ -44,12 +44,18 @@ CODE_GENERATOR = \
gr_add_const_vXX.cc.t \
gr_add_const_vXX.h.t \
gr_add_const_vXX.i.t \
+ gr_argmax_XX.cc.t \
+ gr_argmax_XX.h.t \
+ gr_argmax_XX.i.t \
gr_chunks_to_symbols_XX.cc.t \
gr_chunks_to_symbols_XX.h.t \
gr_chunks_to_symbols_XX.i.t \
gr_divide_XX.cc.t \
gr_divide_XX.h.t \
gr_divide_XX.i.t \
+ gr_max_XX.cc.t \
+ gr_max_XX.h.t \
+ gr_max_XX.i.t \
gr_multiply_XX.cc.t \
gr_multiply_XX.h.t \
gr_multiply_XX.i.t \
diff --git a/gnuradio-core/src/lib/gengen/Makefile.gen b/gnuradio-core/src/lib/gengen/Makefile.gen
index adbceba10..ceb8692b4 100644
--- a/gnuradio-core/src/lib/gengen/Makefile.gen
+++ b/gnuradio-core/src/lib/gengen/Makefile.gen
@@ -19,6 +19,9 @@ GENERATED_H = \
gr_add_vff.h \
gr_add_vii.h \
gr_add_vss.h \
+ gr_argmax_fs.h \
+ gr_argmax_is.h \
+ gr_argmax_ss.h \
gr_chunks_to_symbols_bc.h \
gr_chunks_to_symbols_bf.h \
gr_chunks_to_symbols_ic.h \
@@ -29,6 +32,9 @@ GENERATED_H = \
gr_divide_ff.h \
gr_divide_ii.h \
gr_divide_ss.h \
+ gr_max_ff.h \
+ gr_max_ii.h \
+ gr_max_ss.h \
gr_multiply_cc.h \
gr_multiply_const_cc.h \
gr_multiply_const_ff.h \
@@ -103,6 +109,9 @@ GENERATED_I = \
gr_add_vff.i \
gr_add_vii.i \
gr_add_vss.i \
+ gr_argmax_fs.i \
+ gr_argmax_is.i \
+ gr_argmax_ss.i \
gr_chunks_to_symbols_bc.i \
gr_chunks_to_symbols_bf.i \
gr_chunks_to_symbols_ic.i \
@@ -113,6 +122,9 @@ GENERATED_I = \
gr_divide_ff.i \
gr_divide_ii.i \
gr_divide_ss.i \
+ gr_max_ff.i \
+ gr_max_ii.i \
+ gr_max_ss.i \
gr_multiply_cc.i \
gr_multiply_const_cc.i \
gr_multiply_const_ff.i \
@@ -187,6 +199,9 @@ GENERATED_CC = \
gr_add_vff.cc \
gr_add_vii.cc \
gr_add_vss.cc \
+ gr_argmax_fs.cc \
+ gr_argmax_is.cc \
+ gr_argmax_ss.cc \
gr_chunks_to_symbols_bc.cc \
gr_chunks_to_symbols_bf.cc \
gr_chunks_to_symbols_ic.cc \
@@ -197,6 +212,9 @@ GENERATED_CC = \
gr_divide_ff.cc \
gr_divide_ii.cc \
gr_divide_ss.cc \
+ gr_max_ff.cc \
+ gr_max_ii.cc \
+ gr_max_ss.cc \
gr_multiply_cc.cc \
gr_multiply_const_cc.cc \
gr_multiply_const_ff.cc \
diff --git a/gnuradio-core/src/lib/gengen/generate_common.py b/gnuradio-core/src/lib/gengen/generate_common.py
index 2ab0586df..aaf15f04a 100755
--- a/gnuradio-core/src/lib/gengen/generate_common.py
+++ b/gnuradio-core/src/lib/gengen/generate_common.py
@@ -59,7 +59,9 @@ others = (
('gr_unpacked_to_packed_XX', ('bb','ss','ii')),
('gr_packed_to_unpacked_XX', ('bb','ss','ii')),
('gr_sample_and_hold_XX', ('bb','ss','ii','ff')),
- ('gr_peak_detector_XX', ('ff','ii','ss'))
+ ('gr_peak_detector_XX', ('ff','ii','ss')),
+ ('gr_argmax_XX', ('fs','is','ss')),
+ ('gr_max_XX', ('ff','ii','ss')),
)
diff --git a/gnuradio-core/src/lib/gengen/gengen_generated.i b/gnuradio-core/src/lib/gengen/gengen_generated.i
index d5f874e61..bab1f03e6 100644
--- a/gnuradio-core/src/lib/gengen/gengen_generated.i
+++ b/gnuradio-core/src/lib/gengen/gengen_generated.i
@@ -19,6 +19,9 @@
#include <gr_add_vff.h>
#include <gr_add_vii.h>
#include <gr_add_vss.h>
+#include <gr_argmax_fs.h>
+#include <gr_argmax_is.h>
+#include <gr_argmax_ss.h>
#include <gr_chunks_to_symbols_bc.h>
#include <gr_chunks_to_symbols_bf.h>
#include <gr_chunks_to_symbols_ic.h>
@@ -29,6 +32,9 @@
#include <gr_divide_ff.h>
#include <gr_divide_ii.h>
#include <gr_divide_ss.h>
+#include <gr_max_ff.h>
+#include <gr_max_ii.h>
+#include <gr_max_ss.h>
#include <gr_multiply_cc.h>
#include <gr_multiply_const_cc.h>
#include <gr_multiply_const_ff.h>
@@ -103,6 +109,9 @@
%include <gr_add_vff.i>
%include <gr_add_vii.i>
%include <gr_add_vss.i>
+%include <gr_argmax_fs.i>
+%include <gr_argmax_is.i>
+%include <gr_argmax_ss.i>
%include <gr_chunks_to_symbols_bc.i>
%include <gr_chunks_to_symbols_bf.i>
%include <gr_chunks_to_symbols_ic.i>
@@ -113,6 +122,9 @@
%include <gr_divide_ff.i>
%include <gr_divide_ii.i>
%include <gr_divide_ss.i>
+%include <gr_max_ff.i>
+%include <gr_max_ii.i>
+%include <gr_max_ss.i>
%include <gr_multiply_cc.i>
%include <gr_multiply_const_cc.i>
%include <gr_multiply_const_ff.i>
diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t
new file mode 100644
index 000000000..85c272b4c
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_argmax_XX.cc.t
@@ -0,0 +1,79 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 2, 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME@.h>
+#include <gr_io_signature.h>
+
+@SPTR_NAME@
+gr_make_@BASE_NAME@ ( size_t vlen )
+{
+ return @SPTR_NAME@ ( new @NAME@(vlen));
+}
+
+@NAME@::@NAME@( size_t vlen)
+ : gr_sync_block ( "@BASE_NAME@",
+ gr_make_io_signature (1, -1, vlen*sizeof (@I_TYPE@)),
+ gr_make_io_signature (2, 2, sizeof (@O_TYPE@))),
+ d_vlen(vlen)
+{
+}
+
+
+int
+@NAME@::work( int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+
+ int ninputs = input_items.size ();
+
+ @O_TYPE@ *x_optr = (@O_TYPE@ *) output_items[0];
+ @O_TYPE@ *y_optr = (@O_TYPE@ *) output_items[1];
+
+ for (int i=0; i<noutput_items; i++) {
+
+ @I_TYPE@ max = 0;
+ int x = 0;
+ int y = 0;
+
+ for (int j=0; j < (int) d_vlen; j++ ) {
+ for (int k=0; k<ninputs; k++) {
+ if ( ((@I_TYPE@ *) input_items[k])[i*d_vlen + j] > max) {
+ max = ((@I_TYPE@ *) input_items[k])[i*d_vlen + j];
+ x = j;
+ y = k;
+ }
+ }
+ }
+
+ *x_optr++ = (@O_TYPE@) x;
+ *y_optr++ = (@O_TYPE@) y;
+ }
+ return noutput_items;
+}
+
diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t b/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t
new file mode 100644
index 000000000..ad8b04756
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_argmax_XX.h.t
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 2, 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gr_sync_block.h>
+
+class @NAME@;
+typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen);
+
+
+class @NAME@ : public gr_sync_block
+{
+ friend @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen);
+
+ @NAME@ (size_t vlen);
+ size_t d_vlen;
+
+ public:
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif
diff --git a/gnuradio-core/src/lib/gengen/gr_argmax_XX.i.t b/gnuradio-core/src/lib/gengen/gr_argmax_XX.i.t
new file mode 100644
index 000000000..c6c4f4366
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_argmax_XX.i.t
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 2, 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.
+ */
+
+// @WARNING@
+
+GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@)
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen);
+
+class @NAME@ : public gr_sync_block
+{
+ private:
+ @NAME@ (size_t vlen);
+ size_t d_vlen;
+};
diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_max_XX.cc.t
new file mode 100644
index 000000000..d91703634
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_max_XX.cc.t
@@ -0,0 +1,71 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 2, 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.
+ */
+
+// @WARNING@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <@NAME@.h>
+#include <gr_io_signature.h>
+
+@SPTR_NAME@
+gr_make_@BASE_NAME@ ( size_t vlen )
+{
+ return @SPTR_NAME@ ( new @NAME@(vlen));
+}
+
+@NAME@::@NAME@( size_t vlen)
+ : gr_sync_block ( "@BASE_NAME@",
+ gr_make_io_signature (1, -1, vlen*sizeof (@I_TYPE@)),
+ gr_make_io_signature (1, 1, sizeof (@O_TYPE@))),
+ d_vlen(vlen)
+{
+}
+
+int
+@NAME@::work( int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ @O_TYPE@ *optr = (@O_TYPE@ *) output_items[0];
+
+ int ninputs = input_items.size ();
+
+ for (int i=0; i<noutput_items; i++) {
+
+ @I_TYPE@ max = 0;
+
+ for (int j=0; j < (int) d_vlen; j++ ) {
+ for (int k=0; k<ninputs; k++) {
+ if ( ((@I_TYPE@ *) input_items[k])[i*d_vlen + j] > max) {
+ max = ((@I_TYPE@*) input_items[k])[i*d_vlen + j];
+ }
+ }
+ }
+
+ *optr++ = (@O_TYPE@) max;
+ }
+ return noutput_items;
+}
+
diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.h.t b/gnuradio-core/src/lib/gengen/gr_max_XX.h.t
new file mode 100644
index 000000000..ad8b04756
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_max_XX.h.t
@@ -0,0 +1,51 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 2, 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.
+ */
+
+// @WARNING@
+
+#ifndef @GUARD_NAME@
+#define @GUARD_NAME@
+
+#include <gr_sync_block.h>
+
+class @NAME@;
+typedef boost::shared_ptr<@NAME@> @SPTR_NAME@;
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen);
+
+
+class @NAME@ : public gr_sync_block
+{
+ friend @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen);
+
+ @NAME@ (size_t vlen);
+ size_t d_vlen;
+
+ public:
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+
+#endif
diff --git a/gnuradio-core/src/lib/gengen/gr_max_XX.i.t b/gnuradio-core/src/lib/gengen/gr_max_XX.i.t
new file mode 100644
index 000000000..c6c4f4366
--- /dev/null
+++ b/gnuradio-core/src/lib/gengen/gr_max_XX.i.t
@@ -0,0 +1,34 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 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 2, 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.
+ */
+
+// @WARNING@
+
+GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@)
+
+@SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen);
+
+class @NAME@ : public gr_sync_block
+{
+ private:
+ @NAME@ (size_t vlen);
+ size_t d_vlen;
+};
diff --git a/gnuradio-core/src/python/gnuradio/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am
index 175b36b60..557bf13f9 100644
--- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am
+++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am
@@ -48,6 +48,7 @@ noinst_PYTHON = \
qa_add_and_friends.py \
qa_add_v_and_friends.py \
qa_agc.py \
+ qa_argmax.py \
qa_basic_flow_graph.py \
qa_bin_statistics.py \
qa_cma_equalizer.py \
@@ -73,6 +74,7 @@ noinst_PYTHON = \
qa_interp_fir_filter.py \
qa_kludge_copy.py \
qa_kludged_imports.py \
+ qa_max.py \
qa_message.py \
qa_mute.py \
qa_nlog10.py \
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py b/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py
new file mode 100644
index 000000000..767c27786
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+#
+# Copyright 2007 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 2, 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.
+#
+
+from gnuradio import gr, gr_unittest
+import math
+
+
+class test_sig_source (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.fg = gr.flow_graph ()
+
+
+ def tearDown (self):
+ self.fg = None
+
+
+ def test_001(self):
+ fg = self.fg
+
+ src1_data = (0,0.2,-0.3,0,12,0)
+ src2_data = (0,0.0,3.0,0,10,0)
+ src3_data = (0,0.0,3.0,0,1,0)
+
+ src1 = gr.vector_source_f (src1_data)
+ s2v1 = gr.stream_to_vector(gr.sizeof_float, len(src1_data))
+ fg.connect( src1, s2v1 )
+
+ src2 = gr.vector_source_f (src2_data)
+ s2v2 = gr.stream_to_vector(gr.sizeof_float, len(src1_data))
+ fg.connect( src2, s2v2 )
+
+ src3 = gr.vector_source_f (src3_data)
+ s2v3 = gr.stream_to_vector(gr.sizeof_float, len(src1_data))
+ fg.connect( src3, s2v3 )
+
+ dst1 = gr.vector_sink_s ()
+ dst2 = gr.vector_sink_s ()
+ argmax = gr.argmax_fs (len(src1_data))
+
+ fg.connect (s2v1, (argmax, 0))
+ fg.connect (s2v2, (argmax, 1))
+ fg.connect (s2v3, (argmax, 2))
+
+ fg.connect ((argmax,0), dst1)
+ fg.connect ((argmax,1), dst2)
+
+ fg.run ()
+ index = dst1.data ()
+ source = dst2.data ()
+ self.assertEqual ( index, (4,))
+ self.assertEqual ( source, (0,))
+
+
+
+if __name__ == '__main__':
+ gr_unittest.main ()
+
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_max.py b/gnuradio-core/src/python/gnuradio/gr/qa_max.py
new file mode 100644
index 000000000..b9807734a
--- /dev/null
+++ b/gnuradio-core/src/python/gnuradio/gr/qa_max.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+#
+# Copyright 2007 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 2, 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.
+#
+
+from gnuradio import gr, gr_unittest
+import math
+
+
+class test_sig_source (gr_unittest.TestCase):
+
+ def setUp (self):
+ self.fg = gr.flow_graph ()
+
+
+ def tearDown (self):
+ self.fg = None
+
+
+ def test_001(self):
+
+ src_data = (0,0.2,-0.3,0,12,0)
+ expected_result = (float(max(src_data)), )
+
+ src = gr.vector_source_f(src_data)
+ s2v = gr.stream_to_vector(gr.sizeof_float, len(src_data))
+ op = gr.max_ff( len(src_data) )
+ dst = gr.vector_sink_f()
+
+
+ self.fg.connect(src, s2v, op, dst)
+ self.fg.run()
+ result_data = dst.data()
+ self.assertEqual(expected_result, result_data)
+
+
+if __name__ == '__main__':
+ gr_unittest.main ()
+