Algorithm Search⌘K

Algorithmcore

Tomlinson-Harashima precoding

Also called THP.

Moves the feedback filter of a DFE to the transmitter and keeps the signal bounded with a modulo operation.

Time
O(K L) worst
Space
O(L) extra
Where
K = the number of symbols; L = the number of channel taps
Properties
deterministicnot error propagationnot linearneeds channel at transmitter
Origin
M. Tomlinson, H. Harashima, H. Miyakawa, 1971

Tomlinson-Harashima precoding (THP) moves the feedback filter of a decision feedback equalizer from the receiver to the transmitter. The transmitter knows the symbols it sends, so it can subtract their echoes in advance, before the channel adds them. There are no wrong decisions and no error propagation. Subtracting echoes in advance would make the signal grow without bound on many channels, so a modulo operation folds each sample back into [−M,M)[-M, M). The receiver applies the same modulo and then slices, with no feedback. The cost is a small increase of the transmit power, a factor M2/(M2−1)M^2/(M^2-1), which is 0.280 dB for 4-PAM. THP needs the channel at the transmitter, which the DFE does not. The MMSE-DFE canonical theorem is the reason to want the feedback at the transmitter: a channel code then works as on an ISI-free channel. On a matrix channel, the same idea is a form of dirty paper coding and is close to vector perturbation precoding.

In plain words

A DFE subtracts the echoes of the symbols it has already decided. If it decides wrong, it subtracts the wrong echo. The transmitter never decides wrong: it knows exactly what it sent. So it can send each symbol minus the echoes that the channel will add. The channel then adds the echoes back, and the receiver sees the clean symbol. The problem is that this subtraction can make the transmitted values large. The fix is to fold every value back into a fixed range, like the hand of a clock. The receiver folds what it gets in the same way, and the clean symbol appears.

The problem

The input is a channel h=(h0,…,hL−1)h = (h_0, \ldots, h_{L-1}) with h0≠0h_0 \ne 0, known at the transmitter, and symbols a[k]a[k] from M-PAM with the points M−1−2iM-1-2i, i=0,…,M−1i = 0, \ldots, M-1, or from square M2M^2-QAM with M-PAM on each real dimension. The receiver gets y[k]=∑lhl x[k−l]+w[k]y[k] = \sum_l h_l\, x[k-l] + w[k], where xx is what the transmitter sends. The output is a transmitted sequence xx with bounded samples, and a receiver rule that recovers aa without a feedback loop. In a full system, hh is the cascade of the channel and the feedforward filter of an MMSE-DFE or a whitened matched filter, which makes the channel causal with a strong first tap.

The algorithm

The modulo MOD(v)=v−2M⌊(v+M)/(2M)⌋\mathrm{MOD}(v) = v - 2M \lfloor (v + M)/(2M) \rfloor maps a real number into [−M,M)[-M, M); for a complex number it acts on the real and the imaginary parts.

  1. THP(a, h, M) ▷ the transmitter
  2. 1g ← h / h[0] ▷ the monic channel
  3. 2for k ← 0 to K - 1
  4. 3v ← Σ_{j=1}^{L-1} g[j] x[k - j] ▷ the echo of the past samples
  5. 4x[k] ← MOD(a[k] - v)
  6. 5return x
  7. THP-RECEIVE(y, h0, M) ▷ the receiver
  8. 6for k ← 0 to K - 1
  9. 7u ← y[k] / h0
  10. 8â[k] ← the PAM point nearest to MOD(u), on the circle of length 2M
  11. 9return â

Line L3 is the feedback filter of a ZF-DFE, run on the transmitted samples instead of the decisions. Line L4 subtracts the echo and folds the result. Lines L7 and L8 are the whole receiver. On the circle of length 2M2M, the MM points are equally spaced, so the point M−1M-1 and the point −(M−1)-(M-1) are neighbours.

Example

Take 4-PAM, so M=4M = 4, the points are ±1,±3\pm 1, \pm 3 and the modulo maps into [−4,4)[-4, 4). The channel is h=(1,0.5)h = (1, 0.5), with no noise.

