-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add nrRateMatchPolar(), until now only repetition is supported and ibil has to be disabled * bump version to 0.4.0
- Loading branch information
Showing
4 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import numpy as np | ||
|
||
def subblock_interleaving(u): | ||
N = u.shape[-1] | ||
assert np.mod(N,32)==0, \ | ||
"length for sub-block interleaving must be a multiple of 32." | ||
y = np.zeros_like(u) | ||
# Permutation according to Tab 5.4.1.1-1 in 38.212 | ||
perm = np.array([0, 1, 2, 4, 3, 5, 6, 7, 8, 16, 9, 17, 10, 18, 11, 19, | ||
12, 20, 13, 21, 14, 22, 15, 23, 24, 25, 26, 28, 27, | ||
29, 30, 31]) | ||
|
||
for n in range(N): | ||
i = int(32*n/N) | ||
j = int(perm[i] * N/32 + np.mod(n, N/32)) | ||
y[n] = u[j] | ||
|
||
return y | ||
|
||
def nrRateMatchPolar(enc, K, E, ibil=False): | ||
# TODO: for what is the parameter K?? | ||
N = enc.shape[0] | ||
d = np.zeros(N, int) | ||
d = enc[subblock_interleaving(np.arange(N))] | ||
y = np.zeros(E, int) | ||
if N <= E: | ||
# repetition | ||
y[:N] = d[:N] | ||
for k in range(N, E): | ||
y[k] += d[k%N] | ||
else: | ||
# TODO: implement shortening und puncturing | ||
print("Error!") | ||
exit() | ||
if ibil == True: | ||
print("Error: interleaving of coded bits is not implemented!") | ||
exit() | ||
return y | ||
|
||
if __name__ == '__main__': | ||
import py3gpp | ||
# input = np.zeros(512, int) | ||
# input[0:3] = [1 , 1, 1] | ||
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,1,1,1,0,0,0,1,1,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,0,1,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,1,0,0,0,1,0,0,0,1,1,0,0,0,1,0,1,0,0,1,1,1,1,0,0,1,0,1,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,1,1,0,1,1,1,0,1,1,0,1,0,0,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,1,0,1,0,1,1,0,1,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,0,1,0,0,0,1,1,0,1,0,1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,1,1,1,0]).astype(int) | ||
out = nrRateMatchPolar(input, 0, 863, False) | ||
assert np.array_equal(out, out_desired) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta" | |
py3gpp = ["codes/*.csv"] | ||
|
||
[project] | ||
version = "0.3.6" | ||
version = "0.4.0" | ||
authors = [ | ||
{name = "Benjamin Menküc", email = "[email protected]"}, | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import numpy as np | ||
from py3gpp.nrRateMatchPolar import nrRateMatchPolar | ||
|
||
def test_nrRateMatchPolar(): | ||
input = np.array([1,1,0,0,0,0,1,1,0,0,1,1,1,0,1,0,0,1,1,1,0,1,0,1,1,1,0,0,1,1,1,1,0,1,0,1,1,1,1,1,1,0,1,1,1,0,0,0,1,1,0,1,1,0,0,0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