paddle_quantum.state.common
The common function of the quantum state.
- paddle_quantum.state.common.to_state(data, num_qubits=None, backend=None, dtype=None)
The function to generate a specified state instance.
- Parameters:
data (Tensor | ndarray | QEnv) – The analytical form of quantum state.
num_qubits (int | None) – The number of qubits contained in the quantum state. Defaults to
None
, which means it will be inferred by the data.backend (Backend | None) – Used to specify the backend used. Defaults to
None
, which means to use the default backend.dtype (str | None) – Used to specify the data dtype of the data. Defaults to
None
, which means to use the default data type.
- Returns:
The generated quantum state.
- Return type:
- paddle_quantum.state.common.zero_state(num_qubits, backend=None, dtype=None)
The function to generate a zero state.
- Parameters:
num_qubits (int) – The number of qubits contained in the quantum state.
backend (Backend | None) – Used to specify the backend used. Defaults to
None
, which means to use the default backend.dtype (str | None) – Used to specify the data dtype of the data. Defaults to
None
, which means to use the default data type.
- Raises:
NotImplementedError – If the backend is wrong or not implemented.
- Returns:
The generated quantum state.
- Return type:
- paddle_quantum.state.common.computational_basis(num_qubits, index, backend=None, dtype=None)
Generate a computational basis state
, whose i-th element is 1 and all the other elements are 0.- Parameters:
num_qubits (int) – The number of qubits contained in the quantum state.
index (int) – Index
of the computational basis state :math`|e_{i}rangle` .backend (Backend | None) – Used to specify the backend used. Defaults to
None
, which means to use the default backend.dtype (str | None) – Used to specify the data dtype of the data. Defaults to
None
, which means to use the default data type.
- Raises:
NotImplementedError – If the backend is wrong or not implemented.
- Returns:
The generated quantum state.
- Return type:
- paddle_quantum.state.common.bell_state(num_qubits, backend=None)
Generate a bell state.
Its matrix form is:
- Parameters:
num_qubits (int) – The number of qubits contained in the quantum state.
backend (Backend | None) – Used to specify the backend used. Defaults to
None
, which means to use the default backend.
- Raises:
NotImplementedError – If the backend is wrong or not implemented.
- Returns:
The generated quantum state.
- Return type:
- paddle_quantum.state.common.bell_diagonal_state(prob)
Generate a bell diagonal state.
Its matrix form is:
- 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:
- paddle_quantum.state.common.random_state(num_qubits, is_real=False, rank=None)
Generate a random quantum state.
- Parameters:
num_qubits (int) – The number of qubits contained in the quantum state.
is_real (bool | None) – If the quantum state only contains the real number. Defaults to
False
.rank (int | None) – The rank of the density matrix. Defaults to
None
which means full rank.
- Raises:
NotImplementedError – If the backend is wrong or not implemented.
- Returns:
The generated quantum state.
- Return type:
- paddle_quantum.state.common.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:
- paddle_quantum.state.common.ghz_state(num_qubits)
Generate a GHZ-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:
- paddle_quantum.state.common.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:
- paddle_quantum.state.common.r_state(prob)
Generate an R-state.
Its matrix form is:
- Parameters:
prob (float) – The parameter of the R-state to be generated. It should be in
.- 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:
- paddle_quantum.state.common.s_state(prob)
Generate the S-state.
Its matrix form is:
- Parameters:
prob (float) – The parameter of the S-state to be generated. It should be in
.- 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:
- paddle_quantum.state.common.isotropic_state(num_qubits, prob)
Generate the isotropic state.
Its matrix form is:
- 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
.
- 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: