added X representaton

This commit is contained in:
Didictateur 2023-10-29 23:48:31 +01:00
parent 8afb859dd0
commit 580548efff
2 changed files with 20 additions and 15 deletions

View file

@ -23,8 +23,8 @@ class Circuit:
def __line(self, A, B) -> None:
plt.plot([A[0], B[0]], [A[1], B[1]], color='Black')
def __circle(self, x: float, y: float, radius: float) -> None:
circ = Circle((x, y), radius, fill=True, color='Black')
def __circle(self, x: float, y: float, radius: float, fill=True) -> None:
circ = Circle((x, y), radius, fill=fill, color='Black')
plt.gca().add_patch(circ)
def draw(self) -> None:
@ -40,6 +40,11 @@ class Circuit:
self.__line((i+1.25, q_i), (i+1.5, q_i))
if q_i == index:
if txt == "X":
self.__circle(i+1, q_i, 0.25, False)
self.__line((i+0.75, q_i), (i+1.25, q_i))
self.__line((i+1, q_i-0.25), (i+1, q_i+0.25))
else:
self.__rect(i+1, q_i, txt, n)
for neig in neigbhor:
self.__circle(i+1, neig, 0.05)

View file

@ -441,7 +441,7 @@ def CX(q: MuBit, n1: int, n2: int) -> None:
q._MuBit__mapply(Matrix.CX(), n-2)
SWAP(q, n-2, n1)
SWAP(q, n-1, n2)
q._MuBit__emit("CX", n1, [n2])
q._MuBit__emit("X", n1, [n2])
def CY(q: MuBit, n1: int, n2: int) -> None:
if type(q) is not MuBit:
@ -463,7 +463,7 @@ def CY(q: MuBit, n1: int, n2: int) -> None:
q._MuBit__mapply(Matrix.CY(), n-2)
SWAP(q, n-2, n1)
SWAP(q, n-1, n2)
q._MuBit__emit("CY", n1, [n2])
q._MuBit__emit("Y", n1, [n2])
def CZ(q: MuBit, n1: int, n2: int) -> None:
if type(q) is not MuBit:
@ -485,7 +485,7 @@ def CZ(q: MuBit, n1: int, n2: int) -> None:
q._MuBit__mapply(Matrix.CZ(), n-2)
SWAP(q, n-2, n1)
SWAP(q, n-1, n2)
q._MuBit__emit("CZ", n1, [n2])
q._MuBit__emit("Z", n1, [n2])
def SWAP(q: MuBit, n1: int, n2: int) -> None:
if type(q) is not MuBit:
@ -542,4 +542,4 @@ def Cu(q: MuBit, u: list[list[complex]], n1: int, n2: int) -> None:
q._MuBit__mapply(Matrix.Cu(u), n-2)
SWAP(q, n-2, n1)
SWAP(q, n-1, n2)
q._MuBit__emit("Cu", n1, [n2])
q._MuBit__emit("U", n1, [n2])