Skip to content

Commit a709f63

Browse files
committed
Added docstring.
1 parent faa9e3b commit a709f63

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

commpy/channelcoding/algcode.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Copyright 2012 Veeresh Taranalli <veeresht@gmail.com>
33
#
4-
# This file is part of CommPy.
4+
# This file is part of CommPy.
55
#
66
# CommPy is free software: you can redistribute it and/or modify
77
# it under the terms of the GNU General Public License as published by
@@ -25,7 +25,25 @@
2525
__all__ = ['cyclic_code_genpoly']
2626

2727
def cyclic_code_genpoly(n, k):
28-
28+
"""
29+
Generate all possible generator polynomials for a (n, k)-cyclic code.
30+
31+
Parameters
32+
----------
33+
n : int
34+
Code blocklength of the cyclic code.
35+
36+
k : int
37+
Information blocklength of the cyclic code.
38+
39+
Returns
40+
-------
41+
poly_list : 1D ndarray of ints
42+
A list of generator polynomials (represented as integers) for the (n, k)-cyclic code.
43+
44+
"""
45+
46+
2947
if n%2 == 0:
3048
raise ValueError, "n cannot be an even number"
3149

@@ -35,18 +53,18 @@ def cyclic_code_genpoly(n, k):
3553

3654
x_gf = GF(arange(1, 2**m), m)
3755
coset_fields = x_gf.cosets()
38-
56+
3957
coset_leaders = array([])
4058
minpol_degrees = array([])
4159
for field in coset_fields:
4260
coset_leaders = concatenate((coset_leaders, array([field.elements[0]])))
4361
minpol_degrees = concatenate((minpol_degrees, array([len(field.elements)])))
44-
62+
4563
y_gf = GF(coset_leaders, m)
4664
minpol_list = y_gf.minpolys()
4765
idx_list = arange(1, len(minpol_list))
4866
poly_list = array([])
49-
67+
5068
for i in xrange(1, 2**len(minpol_list)):
5169
i_array = dec2bitarray(i, len(minpol_list))
5270
subset_array = minpol_degrees[i_array == 1]
@@ -66,7 +84,3 @@ def cyclic_code_genpoly(n, k):
6684
genpolys = cyclic_code_genpoly(31, 21)
6785
for poly in genpolys:
6886
print poly_to_string(poly)
69-
70-
71-
72-

0 commit comments

Comments
 (0)