mindquantum.utils.ket_string
- mindquantum.utils.ket_string(state, tol=1e-07)[source]
Get the ket format of the quantum state.
- Parameters
state (numpy.ndarray) – The input quantum state.
tol (float) – The ignore tolerance for small amplitude. Default:
1e-7
.
- Returns
str, the ket format of the quantum state.
Examples
>>> import numpy as np >>> from mindquantum.utils import ket_string >>> state = np.array([1, -1j])/np.sqrt(2) >>> print(ket_string(state)) ['√2/2¦0⟩', '-√2/2j¦1⟩']