comnum.Interleaver#
- class comnum.Interleaver#
A permutation of the positions of a block:
Interleaver.random(n, seed=…),Interleaver.block(rows, cols)orInterleaver.qpp(k, f1, f2). It permutes any array and keeps its dtype (bits, LLRs, symbols).Examples
>>> import comnum, numpy as np >>> il = comnum.Interleaver.block(2, 3) >>> il.interleave(np.arange(6)).tolist() [0, 3, 1, 4, 2, 5] >>> il.deinterleave(il.interleave(np.arange(6))).tolist() [0, 1, 2, 3, 4, 5]
- static block(rows, cols)#
Write row by row, read column by column.
- Parameters:
- Returns:
the interleaver of
rows · colspositions.- Return type:
- static qpp(k, f1, f2)#
The quadratic permutation polynomial
(f1 i + f2 i²) mod k.- Parameters:
- Returns:
the interleaver.
- Return type:
- Raises:
ValueError – if the polynomial is not a permutation.
- static random(n, *, seed=0)#
A uniform random permutation.
- Parameters:
- Returns:
the interleaver.
- Return type:
- Raises:
ValueError – for a negative count.
Examples
>>> import comnum >>> il = comnum.Interleaver.random(8, seed=1) >>> sorted(il.perm.tolist()) == list(range(8)) True
- deinterleave(y)#
The inverse permutation:
x[perm[i]] = y[i].- Parameters:
y (array_like) – one interleaved block of any dtype.
- Returns:
the block in its original order, of the dtype of
y.- Return type:
- Raises:
ValueError – for an input that is not an array of numbers of the expected shape.
- interleave(x)#
Interleave a block:
y[i] = x[perm[i]].- Parameters:
x (array_like) – one block of any dtype (bits, LLRs, symbols).
- Returns:
the permuted block, of the dtype of
x.- Return type:
- Raises:
ValueError – for an input that is not an array of numbers of the expected shape.
- perm#
output
iis inputperm[i].- Type:
- Type:
The permutation (int64)