summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/general
diff options
context:
space:
mode:
authorMartin Braun2010-12-09 09:54:42 +0100
committerMartin Braun2010-12-09 09:54:42 +0100
commitdd35f129cc0ecbbf092a25a60414fef133e6dc04 (patch)
treebc703a861f6952ff53e07ddff3db2340fb485641 /gnuradio-core/src/lib/general
parent5155713e970946e2ce213c4f68ccc44e6737ead0 (diff)
downloadgnuradio-dd35f129cc0ecbbf092a25a60414fef133e6dc04.tar.gz
gnuradio-dd35f129cc0ecbbf092a25a60414fef133e6dc04.tar.bz2
gnuradio-dd35f129cc0ecbbf092a25a60414fef133e6dc04.zip
more elaborate checks, they also work now
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r--gnuradio-core/src/lib/general/gr_cpm.cc6
-rw-r--r--gnuradio-core/src/lib/general/qa_gr_cpm.cc62
2 files changed, 53 insertions, 15 deletions
diff --git a/gnuradio-core/src/lib/general/gr_cpm.cc b/gnuradio-core/src/lib/general/gr_cpm.cc
index a5d328edf..f2d032a22 100644
--- a/gnuradio-core/src/lib/general/gr_cpm.cc
+++ b/gnuradio-core/src/lib/general/gr_cpm.cc
@@ -113,7 +113,7 @@ generate_cpm_lrec_taps(unsigned samples_per_sym, unsigned L)
//! Helper function for TFM
double tfm_g0(double k, double sps)
{
- if (k < 2 * DBL_EPSILON) {
+ if (fabs(k) < 2 * DBL_EPSILON) {
return 1.145393004159143; // 1 + pi^2/48 / sqrt(2)
}
@@ -131,13 +131,13 @@ double tfm_g0(double k, double sps)
std::vector<float>
generate_cpm_tfm_taps(unsigned sps, unsigned L)
{
- double causal_shift = (double) L * sps / 2;
+ unsigned causal_shift = sps * L / 2;
std::vector<double> taps_d(sps * L, 0.0);
std::vector<float> taps(sps * L, 0.0);
double sum = 0;
for (unsigned i = 0; i < sps * L; i++) {
- double k = (double)i - causal_shift; // Causal to acausal
+ double k = (double)(((int)i) - ((int)causal_shift)); // Causal to acausal
taps_d[i] = tfm_g0(k - sps, sps) +
2 * tfm_g0(k, sps) +
diff --git a/gnuradio-core/src/lib/general/qa_gr_cpm.cc b/gnuradio-core/src/lib/general/qa_gr_cpm.cc
index 20d72968a..fe76feadd 100644
--- a/gnuradio-core/src/lib/general/qa_gr_cpm.cc
+++ b/gnuradio-core/src/lib/general/qa_gr_cpm.cc
@@ -24,14 +24,53 @@
#include <gr_cpm.h>
#include <cppunit/TestAssert.h>
+#include <iostream>
+using std::cout;
+using std::endl;
+
const double DELTA = 1e-5;
+const int L = 5;
+const int samples_per_sym = 4;
+const float taps_lrc[20] = {
+ 0, 0.002447174185242, 0.009549150281253, 0.020610737385376,
+ 0.034549150281253, 0.050000000000000, 0.065450849718747, 0.079389262614624,
+ 0.090450849718747, 0.097552825814758, 0.100000000000000, 0.097552825814758,
+ 0.090450849718747, 0.079389262614624, 0.065450849718747, 0.050000000000000,
+ 0.034549150281253, 0.020610737385376, 0.009549150281253, 0.002447174185242
+};
+
+
+const float taps_lsrc[20] = { // beta = 0.2
+ 0.000000000000000, 0.009062686687436, 0.019517618142920, 0.030875041875917,
+ 0.042552315421249, 0.053912556756416, 0.064308860403517, 0.073130584159352,
+ 0.079847961304114, 0.084051371489937, 0.085482007518284, 0.084051371489937,
+ 0.079847961304114, 0.073130584159352, 0.064308860403517, 0.053912556756416,
+ 0.042552315421249, 0.030875041875917, 0.019517618142920, 0.009062686687436
+};
+
+
+const float taps_tfm[20] = {
+ -0.003946522220317, -0.005147757690530, -0.003171631690177, 0.003959659609805,
+ 0.017498721302356, 0.037346982678383, 0.062251889790391, 0.087364237065604,
+ 0.110049050955117, 0.125677762224511, 0.132288693729399, 0.125677762224511,
+ 0.110049050955117, 0.087364237065604, 0.062251889790391, 0.037346982678383,
+ 0.017498721302356, 0.003959659609805, -0.003171631690177, -0.005147757690530
+};
+
+
+const float taps_gaussian[20] = { // BT = 0.3
+ 0.000000743866524, 0.000009286258371, 0.000085441834550, 0.000581664421923,
+ 0.002945540765422, 0.011178079812344, 0.032117220937421, 0.070841188736816,
+ 0.122053715366673, 0.167389736919915, 0.185594670675172, 0.167389736919915,
+ 0.122053715366673, 0.070841188736816, 0.032117220937421, 0.011178079812344,
+ 0.002945540765422, 0.000581664421923, 0.000085441834550, 0.000009286258371
+};
+
// Check LREC phase response
void
qa_gr_cpm::t1 ()
{
- int L = 5;
- int samples_per_sym = 4;
std::vector<float> taps(gr_cpm::phase_response(gr_cpm::LREC, samples_per_sym, L));
for (int i = 0; i < L * samples_per_sym; i++) {
@@ -44,17 +83,15 @@ qa_gr_cpm::t1 ()
void
qa_gr_cpm::t2 ()
{
- int L = 5;
- int samples_per_sym = 4;
std::vector<float> taps(gr_cpm::phase_response(gr_cpm::LRC, samples_per_sym, L));
float sum = 0;
for (int i = 0; i < L * samples_per_sym; i++) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_lrc[i], DELTA);
sum += taps[i];
}
CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[L*samples_per_sym/2], 0.1, DELTA);
}
@@ -62,12 +99,11 @@ qa_gr_cpm::t2 ()
void
qa_gr_cpm::t3 ()
{
- int L = 5;
- int samples_per_sym = 4;
std::vector<float> taps(gr_cpm::phase_response(gr_cpm::LSRC, samples_per_sym, L, 0.2));
float sum = 0;
for (int i = 0; i < L * samples_per_sym; i++) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_lsrc[i], DELTA);
sum += taps[i];
}
@@ -79,12 +115,13 @@ qa_gr_cpm::t3 ()
void
qa_gr_cpm::t4 ()
{
- int L = 5;
- int samples_per_sym = 4;
std::vector<float> taps(gr_cpm::phase_response(gr_cpm::TFM, samples_per_sym, L));
float sum = 0;
+ cout << "TFM" << endl;
for (int i = 0; i < L * samples_per_sym; i++) {
+ cout << "i=" << i << " " << taps[i] << "?=" << taps_tfm[i] << endl;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_tfm[i], DELTA);
sum += taps[i];
}
@@ -96,15 +133,16 @@ qa_gr_cpm::t4 ()
void
qa_gr_cpm::t5 ()
{
- int L = 5;
- int samples_per_sym = 4;
std::vector<float> taps(gr_cpm::phase_response(gr_cpm::GAUSSIAN, samples_per_sym, L, 0.3));
float sum = 0;
for (int i = 0; i < L * samples_per_sym; i++) {
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(taps[i], taps_gaussian[i], DELTA);
sum += taps[i];
}
- CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, 1e-4);
+ // Need to cut this guy some slack; in theory, sum only equals one for
+ // L => infinity
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(sum, 1.0, DELTA);
}