Skip to content

qubit

Qubit

Qubit

Bases: BosonicQubit

FockQubit

Source code in jaxquantum/codes/qubit.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class Qubit(BosonicQubit):
    """
    FockQubit
    """

    def _params_validation(self):
        super()._params_validation()
        self.params["N"] = 2

    def _get_basis_z(self) -> Tuple[jqt.Qarray, jqt.Qarray]:
        """
        Construct basis states |+-x>, |+-y>, |+-z>
        """
        N = int(self.params["N"])
        plus_z = jqt.basis(N, 0)
        minus_z = jqt.basis(N, 1)
        return plus_z, minus_z

    @property
    def x_U(self) -> jqt.Qarray:
        return jqt.sigmax()

    @property
    def y_U(self) -> jqt.Qarray:
        return jqt.sigmay()

    @property
    def z_U(self) -> jqt.Qarray:
        return jqt.sigmaz()

    def plot(self, state, ax=None, qp_type="", **kwargs) -> None:
        state = self.jqt2qt(state)
        with warnings.catch_warnings():
            # TODO: suppressing deprecation warnings, deal with this
            warnings.simplefilter("ignore")
            b = qt.Bloch()
            b.add_states(state)
            b.render()
            b.show()
            plt.tight_layout()
            plt.show()