Algorithm Search⌘K

Algorithmcore

Single-carrier frequency-domain equalization

Also called SC-FDE, frequency-domain equalizer.

Equalizes a block of single-carrier symbols with a cyclic prefix by one complex tap per FFT bin.

Time
O(N log N) worst
Space
O(N) extra
Where
L = the number of channel taps; N = the block length; P = the prefix length
Properties
deterministiclinearneeds channelneeds cyclic prefix
Origin
Hikmet Sari, Georges Karam, Isabelle Jeanclaude, 1995

Single-carrier frequency-domain equalization (SC-FDE) equalizes a long channel with one complex multiplication per frequency bin. The transmitter sends the symbols in blocks of NN and puts a cyclic prefix of P≥L−1P \ge L - 1 samples in front of each block. After the receiver removes the prefix, the channel acts on the block as a circular convolution, so the DFT of the block is the DFT of the symbols times the channel frequency response, bin by bin. The receiver divides by the response (zero forcing) or applies the MMSE weight in each bin and returns to the time domain with an inverse DFT. The decisions are made in the time domain, on the symbols themselves. This is the same block structure as OFDM, with the inverse DFT moved from the transmitter to the receiver. SC-FDMA uses the same receiver for multiple users.

In plain words

A time-domain equalizer for a long channel needs a long filter, and every output costs one multiplication per filter tap. In the frequency domain, a channel is only a gain and a phase per frequency, so undoing it is one division per frequency. The catch is that this is exact only for circular convolution, where the block wraps around. The cyclic prefix makes the channel wrap around: it repeats the end of the block at the front, so the echo of the previous block falls only on the prefix, and the receiver throws the prefix away. The fast Fourier transform makes the change of domain cheap.

The problem

The input is a received block of N+PN + P samples ri=∑l=0L−1hlsi−l+wir_i = \sum_{l=0}^{L-1} h_l s_{i-l} + w_i, where ss is the prefix followed by the block x=(x0,…,xN−1)x = (x_0, \ldots, x_{N-1}), the channel hh is known, P≥L−1P \ge L - 1, and ww is white CN(0,N0)\mathcal{CN}(0, N_0). The symbols are independent with energy EsE_s. The output is an estimate x^\hat x of the block: the zero-forcing estimate, which removes all ISI, or the linear MMSE estimate, which minimizes E∣x^n−xn∣2E|\hat x_n - x_n|^2 among all linear functions of the received block.

The algorithm

The DFT is unnormalized, Xk=∑nxne−j2πkn/NX_k = \sum_n x_n e^{-j2\pi kn/N}, and the inverse DFT has the factor 1/N1/N.

  1. SC-FDE(r, h, N, P, N0, Es)
  2. 1y ← r[P .. P+N-1] ▷ remove the cyclic prefix
  3. 2Y ← FFT(y)
  4. 3H ← FFT(h padded with zeros to N) ▷ once per channel
  5. 4W[k] ← 1 / H[k] ▷ zero forcing
  6. 5or W[k] ← conj(H[k]) / (|H[k]|² + N0/Es) ▷ MMSE
  7. 6return IFFT(W[k] Y[k])

Line L1 is where the prefix matters: when P≥L−1P \ge L - 1, the samples that line L1 keeps contain no sample of the previous block, and yy is the circular convolution of hh and xx. Line L2 turns it into Yk=HkXk+WkY_k = H_k X_k + W_k. Lines L4 and L5 are the one-tap equalizers. The MMSE taps are the Wiener filter of each bin, and together they give exactly the block MMSE estimate. Line L6 returns to the symbols. The fast Fourier transform does lines L2, L3 and L6.

Example

Take N=4N = 4, h=(1,0.5)h = (1, 0.5), P=1P = 1 and the BPSK block x=(+1,−1,−1,+1)x = (+1, -1, -1, +1). The transmitted samples are (+1∣+1,−1,−1,+1)(+1 \mid +1, -1, -1, +1), with the last symbol copied in front. After the prefix is removed and without noise, y=(x0+0.5x3,x1+0.5x0,x2+0.5x1,x3+0.5x2)=(1.5,−0.5,−1.5,0.5)y = (x_0 + 0.5x_3, x_1 + 0.5x_0, x_2 + 0.5x_1, x_3 + 0.5x_2) = (1.5, -0.5, -1.5, 0.5), a circular convolution. In the frequency domain:

