Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion commpy/modulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def __init__(self, m):
Parameters
----------
m : int
Size of the QAM constellation. Must lead to a square QAM (ie sqrt(m) is an integer).
Size of the QAM constellation. Must be a power of 2 and lead to a square QAM (ie log2(m) and sqrt(m) are integers).

Raises
------
Expand All @@ -256,6 +256,10 @@ def __init__(self, m):
num_symb_pam = sqrt(m)
if num_symb_pam != int(num_symb_pam):
raise ValueError('m must lead to a square QAM.')

num_bits_symbol = log2(m)
if num_bits_symbol != int(num_bits_symbol):
raise ValueError('Constellation length must be a power of 2.')

pam = arange(-num_symb_pam + 1, num_symb_pam, 2)
constellation = tile(hstack((pam, pam[::-1])), int(num_symb_pam) // 2) * 1j + pam.repeat(num_symb_pam)
Expand Down