6.7. utils#
- bin2num(c)[source]#
Convert binary list to decimal number.
- Parameters:
c (list([0|1])) – A list of 0 and 1 values.
- Returns:
result – The integer value corresponding to the binary list.
- Return type:
int
- embedSequences(seq)[source]#
This function scans through the operations in a
`Sequence`
object and replaces all occurences of`Sequence`
objects in it by the corresponding operations in it. This function only replaces`Sequence`
objects on the first level, i.e. it does not replace recursively all`Sequence`
objects within other`Sequence`
objects.- Parameters:
seq (geqo.core.quantum_circuit.Sequence) – A
`Sequence`
object.- Returns:
res – A
`Sequence`
object with all occurences of ``Sequence`` objects on the first level replaced by the corresponding operators.- Return type:
- getSingleQubitOperationOnRegister(u: MutableDenseMatrix | ndarray[tuple[Any, ...], dtype[_ScalarT]], numberQubits: int, targets: list[int]) MutableDenseMatrix | ndarray[tuple[Any, ...], dtype[_ScalarT]] [source]#
Apply single-qubit operation to specific qubits in register.
- num2bin(num, digits)[source]#
Convert a decimal number to a binary representation in list form.
- Parameters:
num (int) – An integer.
- Returns:
btstr – A list of 0 and 1, which is the binary representation of the given number.
- Return type:
list([0|1])
- partialTrace(rho: MutableDenseMatrix | ndarray[tuple[Any, ...], dtype[_ScalarT]], qubits: list[int], dropTargets: list[int]) tuple[MutableDenseMatrix, MutableDenseMatrix] | tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], ndarray[tuple[Any, ...], dtype[_ScalarT]]] [source]#
Compute partial trace of density matrix.
- partial_diag(rho, qubits, dropTargets)[source]#
Compute the partial trace (trace out the dropTargets) and extract the non-zero diagonal element of the reduced density matrix.
- Parameters:
rho (numpy.ndarry | sympy.Matrix) – A density matrix.
qubits (list(int|String)) – A list of qubits of a register.
dropTargets (list(int|String)) – The qubits that are discarded.
- Returns:
nonzero – A list of pairs. The first component of a pair is a binary representation of the index of a diagonal element of the density matrix. The second component is the corresponding entry.
- Return type:
list((list([0|1]), numpy.float64 | sympy.core ))
- permutationMatrixQubitsNumPy(perm: list[int]) ndarray[tuple[Any, ...], dtype[_ScalarT]] [source]#
Return permutation matrix for given qubit permutation.
- Parameters:
perm (list[int]) – The permutation of qubits in list form. The elements are indexed starting with 0. For instance, [0,2,1] denotes the permutation of 3 qubits, where the last 2 qubits are flipped.
- Returns:
A permutation matrix on the state space of the qubits. The matrix corresponds to the permutation of the qubits.
- Return type:
NDArray
- permutationMatrixQubitsSymPy(perm: list[int]) MutableDenseMatrix [source]#
Return a permutation matrix for given qubit permutation.
6.7. Params#
- perm: list[int]
The permutation of qubits in list form. Each entry is the index after the permutation.
6.7. Results#
- sym.Matrix
The permutation matrix corresponding to the provided permutation of qubits.