def test_simple_unitary_from_angles5(self): # fourier transform of sine phiset = [-np.pi / 4, 0, 0, 0, np.pi / 4] ualg = LPoly.LAlg.unitary_from_angles(phiset) print(f"For phiset={phiset}, U={ualg}") print(f"diagonal poly = {ualg.IPoly}") assert ualg.IPoly == LPoly.LPoly([0.5, 0, 0, 0, 0.5], -4)
def test_LPoly_mul1(self): ''' Test product of two LPoly's ''' lp1 = LPoly.LPoly([1 / 2, 1 / 2], -1) lp2 = lp1 * lp1 print(f"lp1={lp1}") print(f"lp1 * lp1 = {lp2}") print(f"lp2 coefs={lp2.coefs}") assert lp2.dmin == -2 assert abs(lp2.coefs - np.array([0.25, 0.5, 0.25])).sum() < 1.0e-4
def test_lpoly1(self): # Exp[-i (pi/2) X] * w = w^(-1) * iX w = LPoly.w Q0 = LPoly.LAlg.rotation(np.pi / 2) Q0.IPoly.round_zeros() prod = Q0 * w print(f"w = {w}") print(f"~w = {~w}") print(f"Q0 = {Q0}") print(f"Q0 * w = {prod}") print(f"poly([1,0], -1) = {LPoly.LPoly([1], -1)}") print(f"prod.XPoly coefs={prod.XPoly.coefs}, dmin={prod.XPoly.dmin}") assert prod.XPoly == LPoly.LPoly([1], -1)
def test_simple_unitary_from_angles3(self): phiset = [0, 0, 0] # w^2 ualg = LPoly.LAlg.unitary_from_angles(phiset) print(f"For phiset={phiset}, U={ualg}") print(f"diagonal poly = {ualg.IPoly}") assert ualg.IPoly == LPoly.LPoly([0, 0, 1], -2)
def test_simple_unitary_from_angles1(self): phiset = [0] # identity ualg = LPoly.LAlg.unitary_from_angles(phiset) print(f"For phiset={phiset}, U={ualg}") print(f"diagonal poly = {ualg.IPoly}") assert ualg.IPoly == LPoly.LPoly([1])