kk 0 1 2 3 4
a[k]a[k] 3 -3 -3 3 3
a[k]−0.5 x[k−1]a[k] - 0.5\, x[k-1] 3 -4.5 -4.75 1.375 2.3125
x[k]x[k] 3 3.5 3.25 1.375 2.3125
y[k]=x[k]+0.5 x[k−1]y[k] = x[k] + 0.5\, x[k-1] 3 5 5 3 3
MOD(y[k])\mathrm{MOD}(y[k]) 3 -3 -3 3 3

At k=1k = 1 the value −4.5-4.5 is below −4-4, so the transmitter adds 8 and sends 3.5. The channel output 5 is outside the alphabet, and the receiver folds it back to −3-3, the right symbol. Without the modulo, the transmitter would send 1/(1+0.5z−1)1/(1 + 0.5 z^{-1}) applied to aa, which stays bounded here but grows without bound on a channel with a zero outside the unit circle.

The transmit power was measured over 40000 random 4-PAM symbols (seed 7303). On (1,0.5)(1, 0.5) it is 5.328, close to the uniform value 16/3=5.33316/3 = 5.333, against 5 for 4-PAM itself: a loss of 10log⁡10(16/15)=0.28010 \log_{10}(16/15) = 0.280 dB. On the weak channel (1,0.1)(1, 0.1) the samples are not uniform and the power is 5.059. With Gaussian noise of standard deviation σ=0.4\sigma = 0.4 on (1,0.5)(1, 0.5), the symbol error rate of the modulo receiver is 0.01242 by the exact formula; 20000 symbols (seed 7304) gave 230 errors, 0.0115. A 4-PAM receiver on an ISI-free channel would have 2(1−1/4) Q(2.5)=0.009312(1 - 1/4)\, Q(2.5) = 0.00931, because its outer points have one neighbour each.

Correctness

Claim. The samples x[k]x[k] are in [−M,M)[-M, M) on each dimension for every channel, and y[k]/h0=a[k]+2Md[k]+w[k]/h0y[k]/h_0 = a[k] + 2M d[k] + w[k]/h_0 for some integer d[k]d[k] on each dimension. So without noise the receiver returns aa, and with noise it makes the same decisions as a zero-forcing DFE with correct feedback and an alphabet extended periodically by 2M2M.

Key step. The modulo changes its input by a multiple of 2M2M, so x[k]+v[k]=a[k]+2Md[k]x[k] + v[k] = a[k] + 2M d[k]. The channel adds v[k]v[k] back, because y[k]/h0=x[k]+∑j≥1gjx[k−j]+w[k]/h0y[k]/h_0 = x[k] + \sum_{j \ge 1} g_j x[k-j] + w[k]/h_0. The modulo at the receiver removes 2Md[k]2M d[k], since the modulo of vv depends only on vv up to multiples of 2M2M. The error rate on one dimension is then 1−∑i[Φ((2Mi+1)/σ)−Φ((2Mi−1)/σ)]1 - \sum_i [\Phi((2Mi+1)/\sigma) - \Phi((2Mi-1)/\sigma)], which is about 2Q(1/σ)2Q(1/\sigma) for every point. The proofs folder has the details.

Proof: Tomlinson-Harashima precoding delivers each symbol plus a multiple of 2M, so a modulo and a slicer recover it, with a bounded transmit signalfull

The alphabet on each real dimension is M-PAM with the points M−1−2iM - 1 - 2i, i=0,…,M−1i = 0, \ldots, M-1. They lie in (−M,M)(-M, M) at spacing 2. For a real vv, let mod(v)=v−2M⌊(v+M)/(2M)⌋\mathrm{mod}(v) = v - 2M \lfloor (v + M)/(2M) \rfloor, and for a complex vv apply it to the real and the imaginary parts. The channel is y[k]=∑l=0L−1hl x[k−l]+w[k]y[k] = \sum_{l=0}^{L-1} h_l\, x[k-l] + w[k] with h0≠0h_0 \ne 0 and x[k]=0x[k] = 0 for k<0k < 0. Let g=h/h0g = h / h_0, so g0=1g_0 = 1 (line L1).

