Basis#
Set of functions related to basis and basis transformations.
Pauli basis#
- qibo.quantum_info.pauli_basis(nqubits, normalize=False, vectorize=False, sparse=False, order=None, pauli_order='IXYZ', backend=None)[source]#
Creates the
nqubits-qubit Pauli basis.- Parameters:
nqubits (int) – number of qubits.
normalize (bool, optional) – If
True, normalized basis is returned. Defaults to False.vectorize (bool, optional) – If
False, returns a nested array with all Pauli matrices. IfTrue, returns an array where every row is a vectorized Pauli matrix. Defaults toFalse.sparse (bool, optional) – If
True, returns Pauli basis in a sparse representation. Defaults toFalse.order (str, optional) – If
"row", vectorization of Pauli basis is performed row-wise. If"column", vectorization is performed column-wise. If"system", system-wise vectorization is performed. Required whenvectorize=Trueand ignored whenvectorize=False. Defaults toNone.pauli_order (str, optional) – corresponds to the order of 4 single-qubit Pauli elements. Defaults to
"IXYZ".backend (
qibo.backends.abstract.Backend, optional) – backend to be used in the execution. IfNone, it uses the current backend. Defaults toNone.
- Returns:
- all Pauli matrices forming the basis. If
sparse=True and
vectorize=True, tuple is composed of an array of non-zero elements and an array with their row-wise indexes.
- all Pauli matrices forming the basis. If
- Return type:
ArrayLike or tuple
Computational basis to Pauli basis#
- qibo.quantum_info.comp_basis_to_pauli(nqubits, normalize=False, sparse=False, order='row', pauli_order='IXYZ', backend=None)[source]#
Matrix \(U\) that converts operators from the Liouville representation in the computational basis to the Pauli-Liouville representation.
The matrix \(U\) is given by
\[U = \sum_{k = 0}^{d^{2} - 1} \, |b_{k})(P_{k}| \, ,\]where \(|P_{k})\) is the vectorization of the \(k\)-th Pauli operator \(P_{k}\), and \(|b_{k})\) is the vectorization of the \(k\)-th computational basis element. \(U\) is unitary only if the Pauli basis is normalized, i.e.
normalize=True. For a definition of vectorization, seeqibo.quantum_info.vectorization().Example
from qibo.quantum_info import random_density_matrix, vectorization, comp_basis_to_pauli nqubits = 2 d = 2**nqubits rho = random_density_matrix(d) U_c2p = comp_basis_to_pauli(nqubits, normalize=True, order="system") rho_liouville = vectorization(rho, order="system") rho_pauli_liouville = U_c2p @ rho_liouville
- Parameters:
nqubits (int) – number of qubits.
normalize (bool, optional) – If
True, converts to the normalized Pauli basis. Defaults toFalse.sparse (bool, optional) – If
True, returns unitary matrix in sparse representation. Defaults toFalse.order (str, optional) – If
"row", vectorization of Pauli basis is performed row-wise. If"column", vectorization is performed column-wise. If"system", system-wise vectorization is performed. Defaults to"row".pauli_order (str, optional) – corresponds to the order of 4 single-qubit Pauli elements. Defaults to
"IXYZ".backend (
qibo.backends.abstract.Backend, optional) – backend to be used in the execution. IfNone, it uses the current backend. Defaults toNone.
- Returns:
- Matrix \(U\). If
sparse=True, tuple is composed of array of non-zero elements and an array with their row-wise indexes.
- Matrix \(U\). If
- Return type:
ArrayLike or tuple
Pauli basis to computational basis#
- qibo.quantum_info.pauli_to_comp_basis(nqubits, normalize=False, sparse=False, order='row', pauli_order='IXYZ', backend=None)[source]#
Matrix \(U\) that converts operators from the Pauli-Liouville representation to the Liouville representation in the computational basis.
The matrix \(U\) is given by
\[U = \sum_{k = 0}^{d^{2} - 1} \, |P_{k})(b_{k}| \, ,\]where \(|P_{k})\) is the vectorization of the \(k\)-th Pauli operator \(P_{k}\), and \(|b_{k})\) is the vectorization of the \(k\)-th computational basis element. \(U\) is unitary only if the Pauli basis is normalized, i.e.
normalize=True. For a definition of vectorization, seeqibo.quantum_info.vectorization().- Parameters:
nqubits (int) – number of qubits.
normalize (bool, optional) – If
True, converts to the normalized Pauli basis. Defaults toFalse.sparse (bool, optional) – If
True, returns unitary matrix in sparse representation. Defaults toFalse.order (str, optional) – If
"row", vectorization of Pauli basis is performed row-wise. If"column", vectorization is performed column-wise. If"system", system-wise vectorization is performed. Defaults to"row".pauli_order (str, optional) – corresponds to the order of 4 single-qubit Pauli elements. Defaults to
"IXYZ".backend (
qibo.backends.abstract.Backend, optional) – backend to be used in the execution. IfNone, it uses the current backend. Defaults toNone.
- Returns:
- Matrix \(U\). If
sparse=True, tuple is composed of array of non-zero elements and an array with their row-wise indexes.
- Matrix \(U\). If
- Return type:
ArrayLike or tuple