update MuBit.md
This commit is contained in:
parent
0afb1ad21b
commit
af11de0c6a
3 changed files with 60 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ I = complex(0, 1)
|
|||
## Classes
|
||||
|
||||
class MuBit:
|
||||
def __init__(self, n: int) -> None:
|
||||
def __init__(self, n: int=2) -> None:
|
||||
self.__n = n
|
||||
self.__state: list[complex] = [0]*(2**self.__n)
|
||||
self.__state[0] = 1
|
||||
|
|
@ -88,7 +88,7 @@ class MuBit:
|
|||
l = M._Matrix__apply(self.__state)
|
||||
return sum([abs(x)**2 for x in l])
|
||||
|
||||
def observe(self) -> list[0]:
|
||||
def observe(self) -> list[int]:
|
||||
l = []
|
||||
for i in range(self.__n):
|
||||
l.append(IQuBit(i, self).observe())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
## MuBit
|
||||
|
||||
MuBit(n: int)
|
||||
|
||||
- n: number of intricated QuBits
|
||||
|
||||
### Attributes
|
||||
|
||||
- ```__n: int```
|
||||
|
||||
the number of intricated QuBits represented by this MuBit
|
||||
|
||||
- ```__state: list[complexe]```
|
||||
|
||||
list of the values for the state |0...0>, |0...01>, |0...010>, |0...011> etc...
|
||||
|
||||
### Methode
|
||||
|
||||
- ```__init__(n: int=2) -> None```
|
||||
|
||||
initiates the mubit with n QuBits.
|
||||
|
||||
- ```get_size() -> int```
|
||||
|
||||
return __n
|
||||
|
||||
- ```__str__() -> str```
|
||||
|
||||
returns a string representation of the list of __state. Each state is named and draw in a new line.
|
||||
|
||||
- ```__set(i: int, value: int)```
|
||||
|
||||
force the i-th QuBit of the MuBit to take the state value. Value must be 0 or 1.
|
||||
|
||||
- ```__iter__() -> Iterator[IQuBit]```
|
||||
|
||||
creates an interator of __state.
|
||||
|
||||
- ```__getitem__(item: int) -> IQubIt```
|
||||
|
||||
creates an intricated QuBit corresponding to the item-th QuBit.
|
||||
|
||||
- ```__apply(m: Matrix) -> None```
|
||||
|
||||
takes a Matrix and modifies the QuBits according the matrix.
|
||||
|
||||
- ```__mapply(m: Matrix, i: int) -> None```
|
||||
|
||||
takes a Matrix and modifies the i-th QuBit according the matrix.
|
||||
|
||||
- ```__getProbs(i: int) -> float```
|
||||
|
||||
returns the probability to get the i-th QuBit in the state |0>.
|
||||
|
||||
- ```observe() -> list[int]```
|
||||
|
||||
forces the QuBits in a state, where the probabilities are given throught __state. Returns the list of the state of each QuBit.
|
||||
|
|
@ -39,4 +39,4 @@ QuBit(alpha: complexe, beta: complexe)
|
|||
|
||||
- ```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 state obtained.
|
||||
|
|
|
|||
Loading…
Reference in a new issue