コード例 #1
0
ファイル: qa_constellation.py プロジェクト: klchiu/gnuradio
    def test_soft_qam16_calc(self):
        prec = 8
        constel, code = digital.qam_16_0()

        rot_sym = 1
        side = 2
        width = 2
        c = digital.constellation_rect(constel, code, rot_sym,
                                       side, side, width, width)

        # Get max energy/symbol in constellation
        constel = c.points()
        Es = max([abs(constel_i) for constel_i in constel])

        table = digital.soft_dec_table(constel, code, prec)
        c.gen_soft_dec_lut(prec)

        x = sqrt(2.0) / 2.0
        step = (x.real + x.real) / (2**prec - 1)
        samples = [-x - x * 1j,
                   -x + x * 1j,
                   x + x * 1j,
                   x - x * 1j,
                   (-x + 128 * step) + (-x + 128 * step) * 1j,
                   (-x + 64 * step) + (-x + 64 * step) * 1j,
                   (-x + 64 * step) + (-x + 192 * step) * 1j,
                   (-x + 192 * step) + (-x + 192 * step) * 1j,
                   (-x + 192 * step) + (-x + 64 * step) * 1j,
                   ]

        y_python_raw_calc = []
        y_python_table = []
        y_cpp_raw_calc = []
        y_cpp_table = []
        for sample in samples:
            y_python_raw_calc += slicer(
                digital.calc_soft_dec(
                    sample, constel, code))
            y_python_table += slicer(
                digital.calc_soft_dec_from_table(
                    sample, table, prec, Es))

            y_cpp_raw_calc += slicer(c.calc_soft_dec(sample))
            y_cpp_table += slicer(c.soft_decision_maker(sample))

        self.assertFloatTuplesAlmostEqual(y_python_raw_calc, y_python_table, 0)
        self.assertFloatTuplesAlmostEqual(y_cpp_raw_calc, y_cpp_table, 0)
コード例 #2
0
ファイル: qa_constellation.py プロジェクト: 232675/gnuradio
    def test_soft_qpsk_calc(self):
        prec = 8
        constel, code = digital.psk_4_0()

        rot_sym = 1
        side = 2
        width = 2
        c = digital.constellation_rect(constel, code, rot_sym,
                                       side, side, width, width)

        # Get max energy/symbol in constellation
        constel = c.points()
        Es = max([abs(constel_i) for constel_i in constel])

        table = digital.soft_dec_table(constel, code, prec)
        c.gen_soft_dec_lut(prec)

        x = sqrt(2.0)/2.0
        step = (x.real+x.real) / (2**prec - 1)
        samples = [ -x-x*1j, -x+x*1j,
                     x+x*1j,  x-x*1j,
                   (-x+128*step)+(-x+128*step)*1j,
                   (-x+64*step) +(-x+64*step)*1j,  (-x+64*step) +(-x+192*step)*1j,
                   (-x+192*step)+(-x+192*step)*1j, (-x+192*step)+(-x+64*step)*1j,]

        y_python_raw_calc = []
        y_python_table = []
        y_cpp_raw_calc = []
        y_cpp_table = []
        for sample in samples:
            y_python_raw_calc += digital.calc_soft_dec(sample, constel, code)
            y_python_table += digital.calc_soft_dec_from_table(sample, table, prec, Es)

            y_cpp_raw_calc += c.calc_soft_dec(sample)
            y_cpp_table += c.soft_decision_maker(sample)

        self.assertFloatTuplesAlmostEqual(y_python_raw_calc, y_python_table, 4)
        self.assertFloatTuplesAlmostEqual(y_cpp_raw_calc, y_cpp_table, 4)