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.

Parameters:
num_systems : int

number of systems in this state. Alias of num_qubits.

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

quairkit.database.state.one_state(num_systems, system_dim=2)

The function to generate a one state.

Parameters:
num_systems : int

number of systems in this state. Alias of num_qubits.

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

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 :math`|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

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}\]
Parameters:
num_systems : int

number of systems in this state. Alias of num_qubits.

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

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

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

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

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

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

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

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:
num_qubits : int

The number of qubits contained in the quantum state.

prob : float

The parameter of the isotropic 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