quairkit.database.random¶
The library of random data generation functions
-
quairkit.database.random.random_pauli_str_generator(num_qubits, terms=
3
)¶ Generate a random observable in list form.
An observable \(O=0.3X\otimes I\otimes I+0.5Y\otimes I\otimes Z\)’s list form is
[[0.3, 'x0'], [0.5, 'y0,z2']]
. Such an observable is generated byrandom_pauli_str_generator(3, terms=2)
-
quairkit.database.random.random_state(num_systems, rank=
None
, is_real=False
, size=1
, system_dim=2
)¶ Generate a random quantum state.
- Parameters:¶
- num_systems : int¶
The number of qubits contained in the quantum state.
- rank : int | None¶
The rank of the density matrix. Defaults to
None
which means full rank.- is_real : bool | None¶
If the quantum state only contains the real number. Defaults to
False
.- size : List[int] | int | None¶
Batch size. Defaults to 1
- 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.
- Raises:¶
NotImplementedError – If the backend is wrong or not implemented.
- Returns:¶
The generated quantum state.
- Return type:¶
State
-
quairkit.database.random.random_hamiltonian_generator(num_qubits, terms=
3
)¶ Generate a random Hamiltonian.
- quairkit.database.random.random_hermitian(num_qubits)¶
randomly generate a \(2^n \times 2^n\) hermitian matrix
- quairkit.database.random.random_orthogonal_projection(num_qubits)¶
randomly generate a \(2^n \times 2^n\) rank-1 orthogonal projector
- quairkit.database.random.random_density_matrix(num_qubits)¶
randomly generate an num_qubits-qubit state in density matrix form
-
quairkit.database.random.random_unitary(num_systems, size=
1
, system_dim=2
)¶ randomly generate a \(d \times d\) unitary
- quairkit.database.random.random_unitary_hermitian(num_qubits)¶
randomly generate a \(2^n \times 2^n\) hermitian unitary
-
quairkit.database.random.random_unitary_with_hermitian_block(num_qubits, is_unitary=
False
)¶ randomly generate a unitary \(2^n \times 2^n\) matrix that is a block encoding of a \(2^{n/2} \times 2^{n/2}\) Hermitian matrix
- quairkit.database.random.haar_orthogonal(dim)¶
randomly generate an orthogonal matrix following Haar random, referenced by arXiv:math-ph/0609050v2
- quairkit.database.random.haar_unitary(dim)¶
randomly generate a unitary following Haar random, referenced by arXiv:math-ph/0609050v2
-
quairkit.database.random.haar_state_vector(dim, is_real=
False
)¶ randomly generate a state vector following Haar random
-
quairkit.database.random.haar_density_operator(dim, rank, is_real=
False
)¶ randomly generate a density matrix following Haar random
-
quairkit.database.random.random_channel(num_systems, rank=
None
, target='kraus'
, size=1
, system_dim=2
)¶ Generate a random channel from its Stinespring representation
- Parameters:¶
- num_systems : int¶
number of systems
- rank : int¶
rank of this Channel. Defaults to be random sampled from \([1, d]\)
- target : str¶
target representation, should to be
'choi'
,'kraus'
or'stinespring'
- size : int | None¶
batch size. Defaults to 1
- 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 target representation of a random channel.
- Return type:¶
Tensor