The precoder (lines L2 to L5) computes v[k]=∑j=1L−1gj x[k−j]v[k] = \sum_{j=1}^{L-1} g_j\, x[k-j] and x[k]=mod(a[k]−v[k])x[k] = \mathrm{mod}(a[k] - v[k]). The receiver (lines L6 to L9) computes u[k]=y[k]/h0u[k] = y[k]/h_0 and slices mod(u[k])\mathrm{mod}(u[k]) to the nearest point on the circle of length 2M2M.

Lemma 1 (the modulo). For every real vv, mod(v)∈[−M,M)\mathrm{mod}(v) \in [-M, M) and v−mod(v)∈2MZv - \mathrm{mod}(v) \in 2M\mathbb{Z}. If v−v′∈2MZv - v' \in 2M\mathbb{Z}, then mod(v)=mod(v′)\mathrm{mod}(v) = \mathrm{mod}(v'). If v∈[−M,M)v \in [-M, M), then mod(v)=v\mathrm{mod}(v) = v.

Proof. Let t=⌊(v+M)/(2M)⌋t = \lfloor (v + M)/(2M) \rfloor. Then t≤(v+M)/(2M)<t+1t \le (v + M)/(2M) < t + 1, so −M≤v−2Mt<M-M \le v - 2Mt < M. The difference v−mod(v)=2Mtv - \mathrm{mod}(v) = 2Mt. If v′=v+2Msv' = v + 2Ms with ss an integer, the floor grows by exactly ss, so the two results agree. If v∈[−M,M)v \in [-M, M), then t=0t = 0. □\square

Theorem 1 (bounded transmit signal). Every precoded sample satisfies Re x[k],Im x[k]∈[−M,M)\mathrm{Re}\, x[k], \mathrm{Im}\, x[k] \in [-M, M), for every channel hh with h0≠0h_0 \ne 0, including channels with zeros outside the unit circle.

Proof. Line L4 applies the modulo, so Lemma 1 gives the bound. □\square

Theorem 2 (the received signal). For every kk, u[k]=a[k]+2M d[k]+w[k]/h0u[k] = a[k] + 2M\, d[k] + w[k]/h_0 for some d[k]d[k] whose real and imaginary parts are integers.

Proof. u[k]=∑jgj x[k−j]+w[k]/h0=x[k]+v[k]+w[k]/h0u[k] = \sum_j g_j\, x[k-j] + w[k]/h_0 = x[k] + v[k] + w[k]/h_0. By Lemma 1 on each dimension, (a[k]−v[k])−x[k]=−2Md[k](a[k] - v[k]) - x[k] = -2M d[k] for some d[k]d[k] with integer real and imaginary parts. So x[k]+v[k]=a[k]+2Md[k]x[k] + v[k] = a[k] + 2M d[k]. □\square

Corollary 1 (noiseless recovery). If w=0w = 0, the receiver decides a[k]a[k] for every kk.

Proof. By Theorem 2 and Lemma 1, mod(u[k])=mod(a[k])=a[k]\mathrm{mod}(u[k]) = \mathrm{mod}(a[k]) = a[k] on each dimension, because a[k]∈(−M,M)a[k] \in (-M, M). The slicer returns the point itself. □\square

Corollary 2 (the error rate). Let the noise on one real dimension of w[k]/h0w[k]/h_0 be Gaussian with mean zero and standard deviation σ\sigma. The decision on that dimension is wrong with probability

Pe=1−∑i∈Z[Φ(2Mi+1σ)−Φ(2Mi−1σ)],P_e = 1 - \sum_{i \in \mathbb{Z}} \Big[\Phi\Big(\frac{2Mi + 1}{\sigma}\Big) - \Phi\Big(\frac{2Mi - 1}{\sigma}\Big)\Big],

the same for every point and every channel, and Pe=2Q(1/σ)−δP_e = 2Q(1/\sigma) - \delta with 0≤δ≤2∑i≥1Q((2Mi−1)/σ)0 \le \delta \le 2 \sum_{i \ge 1} Q((2Mi - 1)/\sigma).