kk XkX_k HkH_k YkY_k Yk/HkY_k/H_k ∣Hk∣2\lvert H_k\rvert^2 MMSE tap, N0=0.1N_0 = 0.1
0 0 1.5 0 0 2.25 0.6383
1 2+2j2 + 2j 1−0.5j1 - 0.5j 3+j3 + j 2+2j2 + 2j 1.25 (1+0.5j)/1.35(1 + 0.5j)/1.35
2 0 0.5 0 0 0.25 1.4286
3 2−2j2 - 2j 1+0.5j1 + 0.5j 3−j3 - j 2−2j2 - 2j 1.25 (1−0.5j)/1.35(1 - 0.5j)/1.35

The ZF output is the inverse DFT of Yk/HkY_k/H_k, which is xx exactly. With N0=0.1N_0 = 0.1 and Es=1E_s = 1, the noise after ZF has the variance N0N∑k∣Hk∣−2=0.1511\frac{N_0}{N}\sum_k |H_k|^{-2} = 0.1511 per symbol, most of it from bin 2, where ZF multiplies by 2. The MMSE taps hold back in that bin, and the MSE is J=1N∑kN0Es/(Es∣Hk∣2+N0)=0.1191J = \frac1N \sum_k N_0 E_s/(E_s|H_k|^2 + N_0) = 0.1191. The MMSE output is biased: without noise it is 0.926 x0.926\, x for this block, because both used bins have ∣Hk∣2/(∣Hk∣2+0.1)=1.25/1.35|H_k|^2/(|H_k|^2 + 0.1) = 1.25/1.35.

On the channel B of Proakis, h=(0.407,0.815,0.407)h = (0.407, 0.815, 0.407), with N=64N = 64, Es/N0=10E_s/N_0 = 10 dB and QPSK, the bin k=32k = 32 has H32=0.407−0.815+0.407=−0.001H_{32} = 0.407 - 0.815 + 0.407 = -0.001. ZF multiplies the noise in that bin by 10610^6, and the noise variance per symbol is 1707. The MMSE formula gives J=0.3364J = 0.3364, and 200 blocks with seed 7805 measured 0.3329. The unbiased SINR is Es/J−1E_s/J - 1, which is 2.95 dB.

Correctness

Claim. With P≥L−1P \ge L - 1, the ZF output is xx plus noise of the variance N0N∑k∣Hk∣−2\frac{N_0}{N}\sum_k |H_k|^{-2} per symbol, and the MMSE output equals the block linear MMSE estimate (CHC+N0EsI)−1CHy(\mathbf{C}^H\mathbf{C} + \frac{N_0}{E_s}\mathbf{I})^{-1}\mathbf{C}^H y for the circulant channel matrix C\mathbf{C}. Its MSE is J=1N∑kN0Es/(Es∣Hk∣2+N0)J = \frac1N \sum_k N_0 E_s/(E_s|H_k|^2 + N_0) for every symbol, and its unbiased SINR is Es/J−1E_s/J - 1.

Key step. The prefix makes the channel matrix circulant, and the DFT diagonalizes every circulant matrix, with the eigenvalues HkH_k. So the matrix inverse in the MMSE formula becomes NN scalar divisions. The error covariance is circulant too, so all symbols have the same MSE, the average of the per-bin errors. The proofs folder has the details.

Proof: With a cyclic prefix of at least L-1 samples, one tap per DFT bin gives the zero-forcing and the block MMSE equalizers exactly, with the stated mean squared errorsfull

