added reset

This commit is contained in:
Didictateur 2023-10-24 17:20:38 +02:00
parent a3cb9de05b
commit 824acfda7a
4 changed files with 22 additions and 0 deletions

View file

@ -174,6 +174,10 @@ class MuBit:
state //= 2 state //= 2
return l return l
def reset(self) -> None:
self.state = [0]*self.__n
self.state[0] = 1
@staticmethod @staticmethod
def intricateThem(*args: "QuBit") -> "MuBit": def intricateThem(*args: "QuBit") -> "MuBit":
for q in args: for q in args:
@ -227,6 +231,9 @@ class QuBit:
self.__state = [0, 1] self.__state = [0, 1]
return 1 return 1
def reset(self) -> None:
self.__state = [1, 0]
class IQuBit(QuBit): class IQuBit(QuBit):
def __init__(self, n: int, mb: MuBit) -> None: def __init__(self, n: int, mb: MuBit) -> None:
if type(n) is not int: if type(n) is not int:
@ -266,6 +273,9 @@ class IQuBit(QuBit):
self.__muBit._MuBit__set(self.__n, 1) self.__muBit._MuBit__set(self.__n, 1)
return 1 return 1
def reset(self) -> None:
self.__muBit._MuBit__set(self.__n, 0)

View file

@ -46,3 +46,7 @@ IQuBit(QuBit)
- ```observe() -> list[int]``` - ```observe() -> list[int]```
forces the QuBit in a state, where the probabilities are given throught __state. Returns the new __state obtained. 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.

View file

@ -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. 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 ### Staticmethods
- ```intricateThem(*args: QuBit) -> MuBit``` - ```intricateThem(*args: QuBit) -> MuBit```

View file

@ -40,3 +40,7 @@ QuBit(alpha: complexe, beta: complexe)
- ```observe() -> list[int]``` - ```observe() -> list[int]```
forces the QuBit in a state, where the probabilities are given throught __state. Returns the state obtained. 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.