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
|
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:
|
||||||
|
|
@ -226,6 +230,9 @@ class QuBit:
|
||||||
return 0
|
return 0
|
||||||
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:
|
||||||
|
|
@ -265,6 +272,9 @@ class IQuBit(QuBit):
|
||||||
return 0
|
return 0
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
@ -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```
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
Loading…
Reference in a new issue