The channel taps are h0,…,hL−1h_0, \ldots, h_{L-1}. A block x=(x0,…,xN−1)x = (x_0, \ldots, x_{N-1}) of independent zero-mean symbols with E∣xn∣2=EsE|x_n|^2 = E_s is sent as s=(xN−P,…,xN−1,x0,…,xN−1)s = (x_{N-P}, \ldots, x_{N-1}, x_0, \ldots, x_{N-1}), a cyclic prefix of PP samples followed by the block. The received samples are ri=∑lhlsi−l+wir_i = \sum_l h_l s_{i-l} + w_i with ww white CN(0,N0)\mathcal{CN}(0, N_0), where si−ls_{i-l} for i−l<0i - l < 0 are samples of the previous block. The DFT is unnormalized: Xk=∑nxne−j2πkn/NX_k = \sum_n x_n e^{-j 2\pi kn/N}, and the inverse has the factor 1/N1/N. Write HkH_k for the DFT of hh padded with zeros to length NN (line L3).

Lemma 1 (the prefix makes the convolution circular). If P≥L−1P \ge L - 1, then after the prefix is removed (line L1), yn=rP+n=∑lhlx(n−l) mod N+wP+ny_n = r_{P+n} = \sum_l h_l x_{(n-l) \bmod N} + w_{P+n} for n=0,…,N−1n = 0, \ldots, N-1, whatever the previous block was.

Proof. rP+nr_{P+n} uses sP+n−ls_{P+n-l} for 0≤l≤L−10 \le l \le L-1. The index P+n−l≥P−(L−1)≥0P + n - l \ge P - (L-1) \ge 0, so no sample of the previous block enters. If n−l≥0n - l \ge 0, then sP+n−l=xn−ls_{P+n-l} = x_{n-l}. If n−l<0n - l < 0, then P+n−lP + n - l is in the prefix and sP+n−l=xN+n−l=x(n−l) mod Ns_{P+n-l} = x_{N+n-l} = x_{(n-l) \bmod N}. □\square

Lemma 2 (one tap per bin). With Y=DFT(y)Y = \mathrm{DFT}(y) (line L2), Yk=HkXk+WkY_k = H_k X_k + W_k, where the WkW_k are i.i.d. CN(0,NN0)\mathcal{CN}(0, N N_0).

Proof. The DFT of a circular convolution is the product of the DFTs. The DFT matrix F\mathbf{F} has FHF=NI\mathbf{F}^H \mathbf{F} = N \mathbf{I}, so W=FwW = \mathbf{F} w has the covariance NN0IN N_0 \mathbf{I}, and it is circular Gaussian as a linear map of ww. □\square

In matrix form, y=Cx+wy = \mathbf{C} x + w with the circulant matrix Cnm=h(n−m) mod N\mathbf{C}_{nm} = h_{(n-m) \bmod N} (zero where the index is LL or more). With the unitary U=F/N\mathbf{U} = \mathbf{F}/\sqrt N, Lemma 2 says C=UHΛU\mathbf{C} = \mathbf{U}^H \Lambda \mathbf{U} with Λ=diag(H0,…,HN−1)\Lambda = \mathrm{diag}(H_0, \ldots, H_{N-1}).

Theorem 1 (zero forcing). If every Hk≠0H_k \ne 0, lines L4 and L6 give x^=x+IDFT(Wk/Hk)\hat x = x + \mathrm{IDFT}(W_k / H_k). Without noise x^=x\hat x = x. The noise in each output sample has the variance N0N∑k∣Hk∣−2\frac{N_0}{N} \sum_k |H_k|^{-2}.

Proof. X^k=Yk/Hk=Xk+Wk/Hk\hat X_k = Y_k / H_k = X_k + W_k / H_k. The noise sample nn is 1N∑kej2πkn/NWk/Hk\frac1N \sum_k e^{j2\pi kn/N} W_k/H_k, a sum of independent terms, so its variance is 1N2∑kNN0/∣Hk∣2\frac{1}{N^2} \sum_k N N_0 / |H_k|^2. □\square

Theorem 2 (MMSE). Lines L5 and L6 compute x^=(CHC+γI)−1CHy\hat x = (\mathbf{C}^H \mathbf{C} + \gamma \mathbf{I})^{-1} \mathbf{C}^H y with γ=N0/Es\gamma = N_0/E_s, which is the linear MMSE estimate of xx from yy.