Proof. By Theorem 2 and Lemma 1, mod(u[k])=mod(a[k]+n)\mathrm{mod}(u[k]) = \mathrm{mod}(a[k] + n) for the noise nn of that dimension. On the circle of length 2M2M, the MM points are equally spaced at distance 2, so the nearest point to a+na + n is aa exactly when nn lies within distance 1 of a multiple of 2M2M, that is, in [2Mi−1,2Mi+1)[2Mi - 1, 2Mi + 1) for some integer ii (the boundary has probability zero). Summing these Gaussian probabilities gives 1−Pe1 - P_e. The term i=0i = 0 alone gives 1−2Q(1/σ)1 - 2Q(1/\sigma). The terms with i≠0i \ne 0 add δ\delta, and each of the two tails i≥1i \ge 1 and i≤−1i \le -1 is at most ∑i≥1Q((2Mi−1)/σ)\sum_{i \ge 1} Q((2Mi - 1)/\sigma). □\square

Every point has two neighbours on the circle, so the error rate is 2Q(1/σ)2Q(1/\sigma) for all points, against 2(1−1/M) Q(1/σ)2(1 - 1/M)\, Q(1/\sigma) for M-PAM without the modulo, where the two outer points have only one neighbour.

Corollary 3 (equivalence with the ideal DFE). The receiver of Theorem 2 sees the same noise w[k]/h0w[k]/h_0 as a zero-forcing DFE with c0=1/h0c_0 = 1/h_0, bj=gjb_j = g_j and correct feedback, with the alphabet extended periodically by 2M2M.

Proof. The ZF-DFE with correct feedback computes u[k]−∑j≥1gj xDFE[k−j]=a[k]+w[k]/h0u[k] - \sum_{j \ge 1} g_j\, x_{\text{DFE}}[k-j] = a[k] + w[k]/h_0 when the transmitted sequence is aa itself. The THP receiver gets a[k]+2Md[k]+w[k]/h0a[k] + 2M d[k] + w[k]/h_0, the same up to a multiple of 2M2M that the modulo removes. □\square

Remark (transmit power, a heuristic with a measurement). If the samples x[k]x[k] are uniformly distributed on [−M,M)[-M, M), their power is M2/3M^2/3 per dimension, against (M2−1)/3(M^2-1)/3 for M-PAM, a factor M2/(M2−1)M^2/(M^2 - 1). The uniform law is not a theorem for every channel: if gjg_j is small, x[k]≈a[k]x[k] \approx a[k]. On dispersive channels it is close: for 4-PAM and 40000 symbols (seed 7303), the measured power was 5.344 on (1,0.9,0.6)(1, 0.9, 0.6), 5.328 on (1,0.5)(1, 0.5) and 5.059 on (1,0.1)(1, 0.1), against 16/3=5.33316/3 = 5.333 and the PAM power 5.

Complexity

The precoder costs L−1L - 1 complex multiplications and one modulo per symbol, so KK symbols cost O(KL)O(KL) in the real RAM, with O(L)O(L) extra space for the past samples. The receiver costs O(1)O(1) per symbol. The receiver has no feedback loop, so it can work at a higher rate than a DFE, whose next decision waits for the current one.

Properties

  • No error propagation. The receiver decides each symbol on its own, so one noise event causes one symbol error.
  • Bounded transmit signal. Every sample is in [−M,M)[-M, M), for every channel with h0≠0h_0 \ne 0, also when 1/H(z)1/H(z) is unstable.
  • Power loss. If the precoded samples are uniform on [−M,M)[-M, M), the power is M2/3M^2/3 per dimension, a factor M2/(M2−1)M^2/(M^2 - 1) over M-PAM: 1.249 dB for 2-PAM, 0.280 dB for 4-PAM and 0.07 dB for 8-PAM. This is a heuristic; it holds closely on dispersive channels, by measurement.
  • Modulo loss. The outer points get a second neighbour, so the error rate rises from 2(1−1/M) Q2(1 - 1/M)\, Q to about 2Q2Q. This is small for large MM.
  • Needs the channel at the transmitter. A wrong channel at the transmitter leaves residual ISI that the receiver cannot remove. The precoder needs feedback from the receiver.
  • Coding works. The receiver output is the symbol plus noise modulo 2M2M, with no dependence on past decisions, so a channel code and soft decoding work as on an ISI-free channel.

