2
* Copyright 2008 Free Software Foundation, Inc.
4
* This file is part of GNU Radio
6
* GNU Radio is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3, or (at your option)
11
* GNU Radio is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GNU Radio; see the file COPYING. If not, write to
18
* the Free Software Foundation, Inc., 51 Franklin Street,
19
* Boston, MA 02110-1301, USA.
23
#include <qa_gr_math.h>
24
#include <cppunit/TestAssert.h>
28
qa_gr_math::test_binary_slicer1 ()
30
float x[5] = {-1, -0.5, 0, 0.5, 1.0};
31
unsigned int z[5] = {0, 0, 1, 1, 1};
34
//printf("\nBinary\n");
35
for (unsigned int i = 0; i < 5; i++) {
36
y = gr_binary_slicer(x[i]);
37
//printf("in: %f out: %d desired: %d\n", x[i], y, z[i]);
39
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
42
//printf("\nBranchless Binary\n");
43
for (unsigned int i = 0; i < 5; i++) {
44
y = gr_branchless_binary_slicer(x[i]);
45
//printf("in: %f out: %d desired: %d\n", x[i], y, z[i]);
47
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
52
qa_gr_math::test_quad_0deg_slicer1 ()
54
gr_complex x[4] = {gr_complex(1, 0),
59
unsigned int z[4] = {0, 1, 2, 3};
62
//printf("\nQuad0\n");
63
for (unsigned int i = 0; i < 4; i++) {
64
y = gr_quad_0deg_slicer(x[i]);
65
//printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(), x[i].imag(), y, z[i]);
67
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
70
//printf("\nBranchless Quad0\n");
71
for (unsigned int i = 0; i < 4; i++) {
72
y = gr_branchless_quad_0deg_slicer(x[i]);
73
//printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(), x[i].imag(), y, z[i]);
75
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
80
qa_gr_math::test_quad_45deg_slicer1 ()
82
gr_complex x[4] = {gr_complex(0.707, 0.707),
83
gr_complex(-0.707, 0.707),
84
gr_complex(-0.707, -0.707),
85
gr_complex(0.707, -0.707)};
87
unsigned int z[4] = {0, 1, 2, 3};
90
//printf("\nQuad45\n");
91
for (unsigned int i = 0; i < 4; i++) {
92
y = gr_quad_45deg_slicer(x[i]);
93
//printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(), x[i].imag(), y, z[i]);
95
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);
98
//printf("\nBranchless Quad45\n");
99
for (unsigned int i = 0; i < 4; i++) {
100
y = gr_branchless_quad_45deg_slicer(x[i]);
101
//printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(), x[i].imag(), y, z[i]);
103
CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9);