def generate_test_data(self, block_size, num_info_bits, frozen_bit_positions, nframes, onlyones):
     frozen_bit_values = np.zeros(block_size - num_info_bits, dtype=int)
     encoder = PolarEncoder(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values)
     bits = np.array([], dtype=int)
     data = np.array([], dtype=int)
     for n in range(nframes):
         if onlyones:
             b = np.ones(num_info_bits, dtype=int)
         else:
             b = np.random.randint(2, size=num_info_bits)
         d = encoder.encode_systematic(b)
         bits = np.append(bits, b)
         data = np.append(data, d)
     gr_data = 2.0 * data - 1.0
     return bits, gr_data
    def get_test_data(self, block_size, num_info_bits, num_blocks):
        # helper function to set up test data and together with encoder object.
        num_frozen_bits = block_size - num_info_bits
        frozen_bit_positions = cc.frozen_bit_positions(block_size, num_info_bits, 0.0)
        frozen_bit_values = np.array([0] * num_frozen_bits,)
        python_encoder = PolarEncoder(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values)

        data = np.array([], dtype=int)
        ref = np.array([], dtype=int)
        for i in range(num_blocks):
            d = np.random.randint(2, size=num_info_bits)
            data = np.append(data, d)
            ref = np.append(ref, python_encoder.encode_systematic(d))
        polar_encoder = fec.polar_encoder_systematic.make(block_size, num_info_bits, frozen_bit_positions)
        return data, ref, polar_encoder
 def generate_test_data(self, block_size, num_info_bits, frozen_bit_positions, nframes, onlyones):
     frozen_bit_values = np.zeros(block_size - num_info_bits, dtype=int)
     encoder = PolarEncoder(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values)
     bits = np.array([], dtype=int)
     data = np.array([], dtype=int)
     for n in range(nframes):
         if onlyones:
             b = np.ones(num_info_bits, dtype=int)
         else:
             b = np.random.randint(2, size=num_info_bits)
         d = encoder.encode_systematic(b)
         bits = np.append(bits, b)
         data = np.append(data, d)
     gr_data = 2.0 * data - 1.0
     return bits, gr_data
Beispiel #4
0
    def get_test_data(self, block_size, num_info_bits, num_blocks):
        # helper function to set up test data and together with encoder object.
        num_frozen_bits = block_size - num_info_bits
        frozen_bit_positions = cc.frozen_bit_positions(block_size, num_info_bits, 0.0)
        frozen_bit_values = np.array([0] * num_frozen_bits,)
        python_encoder = PolarEncoder(block_size, num_info_bits, frozen_bit_positions, frozen_bit_values)

        data = np.array([], dtype=int)
        ref = np.array([], dtype=int)
        for i in range(num_blocks):
            d = np.random.randint(2, size=num_info_bits)
            data = np.append(data, d)
            ref = np.append(ref, python_encoder.encode_systematic(d))
        polar_encoder = fec.polar_encoder_systematic.make(block_size, num_info_bits, frozen_bit_positions)
        return data, ref, polar_encoder