From 00f966ef88e7eec5a5b60c9c3bbd2902e61ff64f Mon Sep 17 00:00:00 2001 From: Didictateur Date: Thu, 26 Oct 2023 16:18:43 +0200 Subject: [PATCH] more tests --- Gate_test.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Gate_test.py b/Gate_test.py index de1d4f8..0755979 100644 --- a/Gate_test.py +++ b/Gate_test.py @@ -1,6 +1,6 @@ from QElephant.QuBit import * -## for IQuBit +## MuBit mq = MuBit(2) q = mq[1] @@ -9,4 +9,22 @@ assert mq._MuBit__state == [0, 1, 0, 0] H(q) assert mq._MuBit__state == [1/math.sqrt(2), -1/math.sqrt(2), 0, 0] CX(mq, 0, 1) -assert mq._MuBit__state == [1/math.sqrt(2), -1/math.sqrt(2), 0, 0] \ No newline at end of file +assert mq._MuBit__state == [1/math.sqrt(2), -1/math.sqrt(2), 0, 0] + +## QuBit +q = QuBit() + +X(q) +assert q._QuBit__state == [0, 1] +H(q) +assert q._QuBit__state == [1/math.sqrt(2), -1/math.sqrt(2)] +SQRTX(q) +assert q._QuBit__state == [complex(0, 1/math.sqrt(2)), -complex(0, 1/math.sqrt(2))] +Y(q) +assert q._QuBit__state == [-1/math.sqrt(2), -1/math.sqrt(2)] +Z(q) +assert q._QuBit__state == [-1/math.sqrt(2), 1/math.sqrt(2)] +S(q) +assert q._QuBit__state == [-1/math.sqrt(2), complex(0, 1/math.sqrt(2))] +T(q) +assert q._QuBit__state == [-1/math.sqrt(2), complex(0, 1/math.sqrt(2))*math.e**(complex(0, math.pi/4))]