qutip_qip.operations package¶
Submodules¶
qutip_qip.operations.gates module¶
-
qutip_qip.operations.gates.
berkeley
(N=None, targets=[0, 1])[source]¶ Quantum object representing the Berkeley gate.
- Returns
- berkeley_gateqobj
Quantum object representation of Berkeley gate
Examples
>>> berkeley() Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isHerm = True Qobj data = [[ cos(pi/8).+0.j 0.+0.j 0.+0.j 0.+sin(pi/8).j] [ 0.+0.j cos(3pi/8).+0.j 0.+sin(3pi/8).j 0.+0.j] [ 0.+0.j 0.+sin(3pi/8).j cos(3pi/8).+0.j 0.+0.j] [ 0.+sin(pi/8).j 0.+0.j 0.+0.j cos(pi/8).+0.j]]
-
qutip_qip.operations.gates.
cnot
(N=None, control=0, target=1)[source]¶ Quantum object representing the CNOT gate.
- Returns
- cnot_gateqobj
Quantum object representation of CNOT gate
Examples
>>> cnot() Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isHerm = True Qobj data = [[ 1.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 1.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 1.+0.j] [ 0.+0.j 0.+0.j 1.+0.j 0.+0.j]]
-
qutip_qip.operations.gates.
controlled_gate
(U, N=2, control=0, target=1, control_value=1)[source]¶ Create an N-qubit controlled gate from a single-qubit gate U with the given control and target qubits.
- Parameters
- UQobj
Arbitrary single-qubit gate.
- Ninteger
The number of qubits in the target space.
- controlinteger
The index of the first control qubit.
- targetinteger
The index of the target qubit.
- control_valueinteger (1)
The state of the control qubit that activates the gate U.
- Returns
- resultqobj
Quantum object representing the controlled-U gate.
-
qutip_qip.operations.gates.
cphase
(theta, N=2, control=0, target=1)[source]¶ Returns quantum object representing the controlled phase shift gate.
- Parameters
- thetafloat
Phase rotation angle.
- Ninteger
The number of qubits in the target space.
- controlinteger
The index of the control qubit.
- targetinteger
The index of the target qubit.
- Returns
- Uqobj
Quantum object representation of controlled phase gate.
-
qutip_qip.operations.gates.
cs_gate
(N=None, control=0, target=1)[source]¶ Controlled S gate.
- Returns
- result
qutip.Qobj
Quantum object for operator describing the rotation.
- result
-
qutip_qip.operations.gates.
csign
(N=None, control=0, target=1)[source]¶ Quantum object representing the CSIGN gate.
- Returns
- csign_gateqobj
Quantum object representation of CSIGN gate
Examples
>>> csign() Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isHerm = True Qobj data = [[ 1.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 1.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 1.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j -1.+0.j]]
-
qutip_qip.operations.gates.
ct_gate
(N=None, control=0, target=1)[source]¶ Controlled T gate.
- Returns
- result
qutip.Qobj
Quantum object for operator describing the rotation.
- result
-
qutip_qip.operations.gates.
cy_gate
(N=None, control=0, target=1)[source]¶ Controlled Y gate.
- Returns
- result
qutip.Qobj
Quantum object for operator describing the rotation.
- result
-
qutip_qip.operations.gates.
cz_gate
(N=None, control=0, target=1)[source]¶ Controlled Z gate.
- Returns
- result
qutip.Qobj
Quantum object for operator describing the rotation.
- result
-
qutip_qip.operations.gates.
expand_operator
(oper, N, targets, dims=None, cyclic_permutation=False)[source]¶ Expand a qubits operator to one that acts on a N-qubit system.
- Parameters
- oper
qutip.Qobj
An operator acts on qubits, the type of the
qutip.Qobj
has to be an operator and the dimension matches the tensored qubit Hilbert space e.g. dims =[[2, 2, 2], [2, 2, 2]]
- Nint
The number of qubits in the system.
- targetsint or list of int
The indices of qubits that are acted on.
- dimslist, optional
A list of integer for the dimension of each composite system. E.g
[2, 2, 2, 2, 2]
for 5 qubits system. If None, qubits system will be the default option.- cyclic_permutationboolean, optional
Expand for all cyclic permutation of the targets. E.g. if
N=3
and oper is a 2-qubit operator, the result will be a list of three operators, each acting on qubits 0 and 1, 1 and 2, 2 and 0.
- oper
- Returns
- expanded_oper
qutip.Qobj
The expanded qubits operator acting on a system with N qubits.
- expanded_oper
Notes
This is equivalent to gate_expand_1toN, gate_expand_2toN, gate_expand_3toN in
qutip_qip.gate.py
, but works for any dimension.
-
qutip_qip.operations.gates.
fredkin
(N=None, control=0, targets=[1, 2])[source]¶ Quantum object representing the Fredkin gate.
- Returns
- fredkin_gateqobj
Quantum object representation of Fredkin gate.
Examples
>>> fredkin() Quantum object: dims = [[2, 2, 2], [2, 2, 2]], shape = [8, 8], type = oper, isHerm = True Qobj data = [[ 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j]]
-
qutip_qip.operations.gates.
gate_expand_1toN
(U, N, target)[source]¶ Create a Qobj representing a one-qubit gate that act on a system with N qubits.
- Parameters
- UQobj
The one-qubit gate
- Ninteger
The number of qubits in the target space.
- targetinteger
The index of the target qubit.
- Returns
- gateqobj
Quantum object representation of N-qubit gate.
-
qutip_qip.operations.gates.
gate_expand_2toN
(U, N, control=None, target=None, targets=None)[source]¶ Create a Qobj representing a two-qubit gate that act on a system with N qubits.
- Parameters
- UQobj
The two-qubit gate
- Ninteger
The number of qubits in the target space.
- controlinteger
The index of the control qubit.
- targetinteger
The index of the target qubit.
- targetslist
List of target qubits.
- Returns
- gateqobj
Quantum object representation of N-qubit gate.
-
qutip_qip.operations.gates.
gate_expand_3toN
(U, N, controls=[0, 1], target=2)[source]¶ Create a Qobj representing a three-qubit gate that act on a system with N qubits.
- Parameters
- UQobj
The three-qubit gate
- Ninteger
The number of qubits in the target space.
- controlslist
The list of the control qubits.
- targetinteger
The index of the target qubit.
- Returns
- gateqobj
Quantum object representation of N-qubit gate.
-
qutip_qip.operations.gates.
gate_sequence_product
(U_list, left_to_right=True, inds_list=None, expand=False)[source]¶ Calculate the overall unitary matrix for a given list of unitary operations.
- Parameters
- U_list: list
List of gates implementing the quantum circuit.
- left_to_right: Boolean, optional
Check if multiplication is to be done from left to right.
- inds_list: list of list of int, optional
If expand=True, list of qubit indices corresponding to U_list to which each unitary is applied.
- expand: Boolean, optional
Check if the list of unitaries need to be expanded to full dimension.
- Returns
- U_overallqobj
Unitary matrix corresponding to U_list.
- overall_indslist of int, optional
List of qubit indices on which U_overall applies.
-
qutip_qip.operations.gates.
globalphase
(theta, N=1)[source]¶ Returns quantum object representing the global phase shift gate.
- Parameters
- thetafloat
Phase rotation angle.
- Returns
- phase_gateqobj
Quantum object representation of global phase shift gate.
Examples
>>> phasegate(pi/4) Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isHerm = False Qobj data = [[ 0.70710678+0.70710678j 0.00000000+0.j] [ 0.00000000+0.j 0.70710678+0.70710678j]]
-
qutip_qip.operations.gates.
hadamard_transform
(N=1)[source]¶ Quantum object representing the N-qubit Hadamard gate.
- Returns
- qqobj
Quantum object representation of the N-qubit Hadamard gate.
-
qutip_qip.operations.gates.
iswap
(N=None, targets=[0, 1])[source]¶ Quantum object representing the iSWAP gate.
- Returns
- iswap_gateqobj
Quantum object representation of iSWAP gate
Examples
>>> iswap() Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isHerm = False Qobj data = [[ 1.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+1.j 0.+0.j] [ 0.+0.j 0.+1.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 1.+0.j]]
-
qutip_qip.operations.gates.
molmer_sorensen
(theta, N=None, targets=[0, 1])[source]¶ Quantum object of a Mølmer–Sørensen gate.
- Parameters
- theta: float
The duration of the interaction pulse.
- N: int
Number of qubits in the system.
- target: int
The indices of the target qubits.
- Returns
- molmer_sorensen_gate
qutip.Qobj
Quantum object representation of the Mølmer–Sørensen gate.
- molmer_sorensen_gate
-
qutip_qip.operations.gates.
phasegate
(theta, N=None, target=0)[source]¶ Returns quantum object representing the phase shift gate.
- Parameters
- thetafloat
Phase rotation angle.
- Returns
- phase_gateqobj
Quantum object representation of phase shift gate.
Examples
>>> phasegate(pi/4) Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isHerm = False Qobj data = [[ 1.00000000+0.j 0.00000000+0.j ] [ 0.00000000+0.j 0.70710678+0.70710678j]]
-
qutip_qip.operations.gates.
qasmu_gate
(args, N=None, target=0)[source]¶ QASM U-gate as defined in the OpenQASM standard.
- Parameters
- thetafloat
The argument supplied to the last RZ rotation.
- phifloat
The argument supplied to the middle RY rotation.
- gammafloat
The argument supplied to the first RZ rotation.
- Nint
Number of qubits in the system.
- targetint
The index of the target qubit.
- Returns
- qasmu_gate
qutip.Qobj
Quantum object representation of the QASM U-gate as defined in the OpenQASM standard.
- qasmu_gate
-
qutip_qip.operations.gates.
qrot
(theta, phi, N=None, target=0)[source]¶ Single qubit rotation driving by Rabi oscillation with 0 detune.
- Parameters
- phifloat
The inital phase of the rabi pulse.
- thetafloat
The duration of the rabi pulse.
- Nint
Number of qubits in the system.
- targetint
The index of the target qubit.
- Returns
- qrot_gate
qutip.Qobj
Quantum object representation of physical qubit rotation under a rabi pulse.
- qrot_gate
-
qutip_qip.operations.gates.
qubit_clifford_group
(N=None, target=0)[source]¶ Generates the Clifford group on a single qubit, using the presentation of the group given by Ross and Selinger (http://www.mathstat.dal.ca/~selinger/newsynth/).
- Parameters
- Nint or None
Number of qubits on which each operator is to be defined (default: 1).
- targetint
Index of the target qubit on which the single-qubit Clifford operators are to act.
- Yields
- opQobj
Clifford operators, represented as Qobj instances.
-
qutip_qip.operations.gates.
rotation
(op, phi, N=None, target=0)[source]¶ Single-qubit rotation for operator op with angle phi.
- Returns
- resultqobj
Quantum object for operator describing the rotation.
-
qutip_qip.operations.gates.
rx
(phi, N=None, target=0)[source]¶ Single-qubit rotation for operator sigmax with angle phi.
- Returns
- resultqobj
Quantum object for operator describing the rotation.
-
qutip_qip.operations.gates.
ry
(phi, N=None, target=0)[source]¶ Single-qubit rotation for operator sigmay with angle phi.
- Returns
- resultqobj
Quantum object for operator describing the rotation.
-
qutip_qip.operations.gates.
rz
(phi, N=None, target=0)[source]¶ Single-qubit rotation for operator sigmaz with angle phi.
- Returns
- resultqobj
Quantum object for operator describing the rotation.
-
qutip_qip.operations.gates.
s_gate
(N=None, target=0)[source]¶ Single-qubit rotation also called Phase gate or the Z90 gate.
- Returns
- result
qutip.Qobj
Quantum object for operator describing a 90 degree rotation around the z-axis.
- result
-
qutip_qip.operations.gates.
snot
(N=None, target=0)[source]¶ Quantum object representing the SNOT (Hadamard) gate.
- Returns
- snot_gateqobj
Quantum object representation of SNOT gate.
Examples
>>> snot() Quantum object: dims = [[2], [2]], shape = [2, 2], type = oper, isHerm = True Qobj data = [[ 0.70710678+0.j 0.70710678+0.j] [ 0.70710678+0.j -0.70710678+0.j]]
-
qutip_qip.operations.gates.
sqrtiswap
(N=None, targets=[0, 1])[source]¶ Quantum object representing the square root iSWAP gate.
- Returns
- sqrtiswap_gateqobj
Quantum object representation of square root iSWAP gate
Examples
>>> sqrtiswap() Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isHerm = False Qobj data = [[ 1.00000000+0.j 0.00000000+0.j 0.00000000+0.j 0.00000000+0.j] [ 0.00000000+0.j 0.70710678+0.j 0.00000000-0.70710678j 0.00000000+0.j] [ 0.00000000+0.j 0.00000000-0.70710678j 0.70710678+0.j 0.00000000+0.j] [ 0.00000000+0.j 0.00000000+0.j 0.00000000+0.j 1.00000000+0.j]]
-
qutip_qip.operations.gates.
sqrtnot
(N=None, target=0)[source]¶ Single-qubit square root NOT gate.
- Returns
- resultqobj
Quantum object for operator describing the square root NOT gate.
-
qutip_qip.operations.gates.
sqrtswap
(N=None, targets=[0, 1])[source]¶ Quantum object representing the square root SWAP gate.
- Returns
- sqrtswap_gateqobj
Quantum object representation of square root SWAP gate
-
qutip_qip.operations.gates.
swap
(N=None, targets=[0, 1])[source]¶ Quantum object representing the SWAP gate.
- Returns
- swap_gateqobj
Quantum object representation of SWAP gate
Examples
>>> swap() Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isHerm = True Qobj data = [[ 1.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 1.+0.j 0.+0.j] [ 0.+0.j 1.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 1.+0.j]]
-
qutip_qip.operations.gates.
swapalpha
(alpha, N=None, targets=[0, 1])[source]¶ Quantum object representing the SWAPalpha gate.
- Returns
- swapalpha_gateqobj
Quantum object representation of SWAPalpha gate
Examples
>>> swapalpha(alpha) Quantum object: dims = [[2, 2], [2, 2]], shape = [4, 4], type = oper, isHerm = True Qobj data = [[ 1.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.5*(1 + exp(j*pi*alpha) 0.5*(1 - exp(j*pi*alpha) 0.+0.j] [ 0.+0.j 0.5*(1 - exp(j*pi*alpha) 0.5*(1 + exp(j*pi*alpha) 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 1.+0.j]]
-
qutip_qip.operations.gates.
t_gate
(N=None, target=0)[source]¶ Single-qubit rotation related to the S gate by the relationship S=T*T.
- Returns
- result
qutip.Qobj
Quantum object for operator describing a phase shift of pi/4.
- result
-
qutip_qip.operations.gates.
toffoli
(N=None, controls=[0, 1], target=2)[source]¶ Quantum object representing the Toffoli gate.
- Returns
- toff_gateqobj
Quantum object representation of Toffoli gate.
Examples
>>> toffoli() Quantum object: dims = [[2, 2, 2], [2, 2, 2]], shape = [8, 8], type = oper, isHerm = True Qobj data = [[ 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j 0.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j] [ 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.+0.j 0.+0.j]]
-
qutip_qip.operations.gates.
x_gate
(N=None, target=0)[source]¶ Pauli-X gate or sigmax operator.
- Returns
- result
qutip.Qobj
Quantum object for operator describing a single-qubit rotation through pi radians around the x-axis.
- result