Algorithmcore
V-BLAST
Also called vertical BLAST, ordered successive interference cancellation.
Detects the spatially multiplexed streams one at a time, the stream with the best post-detection SNR first, nulling the streams not yet detected and cancelling each decision.
- Solves
- MIMO detection
- Time
- O(n^3 m + n^4 + n M) worst
- Space
- O(n m) extra
- Counts
- time per vector after setup O(n m + n M) worst
- Where
- M = the constellation size; m = the number of receive antennas; n = the number of transmitted streams
- Model
- Real RAM
- Properties
- deterministicnot exact mlnot linearmmse nulling reaches capacity with codingorder depends only on channelorder maximizes smallest snr
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Peter W. Wolniansky, Gerard J. Foschini, Glen D. Golden, Reinaldo A. Valenzuela, 1998
V-BLAST (vertical Bell Laboratories layered space-time) is the receiver that made spatial multiplexing practical. It solves the MIMO detection problem one stream at a time. At each step it computes the nulling filter of the zero-forcing MIMO detector or the MMSE MIMO detector for the streams not yet detected, picks the stream with the highest post-detection SNR, slices it, and subtracts its contribution from the received vector. Each cancellation removes one interferer, so the later streams see a channel with fewer columns and less noise enhancement. The detector differs from the linear detectors because it uses its own decisions, and from multiuser successive interference cancellation because it chooses the order from the post-detection SNR of the channel matrix, not from the received power of each user. The order maximizes the smallest post-detection SNR over all orders (a theorem). A wrong decision propagates to the later streams, so V-BLAST is still far from ML at high SNR. D-BLAST uses the same receiver on a diagonal layering that removes the rate loss in slow fading.
In plain words
Several antennas send different symbols at the same time. The receiver first finds the one symbol that it can see most clearly, after it blocks out the others. It decides that symbol. Then it subtracts that symbol from what it received, as if that antenna had never sent anything. Now the problem is smaller, and the next symbol is easier to see. The receiver repeats this until all symbols are decided. Starting with the clearest symbol is important: an early mistake spoils every later step, so the receiver makes its first decisions where a mistake is least likely.
The problem
The model is . Here is the known channel matrix with columns , holds one point of a constellation of size and energy per stream, and . ZF nulling needs and full column rank. MMSE nulling works for every and needs . For a set of streams, is the matrix of the columns in . The output is a decision and the order in which the streams were detected.
The algorithm
V-BLAST(y, H, S, a) ▷ a = 0 for ZF nulling, a = N0/Es for MMSE- 1
r ← y; K ← {1, ..., n} - 2
while K is not empty - 3
P ← (H_Kᴴ H_K + a I)⁻¹; W ← P H_Kᴴ - 4
k ← the stream in K with the smallest P_kk - 5
z ← (row k of W) r ▷ for MMSE, divide by 1 - a P_kk - 6
x̂_k ← the point of S nearest to z - 7
r ← r - h_k x̂_k - 8
K ← K \ {k} - 9
return x̂
Line L3 is the nulling filter for the streams still in . For ZF () the stream has the post-detection SNR , and for MMSE it has the unbiased SINR , so line L4 picks the stream with the best SNR or SINR in both cases. Line L5 for MMSE removes the bias of the MMSE estimate, as in the MMSE MIMO detector. Line L7 cancels the decided stream. If the decision is right, the new equals , a smaller problem of the same kind. Lines L3 and L4 depend only on and , so a receiver computes the order and the nulling rows once per channel and reuses them for every received vector of a block.
Example
Take , BPSK with , , and the real channel
The transmitter sends , so . The noise is , and the receiver gets . The plain ZF output is , which gives : stream 2 is wrong.
V-BLAST with ZF nulling runs as follows.
- Lines L3 and L4: , so stream 1 goes first. Its nulling row is row 1 of , , and line L5 gives , so .
- Line L7: .
- Now and . Line L5 gives , so .
The decision is right, and it is also the ML decision: its metric is the smallest of the four candidates (the others give 3.05, 7.85 and 19.45). In units of , the post-detection SNRs of the two steps are and . The other order would give for stream 2 first and then . V-BLAST takes the order whose worse step is better, 0.5 against 0.2.
The other order also fails on this . Stream 2 first gives , so , which is wrong. The cancellation then subtracts the wrong symbol: , and gives , which is wrong too. This is error propagation.
Correctness
The proof is in proofs/correctness.md. It shows four things. First, with ZF nulling and no noise, every step sees its stream with no interference, and V-BLAST returns (a theorem). Second, the post-detection SNR of a stream can only grow when other streams leave , for ZF and for MMSE (a theorem). Third, from this monotonicity, an exchange argument shows that the greedy choice of line L4 maximizes the smallest post-detection SNR or SINR over all orders, assuming correct earlier decisions (a theorem). Fourth, with MMSE nulling and correct cancellation, in every order, so per-stream coding at these rates reaches the MIMO capacity of the channel (a theorem, Tse and Viswanath, Section 8.3.4).
Proof: V-BLAST is exact without noise, its order maximizes the smallest post-detection SNR, and MMSE nulling with correct cancellation adds up to the capacityfull
The model is with , columns , with , and . For a set of streams and , let be the matrix of the columns in , let be the same matrix without column , and let , with (ZF, which needs of full column rank) or (MMSE). The entry of that belongs to stream is written .
All SNR statements below assume that the earlier decisions are right. Then, before the step that detects from the set , line L7 has left .
Theorem 1 (exact without noise). With ZF nulling and , V-BLAST returns .
Proof. By induction over the steps, the invariant is . At the start and . At a step with the set , the nulling matrix is , so and . Row gives , a point of , so line L6 returns at distance 0. Line L7 then gives , and line L8 gives the invariant for the new set.
Lemma 2 (the SNR of one step). Let be the post-detection SNR (ZF) or the unbiased SINR (MMSE) of stream at the step with the set . Then
where is the orthogonal projection onto the complement of the span of the columns in .
Proof. For ZF, the SNR is Theorem 2 of the ZF MIMO detector applied to , and is Lemma 3 of the same page. For MMSE, write with , whose covariance is . The largest SINR of a linear estimate of is , which gives the first form, and the MMSE MIMO detector reaches it with the unbiased SINR (its Theorem 3).
So for both kinds of nulling, falls when grows, and line L4 picks the stream with the largest in .
Lemma 3 (fewer interferers never hurt). If , then .
Proof. ZF: the span of the columns in is a subspace of the span of the columns in . The distance from to a subspace is at least the distance to a larger subspace, so .
MMSE: let and . Then is positive semidefinite, and is positive definite. For positive definite matrices, implies . So .
Theorem 4 (the order is optimal in the max-min sense). For an order of the streams, let and , the smallest post-detection SNR or SINR along the order. Let be the order chosen by line L4, with any rule for ties. Then for every order .
Proof. By induction on . For there is only one order. Let , let be any order, let , and let , a stream with the largest . Suppose .
Exchange step. Let be the order that puts first and keeps the other streams in the order of . Compare the terms of with those of :
- The stream gets , by the choice of and because the first term of is one of the terms of the minimum.
- A stream with is detected from the set in , a subset of , so by Lemma 3 its term does not fall.
- A stream with has the same set in both orders, so its term is the same.
So .
Reduction. After , both and detect the streams , and the terms depend only on the sets of remaining streams. This is the same problem for the channel with columns, and the remaining part of is the order that line L4 chooses for it. By the induction hypothesis, the smallest term of the rest of is at least the smallest term of the rest of . So
Corollary 5 (no stream is worse than with linear detection). In the order , each stream has , the SNR or SINR of the linear ZF or MMSE detector. With ZF nulling in i.i.d. fading, the first detected stream has an error probability that decays at least as fast as .
Proof. The first part is Lemma 3 with . For the second part, the first stream has the SNR . By Theorem 4 of the ZF page, is a sum of independent unit exponentials, so . The same bound then holds for the maximum. Write and , so . The error probability of a slicer at SNR is at most for constants of the constellation. Averaged over the fading, with ,
Theorem 6 (MMSE-SIC adds up to the capacity). With MMSE nulling and correct cancellation, for every order ,
Proof. Let , and , with . By the cofactor formula for the inverse, , because the cofactor of the diagonal entry of is the determinant of the matrix without row and column , which is . By Lemma 2,
The sets lose one stream at each step, so the product over telescopes:
Since , the base 2 logarithm gives the claim.
The right side is the capacity of the channel with equal power per transmit antenna and no channel knowledge at the transmitter. So if each stream carries a capacity-achieving code of rate and the receiver decodes each stream before it cancels it, the sum rate equals this capacity, which is the statement of Tse and Viswanath, Section 8.3.4. Theorem 6 holds for every order; the order of Theorem 4 matters for uncoded detection, where the weakest step limits the error rate.
Complexity
The direct method of line L3 inverts an matrix for , at a cost of each, so the setup per channel costs in the real RAM. The square-root algorithm of Hassibi (2000) finds the same order and nulling rows without a new inverse at each step. After the setup, each received vector costs inner products of length for line L5, updates of length for line L7 and slicings of each, so . The extra space is for the nulling rows. The implementation on this page recomputes the setup on every call, for clarity.
Properties
- Exact without noise. With ZF nulling and , every decision is right (theorem).
- Best order in the max-min sense. Among all orders, the order of line L4 maximizes the smallest post-detection SNR (ZF) or SINR (MMSE), assuming correct earlier decisions (theorem).
- Order from the channel only. The order does not depend on , so it is computed once per channel.
- Never worse than linear in SNR. The first stream has the best ZF or MMSE SNR of all streams, and each later stream has an SNR at least as high as with linear detection (theorem, from the monotonicity).
- Capacity with MMSE and coding. With MMSE nulling, Gaussian codebooks and correct cancellation, the stream rates add up to (theorem).
- Error propagation. Uncoded V-BLAST cancels hard decisions, so a wrong early decision makes later decisions more likely wrong.
- Diversity. In i.i.d. Rayleigh fading with ZF nulling, the first detected stream has at least the diversity of a ZF stream (theorem). Because of error propagation, uncoded V-BLAST does not reach the diversity of ML in general (rule).
- Measured agreement with ML. For 4-QAM with , i.i.d. channel entries and dB, the test with seed 1405 runs 150 random vectors. ZF V-BLAST agreed with ML on 147 vectors and MMSE V-BLAST on all 150. ZF V-BLAST made 7 symbol errors, and plain ZF made 24 (measurement).
Variants and improvements
- MMSE nulling. Set in line L3. This is often called MMSE V-BLAST or MMSE-SIC. It needs . In the 4 by 4, 4-QAM measurement under Properties, it agreed with ML on every vector at 15 dB.
- Square-root and QR methods. The square-root algorithm of Hassibi (2000) avoids one inverse per step. A QR decomposition with the columns sorted during the factorization gives a near-optimal order for the cost of one QR. With a fixed order, ZF-SIC is the Babai nearest plane rule and the spatial version of the decision feedback equalizer.
- Coded layers. If each stream carries its own channel code, the receiver decodes a whole stream before it cancels it, which reduces error propagation. With MMSE nulling this reaches the capacity in fast fading (Tse and Viswanath, Section 8.3.4).
- Diagonal layering. In slow fading a stream that sits on one bad antenna fails. D-BLAST rotates each codeword over all antennas.
- Several candidates. The K-best detector keeps the best partial decisions instead of one, which reduces error propagation at a known cost.
When to use it
Use V-BLAST when the linear detectors lose too much and ML or a sphere search is too expensive, with up to about 8 streams. Use MMSE nulling whenever is known. In a coded system, use it with per-stream codes and decode each stream before cancelling. For a near-ML error rate on a square channel at high SNR, use the K-best detector, lattice reduction aided detection, or Schnorr-Euchner enumeration instead.
Pitfalls
- Wrong order of the bias step. Line L4 compares before the bias removal of line L5. Removing the bias does not change the order, because the unbiased SINR also falls with .
- Picking the stream by its column norm. The stream with the strongest column is not always the one with the best post-detection SNR. In the example, stream 1 has but only the SNR 0.5 after ZF nulling; the right measure is .
- Cancelling with the wrong scale. Line L7 subtracts with the full column, not with the nulled output .
- Error propagation is not in the SNR. The post-detection SNRs assume correct earlier decisions. The real error rate of later streams is higher.
- ZF with . The first step has a singular . Use MMSE nulling, which works for any , or transmit fewer streams.
- Recomputing per vector. Lines L3 and L4 depend only on ; recomputing them for each received vector multiplies the cost by the block length.
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.
# SPDX-License-Identifier: MIT
# Shared helper of the communications pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Complex baseband tools for the communications pages.
Vectors are lists of complex numbers. Matrices are lists of rows. The
functions here are plain building blocks: small linear algebra, convolution,
the DFT as a direct sum, the Gaussian Q function, dB conversion, complex
Gaussian noise and the Wilson score interval. No page algorithm (equalizer,
estimator, synchronizer, detector, precoder, demapper or power allocation)
lives in this file.
Conventions (prompts of the communications area):
- dft is X[k] = sum_n x[n] e^(-j 2 pi k n / N) with no factor; idft has 1/N.
- udft and uidft are the unitary pair, with 1/sqrt(N) on both sides.
- qfunc(x) = 0.5 erfc(x / sqrt(2)); it never computes 1 - Phi(x).
- cn(rng, var) draws CN(0, var): real and imaginary parts are independent
with variance var / 2 each, so E|w|^2 = var.
"""
import cmath
import math
import random
# ---------------------------------------------------------------- vectors and matrices
def zeros(rows: int, cols: int | None = None) -> list:
"""A zero vector of length rows, or a rows by cols zero matrix."""
if cols is None:
return [0j] * rows
return [[0j] * cols for _ in range(rows)]
def eye(n: int) -> list[list[complex]]:
"""The n by n identity matrix."""
return [[1 + 0j if i == k else 0j for k in range(n)] for i in range(n)]
def add(a: list, b: list) -> list:
"""Elementwise a + b for two vectors or two matrices of the same shape."""
if len(a) != len(b):
raise ValueError("shapes differ")
if a and isinstance(a[0], list):
return [add(r, s) for r, s in zip(a, b)]
return [x + y for x, y in zip(a, b)]
def sub(a: list, b: list) -> list:
"""Elementwise a - b for two vectors or two matrices of the same shape."""
if len(a) != len(b):
raise ValueError("shapes differ")
if a and isinstance(a[0], list):
return [sub(r, s) for r, s in zip(a, b)]
return [x - y for x, y in zip(a, b)]
def scale(c: complex, a: list) -> list:
"""The scalar c times a vector or a matrix."""
if a and isinstance(a[0], list):
return [scale(c, r) for r in a]
return [c * x for x in a]
def matmul(a: list[list[complex]], b: list[list[complex]]) -> list[list[complex]]:
"""The matrix product a b."""
if not a or not b or len(a[0]) != len(b):
raise ValueError("inner dimensions differ")
cols = list(zip(*b))
return [[sum(x * y for x, y in zip(row, col)) for col in cols] for row in a]
def matvec(a: list[list[complex]], x: list[complex]) -> list[complex]:
"""The matrix times vector product a x."""
if a and len(a[0]) != len(x):
raise ValueError("inner dimensions differ")
return [sum(p * q for p, q in zip(row, x)) for row in a]
def herm(a: list) -> list:
"""The conjugate transpose of a matrix. A vector gives its conjugate."""
if a and isinstance(a[0], list):
return [[complex(a[i][k]).conjugate() for i in range(len(a))] for k in range(len(a[0]))]
return [complex(x).conjugate() for x in a]
def dot(x: list[complex], y: list[complex]) -> complex:
"""The inner product x^H y = sum of conj(x_i) y_i."""
if len(x) != len(y):
raise ValueError("lengths differ")
return sum(complex(p).conjugate() * q for p, q in zip(x, y))
def norm2(x: list) -> float:
"""The squared Euclidean norm sum |x_i|^2 (squared Frobenius norm for a matrix)."""
if x and isinstance(x[0], list):
return sum(norm2(r) for r in x)
return sum(abs(v) ** 2 for v in x)
# ---------------------------------------------------------------- linear systems
def _lu(a: list[list[complex]]) -> tuple[list[list[complex]], list[int], int]:
"""LU factorization with partial pivoting. Returns (lu, perm, sign)."""
n = len(a)
if any(len(r) != n for r in a):
raise ValueError("matrix is not square")
m = [[complex(v) for v in r] for r in a]
perm = list(range(n))
sign = 1
for k in range(n):
p = max(range(k, n), key=lambda i: abs(m[i][k]))
if abs(m[p][k]) == 0.0:
raise ValueError("matrix is singular")
if p != k:
m[k], m[p] = m[p], m[k]
perm[k], perm[p] = perm[p], perm[k]
sign = -sign
for i in range(k + 1, n):
f = m[i][k] / m[k][k]
m[i][k] = f
if f != 0:
rk, ri = m[k], m[i]
for c in range(k + 1, n):
ri[c] -= f * rk[c]
return m, perm, sign
def _lu_solve(lu: list[list[complex]], perm: list[int], b: list[complex]) -> list[complex]:
n = len(lu)
y = [complex(b[perm[i]]) for i in range(n)]
for i in range(n):
for c in range(i):
y[i] -= lu[i][c] * y[c]
for i in range(n - 1, -1, -1):
for c in range(i + 1, n):
y[i] -= lu[i][c] * y[c]
y[i] /= lu[i][i]
return y
def solve(a: list[list[complex]], b: list) -> list:
"""Solve a x = b by Gaussian elimination with partial pivoting.
b is a vector, or a matrix whose columns are right-hand sides.
Raises ValueError if a is singular.
"""
lu, perm, _ = _lu(a)
if b and isinstance(b[0], list):
cols = [list(c) for c in zip(*b)]
xs = [_lu_solve(lu, perm, c) for c in cols]
return [list(r) for r in zip(*xs)]
if len(b) != len(a):
raise ValueError("lengths differ")
return _lu_solve(lu, perm, b)
def inv(a: list[list[complex]]) -> list[list[complex]]:
"""The inverse of a square matrix."""
return solve(a, eye(len(a)))
def det(a: list[list[complex]]) -> complex:
"""The determinant of a square matrix (0 for a singular matrix)."""
try:
lu, _, sign = _lu(a)
except ValueError as e:
if "singular" in str(e):
return 0j
raise
d = complex(sign)
for i in range(len(lu)):
d *= lu[i][i]
return d
def cholesky(a: list[list[complex]]) -> list[list[complex]]:
"""The lower triangular L with a = L L^H, for a Hermitian positive definite a.
Raises ValueError if a is not positive definite (to rounding).
"""
n = len(a)
low = zeros(n, n)
for i in range(n):
for k in range(i + 1):
s = complex(a[i][k]) - sum(low[i][c] * low[k][c].conjugate() for c in range(k))
if i == k:
if s.real <= 0.0:
raise ValueError("matrix is not positive definite")
low[i][i] = complex(math.sqrt(s.real))
else:
low[i][k] = s / low[k][k].real
return low
# ---------------------------------------------------------------- convolution and the DFT
def conv(a: list[complex], b: list[complex]) -> list[complex]:
"""Linear convolution, of length len(a) + len(b) - 1."""
if not a or not b:
return []
out = [0j] * (len(a) + len(b) - 1)
for i, x in enumerate(a):
for k, y in enumerate(b):
out[i + k] += x * y
return out
def cconv(a: list[complex], b: list[complex], n: int | None = None) -> list[complex]:
"""Circular convolution of length n (default: the longer length).
Both inputs are padded with zeros to length n, or must not be longer than n.
"""
if n is None:
n = max(len(a), len(b))
if len(a) > n or len(b) > n:
raise ValueError("input longer than n")
out = [0j] * n
for i, x in enumerate(a):
for k, y in enumerate(b):
out[(i + k) % n] += x * y
return out
def _twiddles(n: int, sign: int) -> list[complex]:
return [cmath.exp(sign * 2j * math.pi * t / n) for t in range(n)]
def dft(x: list[complex]) -> list[complex]:
"""X[k] = sum over n of x[n] e^(-j 2 pi k n / N), as a direct O(N^2) sum."""
n = len(x)
w = _twiddles(n, -1)
return [sum(x[t] * w[(k * t) % n] for t in range(n)) for k in range(n)]
def idft(xf: list[complex]) -> list[complex]:
"""x[n] = (1/N) sum over k of X[k] e^(j 2 pi k n / N), the inverse of dft."""
n = len(xf)
w = _twiddles(n, 1)
return [sum(xf[k] * w[(k * t) % n] for k in range(n)) / n for t in range(n)]
def udft(x: list[complex]) -> list[complex]:
"""The unitary DFT: dft(x) / sqrt(N)."""
s = 1.0 / math.sqrt(len(x)) if x else 1.0
return [v * s for v in dft(x)]
def uidft(xf: list[complex]) -> list[complex]:
"""The unitary inverse DFT: sqrt(N) idft(X), the inverse of udft."""
s = math.sqrt(len(xf)) if xf else 1.0
return [v * s for v in idft(xf)]
# ---------------------------------------------------------------- Q function and dB
def qfunc(x: float) -> float:
"""Q(x) = P(Z > x) for a standard normal Z, computed as 0.5 erfc(x / sqrt(2))."""
return 0.5 * math.erfc(x / math.sqrt(2.0))
def qinv(p: float) -> float:
"""The x with Q(x) = p, for 0 < p < 1, by bisection on Q (which decreases)."""
if not 0.0 < p < 1.0:
raise ValueError("p must be in (0, 1)")
lo, hi = -40.0, 40.0
for _ in range(200):
mid = 0.5 * (lo + hi)
if qfunc(mid) > p:
lo = mid
else:
hi = mid
if hi - lo <= 1e-15 * max(1.0, abs(mid)):
break
return 0.5 * (lo + hi)
def db(x: float) -> float:
"""10 log10(x), for a ratio of powers or energies."""
return 10.0 * math.log10(x)
def undb(d: float) -> float:
"""10^(d / 10), the inverse of db."""
return 10.0 ** (d / 10.0)
# ---------------------------------------------------------------- noise and statistics
def cn(rng: random.Random, var: float) -> complex:
"""One sample of CN(0, var): independent real and imaginary parts of variance var / 2."""
s = math.sqrt(var / 2.0)
return complex(rng.gauss(0.0, s), rng.gauss(0.0, s))
def awgn(rng: random.Random, x: list[complex], n0: float) -> list[complex]:
"""x plus independent CN(0, n0) noise on each sample."""
return [v + cn(rng, n0) for v in x]
def wilson(k: int, n: int, z: float = 3.29) -> tuple[float, float]:
"""The Wilson score interval for k successes in n trials (z = 3.29 is about 0.999 two-sided)."""
if n <= 0 or not 0 <= k <= n:
raise ValueError("need 0 <= k <= n and n > 0")
p = k / n
z2 = z * z
den = 1.0 + z2 / n
mid = (p + z2 / (2 * n)) / den
half = z * math.sqrt(p * (1 - p) / n + z2 / (4 * n * n)) / den
return max(0.0, mid - half), min(1.0, mid + half)
constel.py 117 lines
# SPDX-License-Identifier: MIT
# Shared helper of the communications pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Constellations, Gray labels and brute-force maximum likelihood detection.
Each constellation function returns a list of M complex points with unit
average energy, ordered by label: points[i] is the point whose bit label is
the integer i, and bits(i, log2 M) gives that label, most significant bit
first. The labels follow the communications area rules:
- M-PAM: the point with amplitude index m = 0, ..., M-1 (raw amplitude
M - 1 - 2m, from the most positive) gets the Gray label gray(m).
So 2-PAM maps bit 0 to +1 and bit 1 to -1.
- Square M-QAM, M = 4^k: the label is the in-phase PAM label followed by the
quadrature PAM label, each of log2(sqrt(M)) bits.
- M-PSK: the point e^(j(2 pi m / M + phase0)) gets the label gray(m).
PAM points are returned as complex numbers with zero imaginary part.
This file imports nothing from cbb.py. It holds no demapper: soft and
max-log demapping are algorithm pages of their own.
"""
import cmath
import itertools
import math
def gray(n: int) -> int:
"""The binary reflected Gray code of n: n XOR (n >> 1)."""
return n ^ (n >> 1)
def _gray_inv(g: int) -> int:
n = 0
while g:
n ^= g
g >>= 1
return n
def bits(i: int, m: int) -> list[int]:
"""The m bits of the integer i, most significant bit first."""
if i < 0 or i >= 1 << m:
raise ValueError("i does not fit in m bits")
return [(i >> (m - 1 - t)) & 1 for t in range(m)]
def _log2(m: int) -> int:
if m < 2 or m & (m - 1):
raise ValueError("M must be a power of two, at least 2")
return m.bit_length() - 1
def pam(m: int) -> list[complex]:
"""Unit-energy M-PAM, ordered by Gray label."""
_log2(m)
s = math.sqrt((m * m - 1) / 3.0)
return [complex((m - 1 - 2 * _gray_inv(lab)) / s, 0.0) for lab in range(m)]
def qam(m: int) -> list[complex]:
"""Unit-energy square M-QAM (M = 4, 16, 64, ...), ordered by label (in-phase bits first)."""
k = _log2(m)
if k % 2:
raise ValueError("square QAM needs M = 4^k")
side = 1 << (k // 2)
s = math.sqrt(2.0 * (m - 1) / 3.0)
raw = [side - 1 - 2 * _gray_inv(lab) for lab in range(side)]
return [complex(raw[lab // side], raw[lab % side]) / s for lab in range(m)]
def psk(m: int, phase0: float = 0.0) -> list[complex]:
"""Unit-energy M-PSK with first point at angle phase0, ordered by Gray label."""
_log2(m)
return [cmath.exp(1j * (2.0 * math.pi * _gray_inv(lab) / m + phase0)) for lab in range(m)]
def energy(points: list[complex]) -> float:
"""The average energy (1/M) sum |p|^2 of equally likely points."""
return sum(abs(p) ** 2 for p in points) / len(points)
def ml_detect(y: complex, points: list[complex], h: complex = 1) -> int:
"""The index of the point p that minimizes |y - h p|^2, by brute force (lowest index on a tie)."""
best, arg = math.inf, -1
for i, p in enumerate(points):
d = abs(y - h * p) ** 2
if d < best:
best, arg = d, i
return arg
def ml_vector(y: list[complex], h: list[list[complex]], points: list[complex]) -> list[int]:
"""The index vector that minimizes ||y - H x||^2 over all M^n vectors x, by brute force.
h is the m by n channel matrix as a list of rows; the result has n indices.
The first minimizer in lexicographic order of the indices wins a tie.
"""
n = len(h[0])
best, arg = math.inf, None
for idx in itertools.product(range(len(points)), repeat=n):
x = [points[i] for i in idx]
d = 0.0
for yi, row in zip(y, h):
d += abs(yi - sum(a * b for a, b in zip(row, x))) ** 2
if d < best:
best, arg = d, idx
return list(arg)
def bit_errors(a, b) -> int:
"""The number of differing bits between two integer labels, or summed over two equal-length lists."""
if isinstance(a, int) and isinstance(b, int):
return bin(a ^ b).count("1")
if len(a) != len(b):
raise ValueError("lengths differ")
return sum(bit_errors(x, y) for x, y in zip(a, b))
v_blast.py 98 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/v-blast/. The authors are listed in prov/Z0RT80.jsonl.
"""The V-BLAST detector: ordered nulling and cancelling.
The model is y = H x + w with H an m by n complex matrix, x a vector of n
constellation points of energy Es and w ~ CN(0, N0 I). At each step the
detector looks at the streams not yet detected (the set K), computes
P = (H_K^H H_K + a I)^(-1), with a = 0 for ZF nulling and a = N0 / Es for
MMSE nulling, and picks the stream k in K with the smallest P_kk, which is
the stream with the largest post-detection SNR (ZF) or SINR (MMSE). It
nulls the other streams of K with row k of P H_K^H, slices the result,
subtracts h_k times the decision from the received vector and removes k
from K. With a = 0 this is the receiver of Wolniansky, Foschini, Golden and
Valenzuela (1998).
"""
import cbb
def nearest(z: complex, points: list[complex]) -> int:
"""The index of the point nearest to z (the lowest index on a tie)."""
best, arg = float("inf"), -1
for i, p in enumerate(points):
d = abs(z - p) ** 2
if d < best:
best, arg = d, i
return arg
def _columns(h: list[list[complex]], cols: list[int]) -> list[list[complex]]:
return [[row[c] for c in cols] for row in h]
def _nulling(h: list[list[complex]], cols: list[int], a: float) -> tuple[list[list[complex]], list[list[complex]]]:
"""(P, P H_K^H) for the columns cols of H, with P = (H_K^H H_K + a I)^(-1)."""
hk = _columns(h, cols)
hh = cbb.herm(hk)
g = cbb.matmul(hh, hk)
for i in range(len(cols)):
g[i][i] += a
try:
p = cbb.inv(g)
except ValueError:
raise ValueError("the remaining columns of H are dependent; use MMSE nulling or fewer streams") from None
return p, cbb.matmul(p, hh)
def vblast_detect(
y: list[complex],
h: list[list[complex]],
points: list[complex],
n0: float = 0.0,
es: float = 1.0,
mmse: bool = False,
) -> tuple[list[int], list[int]]:
"""The V-BLAST decisions and the detection order.
Returns (indices, order): indices[k] is the point index decided for
stream k, and order lists the streams in the order they were detected.
mmse=False gives ZF nulling and needs m >= n; mmse=True needs N0 > 0.
"""
n = len(h[0])
if mmse and n0 <= 0:
raise ValueError("MMSE nulling needs N0 > 0")
if not mmse and len(h) < n:
raise ValueError("ZF nulling needs at least as many receive antennas as streams")
a = n0 / es if mmse else 0.0
r = [complex(v) for v in y]
remaining = list(range(n)) # @line L1
out = [-1] * n
order = []
while remaining: # @line L2
p, w = _nulling(h, remaining, a) # @line L3
i = min(range(len(remaining)), key=lambda t: p[t][t].real) # @line L4
k = remaining[i]
z = sum(c * v for c, v in zip(w[i], r)) # @line L5
if mmse:
z /= 1.0 - a * p[i][i].real # remove the MMSE bias
out[k] = nearest(z, points) # @line L6
s = points[out[k]]
r = [rv - row[k] * s for rv, row in zip(r, h)] # @line L7
remaining.pop(i) # @line L8
order.append(k)
return out, order # @line L9
def post_detection_snr(h: list[list[complex]], order: list[int], es: float, n0: float, mmse: bool = False) -> list[float]:
"""The SNR (ZF) or unbiased SINR (MMSE) of each step, in detection order, assuming correct earlier decisions."""
a = n0 / es
remaining = list(range(len(h[0])))
out = []
for k in order:
p, _ = _nulling(h, remaining, a if mmse else 0.0)
i = remaining.index(k)
out.append(1.0 / (a * p[i][i].real) - 1.0 if mmse else (es / n0) / p[i][i].real)
remaining.pop(i)
return out
test_v_blast.py 128 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/v-blast/. The authors are listed in prov/Z0RT80.jsonl.
import itertools
import math
import random
import pytest
import cbb
import constel
from v_blast import nearest, post_detection_snr, vblast_detect
def rayleigh(rng, m, n):
return [[cbb.cn(rng, 1.0) for _ in range(n)] for _ in range(m)]
def sic_fixed_order(y, h, points, order):
"""ZF nulling and cancelling in a given order, without the V-BLAST choice."""
r = list(y)
left = list(range(len(h[0])))
out = [-1] * len(left)
for k in order:
hk = [[row[c] for c in left] for row in h]
w = cbb.solve(cbb.matmul(cbb.herm(hk), hk), cbb.herm(hk))
i = left.index(k)
out[k] = nearest(sum(c * v for c, v in zip(w[i], r)), points)
r = [rv - row[k] * points[out[k]] for rv, row in zip(r, h)]
left.pop(i)
return out
def test_example_on_the_page() -> None:
h = [[2, 1], [1, 1]]
y = [0.7, 0.4] # x = (+1, -1) and w = (-0.3, 0.4)
bpsk = constel.pam(2)
w = cbb.inv(h)
z = cbb.matvec(w, y)
assert abs(z[0] - 0.3) < 1e-12 and abs(z[1] - 0.1) < 1e-12 # ZF decides (+1, +1)
assert vblast_detect(y, h, bpsk) == ([0, 1], [0, 1])
assert constel.ml_vector(y, h, bpsk) == [0, 1]
assert sic_fixed_order(y, h, bpsk, [1, 0]) == [1, 0] # the other order: two errors
a, b = post_detection_snr(h, [0, 1], 1.0, 1.0), post_detection_snr(h, [1, 0], 1.0, 1.0)
assert max(abs(a[0] - 0.5), abs(a[1] - 2.0), abs(b[0] - 0.2), abs(b[1] - 5.0)) < 1e-12
def test_noiseless_recovery_is_exact() -> None:
rng = random.Random(1401)
pts = constel.qam(16)
for _ in range(60):
n = rng.randint(1, 4)
m = rng.randint(n, 5)
h = rayleigh(rng, m, n)
idx = [rng.randrange(16) for _ in range(n)]
y = cbb.matvec(h, [pts[i] for i in idx])
d, order = vblast_detect(y, h, pts)
assert d == idx and sorted(order) == list(range(n))
d, _ = vblast_detect(y, h, pts, n0=1e-9, mmse=True)
assert d == idx
def test_greedy_order_maximizes_the_smallest_snr() -> None:
# theorem: the V-BLAST order maximizes the minimum post-detection SNR (ZF) or SINR (MMSE)
rng = random.Random(1402)
pts = constel.qam(4)
for _ in range(40):
n = rng.randint(2, 4)
m = rng.randint(n, 5)
h = rayleigh(rng, m, n)
for mmse in (False, True):
_, order = vblast_detect([0j] * m, h, pts, n0=0.1, mmse=mmse)
best = min(post_detection_snr(h, order, 1.0, 0.1, mmse))
for perm in itertools.permutations(range(n)):
assert min(post_detection_snr(h, list(perm), 1.0, 0.1, mmse)) <= best * (1 + 1e-9)
def test_mmse_sic_sinrs_add_up_to_the_capacity_in_any_order() -> None:
# theorem: with MMSE nulling and correct cancellation, sum log2(1 + SINR_k) = log2 det(I + (Es/N0) H^H H)
rng = random.Random(1403)
for _ in range(30):
n = rng.randint(1, 4)
m = rng.randint(1, 5)
h = rayleigh(rng, m, n)
snr = rng.uniform(0.5, 30.0)
g = cbb.matmul(cbb.herm(h), h)
cap = math.log2(abs(cbb.det(cbb.add(cbb.eye(n), cbb.scale(snr, g)))))
order = list(range(n))
rng.shuffle(order)
s = post_detection_snr(h, order, 1.0, 1.0 / snr, mmse=True)
assert abs(sum(math.log2(1 + v) for v in s) - cap) < 1e-9 * (1 + cap)
def test_one_stream_is_maximal_ratio_combining() -> None:
rng = random.Random(1404)
h = rayleigh(rng, 4, 1)
assert abs(post_detection_snr(h, [0], 1.0, 0.5)[0] - cbb.norm2([r[0] for r in h]) / 0.5) < 1e-12
def test_bad_arguments() -> None:
with pytest.raises(ValueError):
vblast_detect([0j], [[1, 1]], constel.pam(2))
with pytest.raises(ValueError):
vblast_detect([0j, 0j], [[1, 2], [2, 4]], constel.pam(2))
with pytest.raises(ValueError):
vblast_detect([0j], [[1]], constel.pam(2), n0=0.0, mmse=True)
def test_most_decisions_match_ml_and_beat_zf() -> None:
# measured: 4-QAM, m = n = 4, Es/N0 = 15 dB, seed 1405, 150 vectors
rng = random.Random(1405)
pts = constel.qam(4)
n0 = 1 / cbb.undb(15.0)
agree_zf = agree_mmse = err_vb = err_zf = 0
for _ in range(150):
h = rayleigh(rng, 4, 4)
idx = [rng.randrange(4) for _ in range(4)]
y = cbb.awgn(rng, cbb.matvec(h, [pts[i] for i in idx]), n0)
ml = constel.ml_vector(y, h, pts)
d, _ = vblast_detect(y, h, pts)
agree_zf += d == ml
agree_mmse += vblast_detect(y, h, pts, n0=n0, mmse=True)[0] == ml
err_vb += sum(a != b for a, b in zip(d, idx))
w = cbb.solve(cbb.matmul(cbb.herm(h), h), cbb.herm(h))
err_zf += sum(nearest(z, pts) != b for z, b in zip(cbb.matvec(w, y), idx))
print(agree_zf, agree_mmse, err_vb, err_zf)
assert agree_zf >= 140 and agree_mmse >= 145
assert err_vb < err_zf
History
Foschini described the layered space-time architecture with diagonal layers (D-BLAST) in 1996, and showed that its capacity grows linearly with the number of antennas. The diagonal layering was hard to build, so Wolniansky, Foschini, Golden and Valenzuela proposed the simpler vertical version in 1998, with the nulling, ordering and cancelling receiver on this page. Golden, Foschini, Valenzuela and Wolniansky reported the laboratory prototype in Electronics Letters in 1999. Hassibi gave the square-root algorithm in 2000. The view of the receiver as MMSE-SIC that reaches the capacity is part of the textbook treatment of Tse and Viswanath (2005).
References
- Peter W. Wolniansky, Gerard J. Foschini, Glen D. Golden and Reinaldo A. Valenzuela, V-BLAST - an architecture for realizing very high data rates over the rich-scattering wireless channel, Proc. URSI International Symposium on Signals, Systems and Electronics, Pisa, 1998, pages 295-300, the detection algorithm (nulling with the rows of the pseudoinverse, the ordering by the smallest row norm and the cancellation)
- Glen D. Golden, Gerard J. Foschini, Reinaldo A. Valenzuela and Peter W. Wolniansky, Detection algorithm and initial laboratory results using V-BLAST space-time communication architecture, Electronics Letters 35(1), 14-16, 1999, the recursive detection algorithm and the measured spectral efficiencies
- David Tse and Pramod Viswanath, Fundamentals of Wireless Communication, Cambridge University Press, 2005, Section 8.1 (the V-BLAST architecture), Section 8.3.2 (successive cancellation and error propagation) and Section 8.3.4 (MMSE-SIC reaches the capacity)
- Babak Hassibi, An efficient square-root algorithm for BLAST, Proc. IEEE ICASSP 2000, pages 737-740, the square-root algorithm that finds the order and the nulling vectors without one matrix inverse per step
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag Z0RT80 Edit this page History Report an error Markdown