quairkit.database.set¶
- quairkit.database.set.pauli_basis(num_qubits)¶
Generate a Pauli basis.
- Parameters:¶
- num_qubits : int¶
the number of qubits \(n\).
- Returns:¶
The Pauli basis of \(\mathbb{C}^{2^n \times 2^n}\), where each tensor is accessible along the first dimension.
- Return type:¶
Tensor
num_qubits = 1 basis = pauli_basis(num_qubits) print(f'The Pauli basis is:\n{basis}')
The Pauli basis is: tensor([[[ 0.7071+0.0000j, 0.0000+0.0000j], [ 0.0000+0.0000j, 0.7071+0.0000j]], [[ 0.0000+0.0000j, 0.7071+0.0000j], [ 0.7071+0.0000j, 0.0000+0.0000j]], [[ 0.0000+0.0000j, 0.0000-0.7071j], [ 0.0000+0.7071j, 0.0000+0.0000j]], [[ 0.7071+0.0000j, 0.0000+0.0000j], [ 0.0000+0.0000j, -0.7071+0.0000j]]])
- quairkit.database.set.pauli_group(num_qubits)¶
Generate a Pauli group i.e., an unnormalized Pauli basis.
- Parameters:¶
- num_qubits : int¶
the number of qubits \(n\).
- Returns:¶
The Pauli group of \(\mathbb{C}^{2^n \times 2^n}\), where each tensor is accessible along the first dimension.
- Return type:¶
Tensor
num_qubits = 1 group = pauli_group(num_qubits) print(f'The Pauli group is:\n{group}')
The Pauli group is: tensor([[[ 1.0000+0.0000j, 0.0000+0.0000j], [ 0.0000+0.0000j, 1.0000+0.0000j]], [[ 0.0000+0.0000j, 1.0000+0.0000j], [ 1.0000+0.0000j, 0.0000+0.0000j]], [[ 0.0000+0.0000j, 0.0000-1.0000j], [ 0.0000+1.0000j, 0.0000+0.0000j]], [[ 1.0000+0.0000j, 0.0000+0.0000j], [ 0.0000+0.0000j, -1.0000+0.0000j]]])
- quairkit.database.set.pauli_str_basis(pauli_str)¶
Get the state basis with respect to the Pauli string
- Parameters:¶
- pauli_str : str | List[str]¶
the string composed of ‘i’, ‘x’, ‘y’ and ‘z’ only.
- Returns:¶
The state basis of the observable given by the Pauli string
- Return type:¶
State
pauli_str = ['x','z'] state_basis = pauli_str_basis(pauli_str) print(f'The state basis of the observable is:\n{state_basis}')
The state basis of the observable is: --------------------------------------------------- Backend: state_vector System dimension: [2] System sequence: [0] Batch size: [2, 2] # 0: [0.71+0.j 0.71+0.j] # 1: [ 0.71+0.j -0.71+0.j] # 2: [1.+0.j 0.+0.j] # 3: [0.+0.j 1.+0.j] ---------------------------------------------------
- quairkit.database.set.pauli_str_povm(pauli_str)¶
Get the povm with respect to the Pauli string
- Parameters:¶
- pauli_str : str | List[str]¶
the string composed of ‘i’, ‘x’, ‘y’ and ‘z’ only.
- Returns:¶
The POVM of the observable given by the Pauli string
- Return type:¶
Tensor
pauli_str = ['x','y'] POVM = pauli_str_povm(pauli_str) print(f'The POVM of the observable is:\n{POVM}')
The POVM of the observable is: tensor([[[[ 0.5000+0.0000j, 0.5000+0.0000j], [ 0.5000+0.0000j, 0.5000+0.0000j]], [[ 0.5000+0.0000j, -0.5000+0.0000j], [-0.5000+0.0000j, 0.5000+0.0000j]]], [[[ 0.5000+0.0000j, 0.0000-0.5000j], [ 0.0000+0.5000j, 0.5000+0.0000j]], [[ 0.5000+0.0000j, 0.0000+0.5000j], [ 0.0000-0.5000j, 0.5000+0.0000j]]]])
- quairkit.database.set.qft_basis(num_qubits)¶
Compute the eigenvectors (eigenbasis) of the Quantum Fourier Transform (QFT) matrix.
- Parameters:¶
- num_qubits : int¶
Number of qubits \(n\) such that \(N = 2^n\).
- Returns:¶
A tensor where the first index gives the eigenvector of the QFT matrix.
- Return type:¶
State
num_qubits = 2 qft_state = qft_basis(num_qubits) print(f'The eigenvectors of the QFT matrix is:\n{qft_state}')
The eigenvectors of the QFT matrix is: --------------------------------------------------- Backend: state_vector System dimension: [2] System sequence: [0] Batch size: [2] # 0: [0.92+0.j 0.38+0.j] # 1: [-0.38-0.j 0.92+0.j] ---------------------------------------------------
-
quairkit.database.set.std_basis(num_systems, system_dim=
2
)¶ Generate all standard basis states for a given number of qubits.
- Parameters:¶
- Returns:¶
A tensor where the first index gives the computational vector
- Return type:¶
State
num_systems = 2 system_dim=[1,2] basis = std_basis(num_systems,system_dim) print(f'The standard basis states are:\n{basis}')
The standard basis states are: --------------------------------------------------- Backend: state_vector System dimension: [1, 2] System sequence: [0, 1] Batch size: [2] # 0: [1.+0.j 0.+0.j] # 1: [0.+0.j 1.+0.j] ---------------------------------------------------
- quairkit.database.set.bell_basis()¶
Generate the Bell basis for a 2-qubit system, with each basis state accessible along the first dimension of a tensor.
- Returns:¶
A tensor of shape (4, 4, 1), representing the four Bell basis states.
basis=bell_basis() print(f'The Bell basis for a 2-qubit system are:\n{basis}')
- Return type:¶
State
The Bell basis for a 2-qubit system are: --------------------------------------------------- Backend: state_vector System dimension: [2, 2] System sequence: [0, 1] Batch size: [4] # 0: [0.71+0.j 0. +0.j 0. +0.j 0.71+0.j] # 1: [ 0.71+0.j 0. +0.j 0. +0.j -0.71+0.j] # 2: [0. +0.j 0.71+0.j 0.71+0.j 0. +0.j] # 3: [ 0. +0.j 0.71+0.j -0.71+0.j 0. +0.j] ---------------------------------------------------
- quairkit.database.set.heisenberg_weyl(dim)¶
- Generate Heisenberg-Weyl operator for qudit.
The Heisenberg-Weyl operators are defined as \(T(a,b) = e^{-(d+1) \pi i a b/ d}Z^a X^b\).
- Parameters:¶
- dim : int¶
dimension of qudit
- Returns:¶
Heisenberg-Weyl operator for qudit
- Return type:¶
Tensor
dim=2 operator=heisenberg_weyl(dim) print(f'The Heisenberg-Weyl operator for qudit is:\n{operator}')
The Heisenberg-Weyl operator for qudit is: tensor([[[ 1.0000e+00+0.0000e+00j, 0.0000e+00+0.0000e+00j], [ 0.0000e+00+0.0000e+00j, 1.0000e+00+0.0000e+00j]], [[ 1.0000e+00+0.0000e+00j, 0.0000e+00+0.0000e+00j], [ 0.0000e+00+0.0000e+00j, -1.0000e+00+1.2246e-16j]], [[ 0.0000e+00+0.0000e+00j, 1.0000e+00+0.0000e+00j], [ 1.0000e+00+0.0000e+00j, 0.0000e+00+0.0000e+00j]], [[-0.0000e+00+0.0000e+00j, -1.8370e-16+1.0000e+00j], [ 6.1232e-17-1.0000e+00j, -0.0000e+00+0.0000e+00j]]], dtype=torch.complex128)
- quairkit.database.set.phase_space_point(dim)¶
Generate phase space point operator for qudit
- Parameters:¶
- dim : int¶
dimension of qudit
- Returns:¶
Phase space point operator for qudit
- Return type:¶
Tensor
dim=2 operator=phase_space_point(dim) print(f'The phase space point operator for qudit is:\n{operator}')
The phase space point operator for qudit is: tensor([[[ 1.0000+0.0000e+00j, 0.5000+5.0000e-01j], [ 0.5000-5.0000e-01j, 0.0000+6.1232e-17j]], [[ 1.0000+0.0000e+00j, -0.5000-5.0000e-01j], [-0.5000+5.0000e-01j, 0.0000+6.1232e-17j]], [[ 0.0000+6.1232e-17j, 0.5000-5.0000e-01j], [ 0.5000+5.0000e-01j, 1.0000+0.0000e+00j]], [[ 0.0000+6.1232e-17j, -0.5000+5.0000e-01j], [-0.5000-5.0000e-01j, 1.0000+0.0000e+00j]]], dtype=torch.complex128)
- quairkit.database.set.gell_mann(dim)¶
Generate a set of Gell-Mann matrices for a given dimension. These matrices span the entire space dim-by-dim matrices, and they generalize the Pauli operators when dim = 2 and the Gell-Mann operators when dim = 3.
- Parameters:¶
- dim : int¶
a positive integer indicating the dimension.
- Returns:¶
A set of Gell-Mann matrices.
- Return type:¶
Tensor
dim=2 matrices=gell_mann(dim) print(f'The Gell-Mann matrices are:\n{matrices}')
The Gell-Mann matrices are: tensor([[[ 0.+0.j, 1.+0.j], [ 1.+0.j, 0.+0.j]], [[ 0.+0.j, -0.-1.j], [ 0.+1.j, 0.+0.j]], [[ 1.+0.j, 0.+0.j], [ 0.+0.j, -1.+0.j]]])