ldpc.codes

ldpc.codes.hamming_code(rank)

Outputs a Hamming code parity check matrix given its rank.

Parameters

rank (int) – The rank of of the Hamming code parity check matrix.

Returns

The Hamming code parity check matrix in numpy.ndarray format.

Return type

numpy.ndarray

Example

>>> print(hamming_code(3))
[[0 0 0 1 1 1 1]
 [0 1 1 0 0 1 1]
 [1 0 1 0 1 0 1]]
ldpc.codes.rep_code(distance)

Outputs repetition code parity check matrix for specified distance.

Parameters

distance (int) – The distance of the repetition code.

Returns

The repetition code parity check matrix in numpy.ndarray format.

Return type

numpy.ndarray

Examples

>>> print(rep_code(5))
[[1 1 0 0 0]
 [0 1 1 0 0]
 [0 0 1 1 0]
 [0 0 0 1 1]]
ldpc.codes.ring_code(distance)

Outputs ring code (closed-loop repetion code) parity check matrix for a specified distance.

Parameters

distance (int) – The distance of the repetition code.

Returns

The repetition code parity check matrix in numpy.ndarray format.

Return type

numpy.ndarray

Examples

>>> print(ring_code(5))
[[1 1 0 0 0]
 [0 1 1 0 0]
 [0 0 1 1 0]
 [0 0 0 1 1]
 [1 0 0 0 1]]