From af11de0c6adc10b9281714aa8d88133e0bdd3430 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Mon, 23 Oct 2023 10:08:00 +0200 Subject: [PATCH] update MuBit.md --- QElephant/QuBit.py | 4 ++-- docs/QuBit/MuBit.md | 57 +++++++++++++++++++++++++++++++++++++++++++++ docs/QuBit/QuBit.md | 2 +- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/QElephant/QuBit.py b/QElephant/QuBit.py index 8098a0b..0e4748a 100644 --- a/QElephant/QuBit.py +++ b/QElephant/QuBit.py @@ -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()) diff --git a/docs/QuBit/MuBit.md b/docs/QuBit/MuBit.md index e69de29..22f15fd 100644 --- a/docs/QuBit/MuBit.md +++ b/docs/QuBit/MuBit.md @@ -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. \ No newline at end of file diff --git a/docs/QuBit/QuBit.md b/docs/QuBit/QuBit.md index 69439c7..f972fae 100644 --- a/docs/QuBit/QuBit.md +++ b/docs/QuBit/QuBit.md @@ -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.