Skip to content

Instantly share code, notes, and snippets.

@kumanna
Created October 10, 2025 12:13
Show Gist options
  • Select an option

  • Save kumanna/1ddad70dc54f17fc2e3589aaad288e70 to your computer and use it in GitHub Desktop.

Select an option

Save kumanna/1ddad70dc54f17fc2e3589aaad288e70 to your computer and use it in GitHub Desktop.
import numpy as np
M = 8
N = 8
triplets = [
(1 - 0.3j, 0, 0),
(0.3 + 0.4j, 1, 1),
(0.7 - 0.6j, 2, 1),
]
X = np.sign(np.random.randn(M, N)) + 1j * np.sign(np.random.randn(M, N))
Y = np.zeros_like(X) * 0.0j
for i in triplets:
h_i, tau_i, nu_i = i
for k in range(M):
for l in range(N):
Y[k, l] += h_i * X[np.mod(k - tau_i, M), np.mod(l - nu_i, N)]
# The kernel for the above is:
# K = np.array([[0, 0],
# [0, 0.3 + 0.4j],
# [0, 0.7 - 0.6j]])
# Constructed automatically:
K = np.zeros_like(X) * 0.0j
for i in triplets:
h_i, tau_i, nu_i = i
K[tau_i, nu_i] = h_i
# Zero-forcing equalization
X_hat = np.fft.ifft2(np.fft.fft2(Y) / np.fft.fft2(K))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment