def test_systematic_decoder(): ntests = 1000 n = 16 k = 8 frozenbitposition = np.array((0, 1, 2, 3, 4, 5, 8, 9), dtype=int) encoder = PolarEncoder(n, k, frozenbitposition) decoder = PolarDecoder(n, k, frozenbitposition) for i in range(ntests): bits = np.random.randint(2, size=k) y = encoder.encode_systematic(bits) u_hat = decoder.decode_systematic(y) assert (bits == u_hat).all()
def test_systematic_decoder(): ntests = 1000 n = 16 k = 8 frozenbitposition = np.array((0, 1, 2, 3, 4, 5, 8, 9), dtype=int) encoder = PolarEncoder(n, k, frozenbitposition) decoder = PolarDecoder(n, k, frozenbitposition) for i in range(ntests): bits = np.random.randint(2, size=k) y = encoder.encode_systematic(bits) u_hat = decoder.decode_systematic(y) assert (bits == u_hat).all()
def systematic_encoder_decoder_chain_test(): print('systematic encoder decoder chain test') block_size = int(2 ** 8) info_bit_size = block_size // 2 ntests = 100 frozenbitposition = cc.get_frozen_bit_indices_from_z_parameters(cc.bhattacharyya_bounds(0.0, block_size), block_size - info_bit_size) encoder = PolarEncoder(block_size, info_bit_size, frozenbitposition) decoder = PolarDecoder(block_size, info_bit_size, frozenbitposition) for i in range(ntests): bits = np.random.randint(2, size=info_bit_size) y = encoder.encode_systematic(bits) u_hat = decoder.decode_systematic(y) assert (bits == u_hat).all()
def systematic_encoder_decoder_chain_test(): print('systematic encoder decoder chain test') block_size = int(2**8) info_bit_size = block_size // 2 ntests = 100 frozenbitposition = cc.get_frozen_bit_indices_from_z_parameters( cc.bhattacharyya_bounds(0.0, block_size), block_size - info_bit_size) encoder = PolarEncoder(block_size, info_bit_size, frozenbitposition) decoder = PolarDecoder(block_size, info_bit_size, frozenbitposition) for i in range(ntests): bits = np.random.randint(2, size=info_bit_size) y = encoder.encode_systematic(bits) u_hat = decoder.decode_systematic(y) assert (bits == u_hat).all()