def test_butterfly_4pt_neg1f(self): d_real = np.array([1, 0, -1, 0], dtype=np.int32) d_imag = np.array([0, -1, 0, 1], dtype=np.int32) fpt = FixedPointType(8, 7) out_real, out_imag = fp_fft.butterfly_r2(d_real, d_imag, 1, 2, fpt, fpt, fpt, False) np.testing.assert_equal(out_real, np.array([0, 0, 2, 0], dtype=np.int32)) np.testing.assert_equal(out_imag, np.array([0, 0, 0, -2], dtype=np.int32)) out_real, out_imag = fp_fft.butterfly_r2(out_real, out_imag, 2, 2, fpt, fpt, fpt, False) np.testing.assert_equal(out_real, np.array([0, 0, 0, 4], dtype=np.int32)) np.testing.assert_equal(out_imag, np.array([0, 0, 0, 0], dtype=np.int32))
def test_butterfly_shift(self): d_real = np.array([1, 1, 1, 1], dtype=np.int32) d_imag = np.array([0, 0, 0, 0], dtype=np.int32) fpt = FixedPointType(8, 7) out_real, out_imag = fp_fft.butterfly_r2(d_real, d_imag, 1, 2, fpt, fpt, fpt, True) np.testing.assert_equal(out_real, np.array([1, 1, 0, 0], dtype=np.int32)) np.testing.assert_equal(out_imag, np.array([0, 0, 0, 0], dtype=np.int32)) out_real, out_imag = fp_fft.butterfly_r2(out_real, out_imag, 2, 2, fpt, fpt, fpt, True) np.testing.assert_equal(out_real, np.array([1, 0, 0, 0], dtype=np.int32)) np.testing.assert_equal(out_imag, np.array([0, 0, 0, 0], dtype=np.int32))
def test_butterfly_4pt_18_17(self): d_real = np.array([1, 1, 1, 1], dtype=np.int32) d_imag = np.array([0, 0, 0, 0], dtype=np.int32) fpt = FixedPointType(18, 17) out_real, out_imag = fp_fft.butterfly_r2(d_real, d_imag, 1, 2, fpt, fpt, fpt, False) np.testing.assert_equal(out_real, np.array([2, 2, 0, 0], dtype=np.int32)) np.testing.assert_equal(out_imag, np.array([0, 0, 0, 0], dtype=np.int32))