added reset
This commit is contained in:
parent
a3cb9de05b
commit
824acfda7a
4 changed files with 22 additions and 0 deletions
|
|
@ -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:
|
||||
|
|
@ -227,6 +231,9 @@ class QuBit:
|
|||
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:
|
||||
if type(n) is not int:
|
||||
|
|
@ -266,6 +273,9 @@ class IQuBit(QuBit):
|
|||
self.__muBit._MuBit__set(self.__n, 1)
|
||||
return 1
|
||||
|
||||
def reset(self) -> None:
|
||||
self.__muBit._MuBit__set(self.__n, 0)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -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```
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
Loading…
Reference in a new issue