Variants and improvements

  • MMSE-THP. Use the feedback filter of the MMSE-DFE instead of the ZF-DFE, with the MMSE feedforward filter at the receiver. This is the usual design, because it keeps the gain of the MMSE-DFE.
  • Complex and lattice versions. For square QAM the modulo acts on each real dimension. Other lattices and shapes give more general modulo precoders.
  • Flexible precoding and trellis precoding. Other precoders for the voiceband modem standards combine the feedback with trellis shaping to remove most of the power loss.
  • MIMO and multiuser THP. On a matrix channel, a QR or LQ factorization gives a triangular channel, and THP runs across the users or the antennas. It is a practical form of dirty paper coding, and vector perturbation precoding chooses the modulo offsets jointly instead of one at a time.

When to use it

Use THP when the transmitter knows the channel, the channel changes slowly enough for the receiver to report it, and the receiver must decode with a channel code at full gain. It was used in voiceband modems and in DSL, and it is used in multiuser downlinks. On a fast-changing channel, or when the channel cannot be fed back, use a DFE or a Viterbi equalizer at the receiver.

Pitfalls

  • Forgetting the modulo at the receiver. The received values lie far outside the alphabet; a plain slicer clips them to the outer points.
  • The modulo interval. The points of M-PAM at spacing 2 need the interval [−M,M)[-M, M) of length 2M2M. A length of 2(M−1)2(M-1) folds the outer points onto each other.
  • A gain error. The receiver must divide by h0h_0 exactly. A small gain error moves the folded values, and the effect is worst near the edges of [−M,M)[-M, M), where the modulo wraps.
  • Channel mismatch. The precoder subtracts the echoes of the channel it was told. A stale channel leaves ISI, and the modulo can turn a small ISI into a jump of 2M2M near the edges.
  • Counting the power. Compare THP with a DFE at the same transmit power, not at the same symbol energy, to include the power loss.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

tomlinson_harashima_precoding.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/tomlinson-harashima-precoding/. The authors are listed in prov/T1E2A7.jsonl.

"""Tomlinson-Harashima precoding for M-PAM and square M^2-QAM.

The symbols use the raw amplitudes M-1-2m, m = 0..M-1 (the odd integers
-(M-1), ..., M-1 for even M), on each real dimension. The modulo maps each real
dimension into [-M, M), an interval of length 2M that holds M points at spacing 2.

The channel h is known at the transmitter. The precoder works with the monic
channel h / h[0]; the receiver divides by h[0]. With the precoder
x[k] = mod(a[k] - sum_{j>=1} (h[j]/h[0]) x[k-j]), the noiseless received sample
divided by h[0] is a[k] plus a multiple of 2M on each dimension, so the receiver
needs only a modulo and a slicer: no feedback filter and no decisions in a loop.
"""

import math


def pam(m: int) -> list[int]:
    """The raw M-PAM amplitudes M-1-2i for i = 0..M-1."""
    if m < 2:
        raise ValueError("need M >= 2")
    return [m - 1 - 2 * i for i in range(m)]


def mod_real(v: float, m: int) -> float:
    """v reduced into [-M, M) by adding a multiple of 2M."""
    return v - 2 * m * math.floor((v + m) / (2 * m))


def mod(v: complex, m: int) -> complex:
    """The modulo on each real dimension of a complex number."""
    return complex(mod_real(v.real, m), mod_real(v.imag, m))


def slice_real(v: float, m: int) -> int:
    """The M-PAM point nearest to v on the circle of length 2M."""
    idx = round((m - 1 - mod_real(v, m)) / 2) % m
    return m - 1 - 2 * idx


def thp_encode(a: list[complex], h: list[complex], m: int) -> list[complex]:
    """The precoded sequence x for the symbols a and the channel h, h[0] != 0."""
    if not h or h[0] == 0:
        raise ValueError("need h[0] != 0")
    g = [complex(v) / h[0] for v in h]  # @line L1
    x: list[complex] = []
    for k, ak in enumerate(a):  # @line L2
        fb = sum(g[j] * x[k - j] for j in range(1, len(g)) if k - j >= 0)  # @line L3
        x.append(mod(complex(ak) - fb, m))  # @line L4
    return x  # @line L5


