ba-thesis/sw/main.py

37 lines
779 B
Python

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from decoders import proximal
from decoders import utility
def main():
# Hamming(7,4) code
G = np.array([[1, 1, 1, 0, 0, 0, 0],
[1, 0, 0, 1, 1, 0, 0],
[0, 1, 0, 1, 0, 1, 0],
[1, 1, 0, 1, 0, 0, 1]])
H = np.array([[1, 0, 1, 0, 1, 0, 1],
[0, 1, 1, 0, 0, 1, 1],
[0, 0, 0, 1, 1, 1, 1]])
# Test decoder
d = np.array([0, 1, 0, 1])
c = np.dot(G.transpose(), d) % 2
print(f"Simulating with c = {c}")
decoder = proximal.ProximalDecoder(H, K=1000)
SNRs, BERs = utility.test_decoder(decoder, c, N=100)
plt.stem(SNRs, BERs)
plt.show()
if __name__ == "__main__":
main()