Proof. The linear MMSE estimate of xx with covariance EsIE_s \mathbf{I} from y=Cx+wy = \mathbf{C} x + w is EsCH(EsCCH+N0I)−1yE_s \mathbf{C}^H (E_s \mathbf{C}\mathbf{C}^H + N_0 \mathbf{I})^{-1} y, which equals (CHC+γI)−1CHy(\mathbf{C}^H \mathbf{C} + \gamma \mathbf{I})^{-1} \mathbf{C}^H y by the push-through identity. Substitute C=UHΛU\mathbf{C} = \mathbf{U}^H \Lambda \mathbf{U}: the matrix is UHdiag(Hˉk/(∣Hk∣2+γ))U\mathbf{U}^H \mathrm{diag}\big(\bar H_k / (|H_k|^2 + \gamma)\big) \mathbf{U}. Applying it to yy is the DFT, one multiplication per bin and the inverse DFT, because UHDUy=F−1DFy\mathbf{U}^H \mathbf{D} \mathbf{U} y = \mathbf{F}^{-1} \mathbf{D} \mathbf{F} y. □\square

Theorem 3 (the MMSE value). Each output sample of the MMSE equalizer has the mean squared error

J=1N∑k=0N−1N0EsEs∣Hk∣2+N0.J = \frac{1}{N} \sum_{k=0}^{N-1} \frac{N_0 E_s}{E_s |H_k|^2 + N_0}.

Proof. The error covariance of the linear MMSE estimate is (Es−1I+N0−1CHC)−1=UHdiag(N0Es/(N0+Es∣Hk∣2))U(E_s^{-1} \mathbf{I} + N_0^{-1} \mathbf{C}^H \mathbf{C})^{-1} = \mathbf{U}^H \mathrm{diag}\big(N_0 E_s/(N_0 + E_s |H_k|^2)\big) \mathbf{U}. This matrix is circulant, so all diagonal entries are equal to the trace divided by NN, and the trace is the sum of the eigenvalues. □\square

Corollary 1 (bias and SINR). The MMSE output is x^n=g xn+vn\hat x_n = g\, x_n + v_n with g=1−J/Esg = 1 - J/E_s and vnv_n uncorrelated with xnx_n, of variance gJgJ. So the unbiased output x^n/g\hat x_n / g has the SINR Es/J−1E_s/J - 1.

Proof. The output is x^=Ax+Bw\hat x = \mathbf{A} x + \mathbf{B} w with A=UHdiag(∣Hk∣2/(∣Hk∣2+γ))U\mathbf{A} = \mathbf{U}^H \mathrm{diag}\big(|H_k|^2/(|H_k|^2 + \gamma)\big) \mathbf{U}, a circulant matrix with all diagonal entries g=1N∑k∣Hk∣2/(∣Hk∣2+γ)=1−1N∑kγ/(∣Hk∣2+γ)=1−J/Esg = \frac1N \sum_k |H_k|^2/(|H_k|^2 + \gamma) = 1 - \frac1N \sum_k \gamma/(|H_k|^2 + \gamma) = 1 - J/E_s. The rest, vn=∑m≠nAnmxm+(Bw)nv_n = \sum_{m \ne n} \mathbf{A}_{nm} x_m + (\mathbf{B} w)_n, is uncorrelated with xnx_n because the symbols are independent with zero mean and the noise is independent of them. Then J=E∣x^n−xn∣2=(1−g)2Es+Var(vn)J = E|\hat x_n - x_n|^2 = (1 - g)^2 E_s + \mathrm{Var}(v_n), so Var(vn)=J−J2/Es=gJ\mathrm{Var}(v_n) = J - J^2/E_s = gJ, and the SINR of x^n/g\hat x_n/g is g2Es/(gJ)=gEs/J=Es/J−1g^2 E_s / (gJ) = gE_s/J = E_s/J - 1. □\square

Theorem 4 (the cost). With NN a power of 2, lines L2 and L6 cost O(Nlog⁡N)O(N \log N) each by the radix-2 FFT, and lines L4 and L5 cost O(N)O(N). The DFT of hh (line L3) is needed once per channel. So a block of NN symbols costs O(Nlog⁡N)O(N \log N), or O(log⁡N)O(\log N) per symbol.

Proof. The radix-2 FFT does log⁡2N\log_2 N passes of N/2N/2 butterflies. □\square

Complexity

The FFT and the inverse FFT cost O(Nlog⁡N)O(N \log N) each for NN a power of 2, and the taps cost O(N)O(N), so a block costs O(Nlog⁡N)O(N \log N) in the real RAM, or O(log⁡N)O(\log N) per symbol, with O(N)O(N) extra space. The channel FFT is computed once per channel estimate. A time-domain equalizer with LfL_f taps costs O(NLf)O(N L_f) per block, and LfL_f must grow with the channel length LL, so SC-FDE wins for long channels. The prefix costs a fraction P/(N+P)P/(N+P) of the throughput, which is why NN is chosen much larger than LL.

Properties

  • Exact block equalizers. The ZF and MMSE outputs are the exact block ZF and block MMSE estimates for the circular channel, not approximations of a finite filter.
  • Same MSE for every symbol. The error covariance is circulant, so no symbol of the block is worse off. A time-domain block equalizer without a prefix has worse errors at the block edges.
  • Averaging over frequency. The MSE is an average over the bins of N0Es/(Es∣Hk∣2+N0)N_0 E_s/(E_s|H_k|^2 + N_0). A deep fade in one bin raises the MSE of all symbols a little, instead of destroying the subcarriers in that bin, as in uncoded OFDM.
  • Biased MMSE. The MMSE output is gx+vg x + v with g=1−J/Esg = 1 - J/E_s. Scale by 1/g1/g before a slicer for QAM.
  • Single-carrier envelope. The transmitter sends the symbols directly, so the peak-to-average power ratio is that of the constellation and the pulse, lower than for OFDM.
  • Linear. It is a linear equalizer and inherits the loss of linear equalizers on channels with deep nulls.

Variants and improvements

  • Frequency-domain DFE. A frequency-domain feedforward filter followed by a short time-domain feedback filter, which recovers much of the loss on channels with deep nulls. See the decision feedback equalizer.
  • Iterative block DFE and turbo FDE. Repeat the FDE with soft decisions from a decoder to cancel the residual ISI, as in turbo equalization and the soft interference cancellation equalizer.
  • SC-FDMA. Each user spreads its block with a DFT and maps it to some of the subcarriers of a larger IFFT. The receiver equalizes per bin and despreads with an inverse DFT. See SC-FDMA.
  • Unique word. A known sequence in place of the cyclic prefix, at the end of every block, also makes the convolution circular and can serve as a pilot.
  • Overlap methods without a prefix. The overlap-save method equalizes a continuous stream in the frequency domain with no prefix, at the cost of discarded overlap samples at the receiver.
  • Channel estimation. With a known block or pilot bins, HkH_k is estimated per bin by least squares, then smoothed by limiting the impulse response to P+1P + 1 taps. See least-squares channel estimation.

When to use it

Use SC-FDE for long channels and high symbol rates, when the transmitter must keep a low peak-to-average power ratio: broadband wireless uplinks, satellite links and mobile terminals. Use OFDM when the transmitter can adapt the rate per subcarrier, and a Viterbi equalizer or a time-domain DFE when the channel is short and no prefix is in the frame format.

Pitfalls

  • A prefix shorter than the channel. If P<L−1P < L - 1, the previous block leaks into the kept samples and the convolution is not circular. The error does not go away at high SNR. A channel shortening equalizer can shorten the channel first.
  • ZF near a null. Dividing by a small HkH_k blows up the noise in that bin and spreads it over every symbol. On the channel B of Proakis with N=64N = 64, ZF gives a noise variance of 1707 per symbol. Use the MMSE taps.
  • Forgetting the bias. The MMSE output is scaled by g<1g < 1. For QAM with several amplitude levels, scale by 1/g1/g before deciding.
  • The DFT scaling. With the unnormalized DFT, the noise per bin has variance NN0N N_0, and the inverse DFT carries the factor 1/N1/N. Mixing conventions gives the wrong N0N_0 in the MMSE taps.
  • Timing. The kept window must start at the first sample of the block. A window that starts dd samples early still sees a circular convolution if P≥L−1+dP \ge L - 1 + d, but with the channel shifted circularly by dd samples, so the channel estimate must come from the same window. A window that starts late takes in the next block.

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.