def thp_receive(y: list[complex], h0: complex, m: int, real: bool = False) -> list[complex]:
    """The decisions: divide by h[0], reduce modulo 2M on each dimension and slice."""
    out = []
    for v in y:  # @line L6
        u = complex(v) / h0  # @line L7
        re = slice_real(u.real, m)  # @line L8
        out.append(complex(re, 0) if real else complex(re, slice_real(u.imag, m)))
    return out  # @line L9


def channel(x: list[complex], h: list[complex]) -> list[complex]:
    """The noiseless channel output sum_l h[l] x[k-l] for k = 0..len(x)-1."""
    return [sum(h[l] * x[k - l] for l in range(len(h)) if k - l >= 0) for k in range(len(x))]


def power_loss(m: int) -> float:
    """M^2 / (M^2 - 1): the uniform power M^2/3 over the PAM power (M^2-1)/3."""
    return m * m / (m * m - 1)


def ser_per_dimension(m: int, sigma: float, wraps: int = 4) -> float:
    """The exact symbol error rate of one real dimension after the modulo.

    The noise is real Gaussian with standard deviation sigma. A decision is right
    when the noise lands in one of the intervals [2Mi - 1, 2Mi + 1), i an integer.
    """
    ok = 0.0
    for i in range(-wraps, wraps + 1):
        lo, hi = (2 * m * i - 1) / sigma, (2 * m * i + 1) / sigma
        ok += 0.5 * (math.erf(hi / math.sqrt(2)) - math.erf(lo / math.sqrt(2)))
    return 1.0 - ok
test_tomlinson_harashima_precoding.py 113 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/tomlinson-harashima-precoding/. The authors are listed in prov/T1E2A7.jsonl.

import math
import random

import pytest

from tomlinson_harashima_precoding import (
    channel,
    mod,
    mod_real,
    pam,
    power_loss,
    ser_per_dimension,
    slice_real,
    thp_encode,
    thp_receive,
)


def wilson(k, n, z=3.29):
    p, z2 = k / n, z * z
    mid = (p + z2 / (2 * n)) / (1 + z2 / n)
    half = z * math.sqrt(p * (1 - p) / n + z2 / (4 * n * n)) / (1 + z2 / n)
    return mid - half, mid + half


def test_example_on_the_page() -> None:
    a = [3, -3, -3, 3, 3]
    x = thp_encode(a, [1, 0.5], 4)
    assert [v.real for v in x] == [3, 3.5, 3.25, 1.375, 2.3125]
    y = channel(x, [1, 0.5])
    assert [v.real for v in y] == [3, 5, 5, 3, 3]
    assert thp_receive(y, 1, 4, real=True) == [complex(v) for v in a]
    assert abs(10 * math.log10(power_loss(4)) - 0.280287) < 1e-6
    assert abs(10 * math.log10(power_loss(2)) - 1.249387) < 1e-6


def test_modulo_and_slicer() -> None:
    for v in (-4.0, -3.99, 0.0, 3.99, 4.0, 7.5, -12.25, 100.1):
        r = mod_real(v, 4)
        assert -4 <= r < 4 and abs((v - r) / 8 - round((v - r) / 8)) < 1e-12
    for m in (2, 3, 4, 8):
        for p in pam(m):
            for k in (-2, -1, 0, 1, 3):
                assert slice_real(p + 2 * m * k + 0.4, m) == p
                assert slice_real(p + 2 * m * k - 0.4, m) == p
    assert pam(4) == [3, 1, -1, -3]
    with pytest.raises(ValueError):
        pam(1)


