quairkit.database.state¶
The library of common quantum states.
-
quairkit.database.state.zero_state(num_systems, system_dim=
2
)¶ The function to generate a zero state.
num_systems = 2 system_dim=[2,3] state = zero_state(num_systems,system_dim) print(f'The zero state is:\n{state}')
The zero state is: --------------------------------------------------- Backend: state_vector System dimension: [2, 3] System sequence: [0, 1] [1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] ---------------------------------------------------
-
quairkit.database.state.one_state(num_systems, system_dim=
2
)¶ The function to generate a one state.
num_systems = 2 system_dim=[1,3] state = one_state(num_systems,system_dim) print(f'The one state is:\n{state}')
The one state is: --------------------------------------------------- Backend: state_vector System dimension: [1, 3] System sequence: [0, 1] [0.+0.j 1.+0.j 0.+0.j] ---------------------------------------------------
-
quairkit.database.state.computational_state(num_systems, index, system_dim=
2
)¶ Generate a computational state \(|e_{i}\rangle\) , whose i-th element is 1 and all the other elements are 0.
- Parameters:¶
- num_systems : int¶
number of systems in this state. Alias of
num_qubits
.- index : int¶
Index \(i\) of the computational basis state \(|e_{i}rangle\) .
- system_dim : List[int] | int¶
dimension of systems. Can be a list of system dimensions or an int representing the dimension of all systems. Defaults to be qubit case.
- Returns:¶
The generated quantum state.
- Return type:¶
State
num_systems = 2 system_dim=[2,3] index=4 state = computational_state(num_systems,index,system_dim) print(f'The state is:\n{state}')
The state is: --------------------------------------------------- Backend: state_vector System dimension: [2, 3] System sequence: [0, 1] [0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j] ---------------------------------------------------
-
quairkit.database.state.bell_state(num_systems, system_dim=
2
)¶ Generate a bell state.
Its matrix form is:
\[|\Phi_{D}\rangle=\frac{1}{\sqrt{D}} \sum_{j=0}^{D-1}|j\rangle_{A}|j\rangle_{B}\]num_systems = 2 system_dim=[2,2] state = bell_state(num_systems,system_dim) print(f'The Bell state is:\n{state}')
The Bell state is: --------------------------------------------------- Backend: state_vector System dimension: [2, 2] System sequence: [0, 1] [0.71+0.j 0. +0.j 0. +0.j 0.71+0.j] ---------------------------------------------------
- quairkit.database.state.bell_diagonal_state(prob)¶
Generate a bell diagonal state.
Its matrix form is:
\[p_{1}|\Phi^{+}\rangle\langle\Phi^{+}|+p_{2}| \Psi^{+}\rangle\langle\Psi^{+}|+p_{3}| \Phi^{-}\rangle\langle\Phi^{-}| + p_{4}|\Psi^{-}\rangle\langle\Psi^{-}|\]- Parameters:¶
- prob : List[float]¶
The prob of each bell state.
- Raises:¶
Exception – The state should be a pure state if the backend is state_vector.
NotImplementedError – If the backend is wrong or not implemented.
- Returns:¶
The generated quantum state.
- Return type:¶
State
prob=[0.2,0.3,0.4,0.1] state = bell_diagonal_state(prob) print(f'The Bell diagonal state is:\n{state}')
The Bell diagonal state is: --------------------------------------------------- Backend: density_matrix System dimension: [2, 2] System sequence: [0, 1] [[ 0.3+0.j 0. +0.j 0. +0.j -0.1+0.j] [ 0. +0.j 0.2+0.j 0.1+0.j 0. +0.j] [ 0. +0.j 0.1+0.j 0.2+0.j 0. +0.j] [-0.1+0.j 0. +0.j 0. +0.j 0.3+0.j]] ---------------------------------------------------
- quairkit.database.state.w_state(num_qubits)¶
Generate a W-state.
- Parameters:¶
- num_qubits : int¶
The number of qubits contained in the quantum state.
- Raises:¶
NotImplementedError – If the backend is wrong or not implemented.
- Returns:¶
The generated quantum state.
- Return type:¶
State
num_qubits = 2 W_state =w_state(num_qubits) print(f'The W-state is:\n{W_state}')
The W-state is: --------------------------------------------------- Backend: state_vector System dimension: [2, 2] System sequence: [0, 1] [0. +0.j 0.71+0.j 0.71+0.j 0. +0.j] ---------------------------------------------------
- quairkit.database.state.ghz_state(num_qubits)¶
Generate a GHZ-state.
- Parameters:¶
- num_qubits : int¶
The number of qubits contained izn the quantum state.
- Raises:¶
NotImplementedError – If the backend is wrong or not implemented.
- Returns:¶
The generated quantum state.
- Return type:¶
State
num_qubits = 2 GHZ_state =ghz_state(num_qubits) print(f'The GHZ-state is:\n{GHZ_state}')
The GHZ-state is: --------------------------------------------------- Backend: state_vector System dimension: [2, 2] System sequence: [0, 1] [0.71+0.j 0. +0.j 0. +0.j 0.71+0.j] ---------------------------------------------------
- quairkit.database.state.completely_mixed_computational(num_qubits)¶
Generate the density matrix of the completely mixed state.
- Parameters:¶
- num_qubits : int¶
The number of qubits contained in the quantum state.
- Raises:¶
Exception – The state should be a pure state if the backend is state_vector.
NotImplementedError – If the backend is wrong or not implemented.
- Returns:¶
The generated quantum state.
- Return type:¶
State
num_qubits = 1 state =completely_mixed_computational(num_qubits) print(f'The density matrix of the completely mixed state is:\n{state}')
The density matrix of the completely mixed state is: --------------------------------------------------- Backend: density_matrix System dimension: [2] System sequence: [0] [[0.5+0.j 0. +0.j] [0. +0.j 0.5+0.j]] ---------------------------------------------------
- quairkit.database.state.r_state(prob)¶
Generate an R-state.
Its matrix form is:
\[p|\Psi^{+}\rangle\langle\Psi^{+}| + (1 - p)|11\rangle\langle11|\]- Parameters:¶
- prob : float¶
The parameter of the R-state to be generated. It should be in \([0,1]\) .
- Raises:¶
Exception – The state should be a pure state if the backend is state_vector.
NotImplementedError – If the backend is wrong or not implemented.
- Returns:¶
The generated quantum state.
- Return type:¶
State
prob = 0.5 R_state =r_state(prob) print(f'The R-state is:\n{R_state}')
The R-state is: --------------------------------------------------- Backend: density_matrix System dimension: [2, 2] System sequence: [0, 1] [[0. +0.j 0. +0.j 0. +0.j 0. +0.j] [0. +0.j 0.25+0.j 0.25+0.j 0. +0.j] [0. +0.j 0.25+0.j 0.25+0.j 0. +0.j] [0. +0.j 0. +0.j 0. +0.j 0.5 +0.j]] ---------------------------------------------------
- quairkit.database.state.s_state(prob)¶
Generate the S-state.
Its matrix form is:
\[p|\Phi^{+}\rangle\langle\Phi^{+}| + (1 - p)|00\rangle\langle00|\]- Parameters:¶
- prob : float¶
The parameter of the S-state to be generated. It should be in \([0,1]\) .
- Raises:¶
Exception – The state should be a pure state if the backend is state_vector.
NotImplementedError – If the backend is wrong or not implemented.
- Returns:¶
The generated quantum state.
- Return type:¶
State
prob = 0.5 S_state =s_state(prob) print(f'The S-state is:\n{S_state}')
The S-state is: --------------------------------------------------- Backend: density_matrix System dimension: [2, 2] System sequence: [0, 1] [[0.75+0.j 0. +0.j 0. +0.j 0.25+0.j] [0. +0.j 0. +0.j 0. +0.j 0. +0.j] [0. +0.j 0. +0.j 0. +0.j 0. +0.j] [0.25+0.j 0. +0.j 0. +0.j 0.25+0.j]] ---------------------------------------------------
- quairkit.database.state.isotropic_state(num_qubits, prob)¶
Generate the isotropic state.
Its matrix form is:
\[p(\frac{1}{\sqrt{D}} \sum_{j=0}^{D-1}|j\rangle_{A}|j\rangle_{B}) + (1 - p)\frac{I}{2^n}\]- Parameters:¶
- Raises:¶
Exception – The state should be a pure state if the backend is state_vector.
NotImplementedError – If the backend is wrong or not implemented.
- Returns:¶
The generated quantum state.
- Return type:¶
State
num_qubits=2 prob = 0.5 state =isotropic_state(num_qubits,prob) print(f'The isotropic state is:\n{state}')
The isotropic state is: --------------------------------------------------- Backend: density_matrix System dimension: [2, 2] System sequence: [0, 1] [[0.38+0.j 0. +0.j 0. +0.j 0.25+0.j] [0. +0.j 0.12+0.j 0. +0.j 0. +0.j] [0. +0.j 0. +0.j 0.12+0.j 0. +0.j] [0.25+0.j 0. +0.j 0. +0.j 0.38+0.j]] ---------------------------------------------------