diff options
author | Tom Rondeau | 2012-10-15 10:56:40 -0400 |
---|---|---|
committer | Tom Rondeau | 2012-10-15 10:56:40 -0400 |
commit | d4cec71c426653edbe1d2c552388f20939f09a8e (patch) | |
tree | bf561792c9c0c1de977bd844f018abcb1c8e6c04 /gr-digital/lib/digital_constellation.cc | |
parent | 136050324a6f5023a6b549b158fef1a0de9e1d79 (diff) | |
parent | a5f794128d8386ff0067cbe2928af4ded728d3b2 (diff) | |
download | gnuradio-d4cec71c426653edbe1d2c552388f20939f09a8e.tar.gz gnuradio-d4cec71c426653edbe1d2c552388f20939f09a8e.tar.bz2 gnuradio-d4cec71c426653edbe1d2c552388f20939f09a8e.zip |
Merge remote-tracking branch 'benreynwar/master_constellation_scale'
Diffstat (limited to 'gr-digital/lib/digital_constellation.cc')
-rw-r--r-- | gr-digital/lib/digital_constellation.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gr-digital/lib/digital_constellation.cc b/gr-digital/lib/digital_constellation.cc index d9a53c493..da79f2caa 100644 --- a/gr-digital/lib/digital_constellation.cc +++ b/gr-digital/lib/digital_constellation.cc @@ -49,6 +49,17 @@ digital_constellation::digital_constellation (std::vector<gr_complex> constellat d_rotational_symmetry(rotational_symmetry), d_dimensionality(dimensionality) { + // Scale constellation points so that average magnitude is 1. + float summed_mag = 0; + unsigned int constsize = d_constellation.size(); + for (unsigned int i=0; i<constsize; i++) { + gr_complex c = d_constellation[i]; + summed_mag += sqrt(c.real()*c.real() + c.imag()*c.imag()); + } + d_scalefactor = constsize/summed_mag; + for (unsigned int i=0; i<constsize; i++) { + d_constellation[i] = d_constellation[i]*d_scalefactor; + } if (pre_diff_code.size() == 0) d_apply_pre_diff_code = false; else if (pre_diff_code.size() != constellation.size()) @@ -293,6 +304,8 @@ digital_constellation_rect::digital_constellation_rect (std::vector<gr_complex> n_real_sectors(real_sectors), n_imag_sectors(imag_sectors), d_width_real_sectors(width_real_sectors), d_width_imag_sectors(width_imag_sectors) { + d_width_real_sectors *= d_scalefactor; + d_width_imag_sectors *= d_scalefactor; find_sector_values(); } |