qam_demodulate
Builtin index · Signal processing
result = qam_demodulate(symbols, order)
Input: symbols, order · Output: result
What it is
symbols: a CVec, a real Vec (quadrature taken as zero), or a single Complex; order as for qam_modulate. Nearest-constellation-point decision, the exact inverse of qam_modulate on clean symbols. Because a square constellation is a product of two independent PAM axes, the nearest point is found by rounding per axis rather than searching all order points; a symbol landing outside the constellation decides to the edge point.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = qam_demodulate(symbols, order) | symbols CVec, Vec, or Complexsymbols: a CVec, a real Vec (quadrature taken as zero), or a single Complex.order —order as for qam_modulate. | result Vec | Returns a Vec of 0/1, log2(order) bits per symbol. (Added in v0.3.0.) |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
bits = [0, 1, 1, 0, 1, 0, 0, 1]
syms = qam_modulate(bits, 16) # 2 symbols on the odd-integer grid
print(qam_demodulate(syms, 16)) # back to the same 8 bits
print(hamming74_encode([1, 0, 1, 1])) # [0, 1, 1, 0, 0, 1, 1]
r = hamming74_decode([0, 1, 1, 0, 1, 1, 1]) # bit 5 flipped in transit
print("{r.data} corrected={r.corrected} at {r.positions}")
m = [1, 1, 0, 1]
print(crc(m, 11)) # [0, 0, 1] -- x^3 + x + 1
print(crc_check([1, 1, 0, 1, 0, 0, 1], 11)) # true
[0, 1, 1, 0, 1, 0, 0, 1] [0, 1, 1, 0, 0, 1, 1] [1, 0, 1, 1] corrected=true at [5] [0, 0, 1] true
from signal-processing
How it works
qam_demodulate(symbols, order) — nearest-constellation- point decision, the inverse of qam_modulate. Accepts a CVec, a real Vec (quadrature taken as zero) or a single Complex. Returns the recovered bits as a Vec of 0/1.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.