frequency_domain_equalization.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/frequency-domain-equalization/. The authors are listed in prov/8TF7E6.jsonl.

"""Single-carrier frequency-domain equalization (SC-FDE) with a cyclic prefix.

The transmitter sends blocks of N symbols, each with a cyclic prefix of P >= L-1
samples. After the prefix is removed, the channel acts on the block as a circular
convolution, y = h (*) x + w with w white CN(0, N0). The DFT (unnormalized,
X[k] = sum_n x[n] e^{-j 2 pi k n / N}) turns it into Y[k] = H[k] X[k] + W[k].
The equalizer is one tap per bin, W[k] = 1/H[k] (zero forcing) or
W[k] = conj(H[k]) / (|H[k]|^2 + N0/Es) (MMSE), followed by the inverse DFT.

The FFT here is the iterative radix-2 Cooley-Tukey algorithm; other sizes use
the direct DFT.
"""

import cmath
import math


def fft(x: list[complex], inverse: bool = False) -> list[complex]:
    """The unnormalized DFT of x (or the inverse DFT, with the 1/N factor)."""
    n = len(x)
    a = [complex(v) for v in x]
    sign = 1 if inverse else -1
    if n & (n - 1) or n == 0:
        out = [sum(a[t] * cmath.exp(sign * 2j * math.pi * k * t / n) for t in range(n)) for k in range(n)]
    else:
        j = 0
        for i in range(1, n):  # bit reversal
            bit = n >> 1
            while j & bit:
                j ^= bit
                bit >>= 1
            j |= bit
            if i < j:
                a[i], a[j] = a[j], a[i]
        size = 2
        while size <= n:
            w = cmath.exp(sign * 2j * math.pi / size)
            for start in range(0, n, size):
                wk = 1 + 0j
                for k in range(size // 2):
                    u, v = a[start + k], a[start + k + size // 2] * wk
                    a[start + k], a[start + k + size // 2] = u + v, u - v
                    wk *= w
            size *= 2
        out = a
    if inverse and n:
        out = [v / n for v in out]
    return out


def add_cyclic_prefix(x: list[complex], p: int) -> list[complex]:
    return list(x[len(x) - p:]) + list(x) if p else list(x)


def fde(r: list[complex], h: list[complex], n: int, p: int, n0: float | None = None, es: float = 1.0) -> list[complex]:
    """Equalize one received block r of n + p samples (prefix first).

    n0 = None gives zero forcing; otherwise the MMSE taps for noise CN(0, n0)
    and symbol energy es. Returns the n soft estimates of x.
    """
    if len(h) - 1 > p:
        raise ValueError("the cyclic prefix must hold at least L-1 samples")
    if len(r) != n + p:
        raise ValueError("r must hold n + p samples")
    y = r[p:]  # @line L1
    yf = fft(y)  # @line L2
    hf = fft(list(h) + [0j] * (n - len(h)))  # @line L3
    if n0 is None:
        w = [1 / v for v in hf]  # @line L4
    else:
        w = [v.conjugate() / (abs(v) ** 2 + n0 / es) for v in hf]  # @line L5
    return fft([a * b for a, b in zip(w, yf)], inverse=True)  # @line L6


def mmse_mse(h: list[complex], n: int, n0: float, es: float = 1.0) -> float:
    """The MSE per symbol of the MMSE-FDE: (1/N) sum_k N0 Es / (Es |H[k]|^2 + N0)."""
    hf = fft(list(h) + [0j] * (n - len(h)))
    return sum(n0 * es / (es * abs(v) ** 2 + n0) for v in hf) / n


def zf_mse(h: list[complex], n: int, n0: float) -> float:
    """The noise variance per symbol after the ZF-FDE: (1/N) sum_k N0 / |H[k]|^2."""
    hf = fft(list(h) + [0j] * (n - len(h)))
    return sum(n0 / abs(v) ** 2 for v in hf) / n


def channel(s: list[complex], h: list[complex], prev: list[complex] | None = None) -> list[complex]:
    """Linear convolution of the transmitted samples s with h, cut to len(s).

    prev holds the samples sent before s (the previous block), so that its tail
    falls into the prefix of s, as in a real stream.
    """
    prev = list(prev) if prev is not None else []
    full = prev + list(s)
    off = len(prev)
    return [sum(h[l] * full[off + k - l] for l in range(len(h)) if off + k - l >= 0) for k in range(len(s))]
test_frequency_domain_equalization.py 134 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/frequency-domain-equalization/. The authors are listed in prov/8TF7E6.jsonl.

import cmath
import math
import random

import pytest

from frequency_domain_equalization import add_cyclic_prefix, channel, fde, fft, mmse_mse, zf_mse


def cn(rng, var):
    s = math.sqrt(var / 2)
    return complex(rng.gauss(0, s), rng.gauss(0, s))


def dft(x):
    n = len(x)
    return [sum(x[t] * cmath.exp(-2j * math.pi * k * t / n) for t in range(n)) for k in range(n)]


def solve(a, b):
    n = len(a)
    m = [row[:] + [b[i]] for i, row in enumerate(a)]
    for c in range(n):
        p = max(range(c, n), key=lambda r: abs(m[r][c]))
        m[c], m[p] = m[p], m[c]
        for r in range(c + 1, n):
            f = m[r][c] / m[c][c]
            for k in range(c, n + 1):
                m[r][k] -= f * m[c][k]
    x = [0j] * n
    for r in range(n - 1, -1, -1):
        x[r] = (m[r][n] - sum(m[r][k] * x[k] for k in range(r + 1, n))) / m[r][r]
    return x


QPSK = [complex(a, b) / math.sqrt(2) for a in (-1, 1) for b in (-1, 1)]


def test_example_on_the_page() -> None:
    x = [1, -1, -1, 1]
    r = channel(add_cyclic_prefix(x, 1), [1, 0.5])
    assert r[1:] == [1.5, -0.5, -1.5, 0.5]
    y = fft(r[1:])
    want = [0, 3 + 1j, 0, 3 - 1j]
    assert max(abs(a - b) for a, b in zip(y, want)) < 1e-12
    hf = fft([1, 0.5, 0, 0])
    assert max(abs(a - b) for a, b in zip(hf, [1.5, 1 - 0.5j, 0.5, 1 + 0.5j])) < 1e-12
    assert max(abs(a - b) for a, b in zip(fde(r, [1, 0.5], 4, 1), x)) < 1e-12
    assert abs(mmse_mse([1, 0.5], 4, 0.1) - 0.119104) < 1e-6
    assert abs(zf_mse([1, 0.5], 4, 0.1) - 0.151111) < 1e-6


def test_fft_matches_the_direct_dft() -> None:
    rng = random.Random(7801)
    for n in list(range(1, 17)) + [32, 64]:
        x = [cn(rng, 1.0) for _ in range(n)]
        a, b = fft(x), dft(x)
        assert max(abs(u - v) for u, v in zip(a, b)) < 1e-9
        back = fft(a, inverse=True)
        assert max(abs(u - v) for u, v in zip(back, x)) < 1e-9


def test_zero_forcing_inverts_the_channel_without_noise() -> None:
    rng = random.Random(7802)
    for _ in range(30):
        taps = rng.randint(1, 6)
        h = [cn(rng, 1.0) for _ in range(taps)]
        n = rng.choice((8, 12, 16, 32))
        p = taps - 1 + rng.randint(0, 2)
        prev = [rng.choice(QPSK) for _ in range(n + p)]
        x = [rng.choice(QPSK) for _ in range(n)]
        r = channel(add_cyclic_prefix(x, p), h, prev)  # the previous block's tail falls into the prefix
        est = fde(r, h, n, p)
        assert max(abs(a - b) for a, b in zip(est, x)) < 1e-9


def test_short_prefix_leaves_interblock_interference() -> None:
    rng = random.Random(7803)
    h = [1, 0.6, 0.4, 0.3]
    x = [rng.choice(QPSK) for _ in range(16)]
    prev = [rng.choice(QPSK) for _ in range(17)]
    r = channel(add_cyclic_prefix(x, 1), h, prev)
    with pytest.raises(ValueError):
        fde(r, h, 16, 1)
    # the one-tap equalizer applied anyway: the tail of the previous block stays in the result
    y = r[1:]
    xf, hf = fft(y), fft(h + [0] * 12)
    wrong = fft([a / b for a, b in zip(xf, hf)], inverse=True)
    assert max(abs(a - b) for a, b in zip(wrong, x)) > 1e-2


def test_mmse_equals_the_circulant_matrix_solution() -> None:
    rng = random.Random(7804)
    for _ in range(6):
        n, h = rng.choice((8, 12, 16)), [cn(rng, 1.0) for _ in range(3)]
        n0, es = rng.uniform(0.05, 1.0), rng.uniform(0.5, 2.0)
        r = [cn(rng, 1.0) for _ in range(n + 2)]
        est = fde(r, h, n, 2, n0, es)
        hc = [[h[(i - j) % n] if (i - j) % n < len(h) else 0j for j in range(n)] for i in range(n)]
        y = r[2:]
        a = [[sum(hc[k][i].conjugate() * hc[k][j] for k in range(n)) + (n0 / es if i == j else 0) for j in range(n)] for i in range(n)]
        b = [sum(hc[k][i].conjugate() * y[k] for k in range(n)) for i in range(n)]
        want = solve(a, b)
        assert max(abs(u - v) for u, v in zip(est, want)) < 1e-9


def test_measured_mse_matches_the_formula() -> None:
    # QPSK with Es = 1, N = 64, P = 2, N0 = 0.1, 200 blocks, seed 7805: MMSE on Proakis channel B
    # and ZF on (1, 0.5); ZF on B is useless, because B has |H|^2 = 1e-6 at bin 32
    rng = random.Random(7805)
    n, p, n0 = 64, 2, 0.1
    for h, mode in (([0.407, 0.815, 0.407], n0), ([1, 0.5], None)):
        formula = mmse_mse(h, n, n0) if mode else zf_mse(h, n, n0)
        total, count = 0.0, 0
        prev = [rng.choice(QPSK) for _ in range(n + p)]
        for _ in range(200):
            x = [rng.choice(QPSK) for _ in range(n)]
            s = add_cyclic_prefix(x, p)
            r = [v + cn(rng, n0) for v in channel(s, h, prev)]
            prev = s
            est = fde(r, h, n, p, mode)
            total += sum(abs(a - b) ** 2 for a, b in zip(est, x))
            count += n
        assert abs(total / count - formula) < 0.04 * formula


def test_input_checks() -> None:
    with pytest.raises(ValueError):
        fde([0j] * 9, [1, 0.5, 0.2], 8, 1)
    with pytest.raises(ValueError):
        fde([0j] * 8, [1, 0.5], 8, 1)

History

In 1995, Sari, Karam and Jeanclaude compared OFDM with single-carrier transmission equalized in the frequency domain for digital terrestrial television, and showed that the two receivers have about the same complexity when both use the FFT. In 2002, Falconer, Ariyavisitakul, Benyamin-Seeyar and Eidson described SC-FDE for broadband wireless, with the cyclic prefix, the ZF and MMSE taps, the decision feedback variants and the comparison with OFDM. SC-FDMA, the uplink of LTE, uses the same receiver.

References

  1. David Falconer, Sirikiat Lek Ariyavisitakul, Anader Benyamin-Seeyar and Brian Eidson, Frequency domain equalization for single-carrier broadband wireless systems, IEEE Communications Magazine 40(4), 2002, pages 58 to 66, the block structure with the cyclic prefix, the ZF and MMSE taps per bin, and the comparison with OFDM
  2. Hikmet Sari, Georges Karam and Isabelle Jeanclaude, Transmission techniques for digital terrestrial TV broadcasting, IEEE Communications Magazine 33(2), 1995, pages 100 to 109, single-carrier transmission with frequency-domain equalization against OFDM

Where this leads

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
  • at least three sources
  • a scene preset for the example