import numpy as np

from common import circuit_matrix, equivalent, fmt, global_phase, X, Y, Z

# Le circuit « H, X, H » et la porte Z ont la même matrice
print("H, X, H égale Z :", np.allclose(circuit_matrix(["H", "X", "H"]), Z))
print("H, Z, H égale X :", np.allclose(circuit_matrix(["H", "Z", "H"]), X))

# Pour Y, il reste une phase globale
hyh = circuit_matrix(["H", "Y", "H"])
print("H, Y, H égale Y :", np.allclose(hyh, Y))
print("H, Y, H = c·Y avec c =", fmt(global_phase(hyh, Y)), "  équivalent à Y :", equivalent(hyh, Y))
