Expand description
Constellations, Gray mapping and hard decisions (OptiCommPy optic.comm.modulation).
§Constellations
A Constellation stores its M = 2^b points indexed by their bit label: the
point points()[i] carries the bits of i written on b bits, most significant
bit first. The points are those of OptiCommPy, not normalised:
- PAM:
{-(M-1), …, -1, 1, …, M-1}(minimum distance 2,E_s = (M²-1)/3); - square QAM: the Cartesian product of two
√M-PAM (E_s = 2(M-1)/3); - PSK:
e^{j2πk/M},k = 0..M-1(E_s = 1); - OOK:
{0, 1}.
The Gray labels are assigned as in OptiCommPy: the points are listed in their
construction order (PAM and PSK in increasing order; QAM row by row from the top,
every other row reversed, a “snake” that makes neighbouring points adjacent in the
list), and the i-th point of the list gets the Gray code i ⊕ (i >> 1). Two
nearest neighbours then differ by one bit, and the bits of a symbol stream are those
of OptiCommPy’s modulateGray.
Use Constellation::normalized for unit average energy (E_s = 1), the usual
convention of the simulations.
§Decisions
Constellation::decide returns the nearest point (the maximum-likelihood decision
over AWGN); the soft demapper is in crate::demapper.
§Examples
use comnum_mapping::constellation::{Constellation, ConstellationKind};
use comnum_math::C64;
let c = Constellation::qam(16).unwrap();
assert_eq!(c.points()[0], C64::new(-3.0, 3.0)); // label 0000
assert!((c.energy() - 10.0).abs() < 1e-12); // 2(M-1)/3
let x = c.map_bits(&[0, 0, 0, 1, 1, 0, 1, 1]).unwrap();
assert_eq!(x, vec![c.points()[1], c.points()[11]]);
// Gray mapping: nearest neighbours differ by one bit
for i in 0..16 {
for j in 0..16 {
if (c.points()[i] - c.points()[j]).norm() == 2.0 {
assert_eq!((i ^ j).count_ones(), 1);
}
}
}
assert_eq!(Constellation::new(ConstellationKind::Psk, 8).unwrap().order(), 8);Structs§
- Constellation
- A labelled constellation:
points()[i]carries the bits ofi.
Enums§
- Constellation
Kind - The family of a constellation.
Constants§
- MAX_
GRAY_ BITS - The largest number of bits of
gray_code(16 777 216 code words; the $2^{n}$ words are allocated at once). - PRIOR_
FLOOR - The floor of a prior probability before its logarithm: $\ln 10^{-300} \approx -691$.
Functions§
- bpsk
- The real BPSK symbols $1 - 2b$ of bits ($0 \mapsto +1$, $1 \mapsto -1$), the
modulation of the code tests over a real channel (
crate::demapper::bpsk_llris its demapper). - gray_
code - The Gray code of every
n-bit integer:code[i] = i ⊕ (i >> 1)(comnum_math::gray). - indices_
to_ bits - The bits of every index,
bits_per_symbolbits each, most significant bit first (comnum_math::index_to_bits). - log_
priors - The log of prior probabilities, floored at
PRIOR_FLOORso that a zero probability gives a finite log (the metric of an impossible point). - qam_
side - The side of a square QAM of order
m(Noneunlessmis a perfect square).