def test_noiseless_recovery_on_random_channels() -> None:
    rng = random.Random(7301)
    for _ in range(30):
        m = rng.choice((2, 4, 8))
        taps = rng.randint(2, 5)
        cplx = rng.random() < 0.5
        h = [complex(rng.gauss(0, 1), rng.gauss(0, 1) if cplx else 0) for _ in range(taps)]
        pts = pam(m)
        a = [complex(rng.choice(pts), rng.choice(pts) if cplx else 0) for _ in range(200)]
        x = thp_encode(a, h, m)
        assert all(-m <= v.real < m and -m <= v.imag < m for v in x)
        y = channel(x, h)
        assert thp_receive(y, h[0], m, real=not cplx) == a


def test_received_minus_symbol_is_noise_modulo_2m() -> None:
    rng = random.Random(7302)
    h = [1, -0.9 + 0.3j, 0.4j]
    m = 4
    pts = pam(m)
    a = [complex(rng.choice(pts), rng.choice(pts)) for _ in range(500)]
    x = thp_encode(a, h, m)
    w = [complex(rng.gauss(0, 0.3), rng.gauss(0, 0.3)) for _ in a]
    y = [v + n for v, n in zip(channel(x, h), w)]
    for k in range(len(a)):
        d = mod(y[k] - a[k], m) - mod(w[k], m)
        assert abs(d.real) < 1e-9 or abs(abs(d.real) - 2 * m) < 1e-9
        assert abs(d.imag) < 1e-9 or abs(abs(d.imag) - 2 * m) < 1e-9


def test_transmit_power_is_near_the_uniform_power() -> None:
    # a measurement: on a dispersive channel the precoded samples are close to uniform on [-M, M)
    rng = random.Random(7303)
    m, n = 4, 40000
    a = [rng.choice(pam(m)) for _ in range(n)]
    x = thp_encode(a, [1, 0.9, 0.6], m)
    p = sum(v.real ** 2 for v in x) / n
    assert abs(p - m * m / 3) < 0.05 * m * m / 3
    assert p > (m * m - 1) / 3


def test_symbol_error_rate_matches_the_modulo_formula() -> None:
    rng = random.Random(7304)
    m, n, sigma = 4, 20000, 0.4
    pe = ser_per_dimension(m, sigma)
    assert abs(pe - 2 * 0.5 * math.erfc(1 / sigma / math.sqrt(2))) < 1e-9
    assert pe * n >= 100
    h = [1, 0.5]
    a = [complex(rng.choice(pam(m))) for _ in range(n)]
    y = [v + rng.gauss(0, sigma) for v in channel(thp_encode(a, h, m), h)]
    errors = sum(1 for p, q in zip(thp_receive(y, 1, m, real=True), a) if p != q)
    lo, hi = wilson(errors, n)
    assert lo <= pe <= hi


def test_input_checks() -> None:
    with pytest.raises(ValueError):
        thp_encode([1], [0, 1], 4)
    with pytest.raises(ValueError):
        thp_encode([1], [], 4)

History

Tomlinson described an automatic equaliser with modulo arithmetic in Electronics Letters in 1971. Harashima and Miyakawa proposed the same structure, which they called matched transmission, for channels with intersymbol interference in 1972. The technique was little used at first, because it needs the channel at the transmitter. It became practical in voiceband modems, where the receiver sends the channel back at startup, and the analysis of the MMSE-DFE with coding by Cioffi, Dudevoir, Eyuboglu and Forney in 1995 explained why precoding is the right partner for a channel code. THP later spread to DSL and to multiuser MIMO downlinks.

References

  1. M. Tomlinson, New automatic equaliser employing modulo arithmetic, Electronics Letters 7(5-6), 1971, pages 138 to 139, the precoder with modulo arithmetic
  2. H. Harashima and H. Miyakawa, Matched-transmission technique for channels with intersymbol interference, IEEE Transactions on Communications 20(4), 1972, pages 774 to 780, the precoder at the transmitter and the modulo receiver
  3. John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Section 9.5-4 (equalization at the transmitter)
  4. John M. Cioffi, Glen P. Dudevoir, M. Vedat Eyuboglu and G. David Forney, Jr., MMSE decision-feedback equalizers and coding, Part II: Coding results, IEEE Transactions on Communications 43(10), 1995, pages 2595 to 2604, precoding with the MMSE-DFE and coding

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a scene preset for the example