diff --git a/QElephant/QuBit.py b/QElephant/QuBit.py index 9bea0e6..6c99213 100644 --- a/QElephant/QuBit.py +++ b/QElephant/QuBit.py @@ -174,6 +174,10 @@ class MuBit: state //= 2 return l + def reset(self) -> None: + self.state = [0]*self.__n + self.state[0] = 1 + @staticmethod def intricateThem(*args: "QuBit") -> "MuBit": for q in args: @@ -226,6 +230,9 @@ class QuBit: return 0 self.__state = [0, 1] return 1 + + def reset(self) -> None: + self.__state = [1, 0] class IQuBit(QuBit): def __init__(self, n: int, mb: MuBit) -> None: @@ -265,6 +272,9 @@ class IQuBit(QuBit): return 0 self.__muBit._MuBit__set(self.__n, 1) return 1 + + def reset(self) -> None: + self.__muBit._MuBit__set(self.__n, 0) diff --git a/docs/QuBit/IQuBit.md b/docs/QuBit/IQuBit.md index 41304db..c45bd4b 100644 --- a/docs/QuBit/IQuBit.md +++ b/docs/QuBit/IQuBit.md @@ -46,3 +46,7 @@ IQuBit(QuBit) - ```observe() -> list[int]``` forces the QuBit in a state, where the probabilities are given throught __state. Returns the new __state obtained. + +- ```reset() -> None``` + + fixes the QuBit in the state |0>. This is irrevesible. \ No newline at end of file diff --git a/docs/QuBit/MuBit.md b/docs/QuBit/MuBit.md index 774f4fa..cd03148 100644 --- a/docs/QuBit/MuBit.md +++ b/docs/QuBit/MuBit.md @@ -60,6 +60,10 @@ MuBit(n: int) forces the QuBits in a state, where the probabilities are given throught __state. Returns the list of the state of each QuBit. +- ```reset() -> None``` + + fixes the QuBit in the state |0...0>. This is irrevesible. + ### Staticmethods - ```intricateThem(*args: QuBit) -> MuBit``` diff --git a/docs/QuBit/QuBit.md b/docs/QuBit/QuBit.md index f972fae..21664f9 100644 --- a/docs/QuBit/QuBit.md +++ b/docs/QuBit/QuBit.md @@ -40,3 +40,7 @@ QuBit(alpha: complexe, beta: complexe) - ```observe() -> list[int]``` forces the QuBit in a state, where the probabilities are given throught __state. Returns the state obtained. + +- ```reset() -> None``` + + fixes the QuBit in the state |0>. This is irrevesible. \ No newline at end of file