qutip_qip.operations

Operations on quantum circuits.

Classes

Gate()

Abstract base class for a quantum gate.

Measurement([name, targets, index, ...])

Representation of a quantum measurement, with its required parameters, and target qubits.

gates.GATE_CLASS_MAP

gates.IDENTITY()

Single-Qubit IDENTITY gate.

gates.X()

Pauli X gate.

gates.Y()

Pauli Y gate.

gates.Z()

Pauli Z gate.

gates.H()

Hadamard gate.

gates.S()

S gate i.e. \(\sqrt{Z}\) gate.

gates.Sdag()

Sdag gate i.e. \((\sqrt{Z})^\dagger\) gate.

gates.T()

T gate i.e. \(\sqrt[4]{Z}\) gate.

gates.Tdag()

Tdag gate i.e. \(\sqrt[4]{Z}^\dagger\) gate.

gates.SQRTX()

\(\sqrt{X}\) gate.

gates.SQRTXdag()

\(\sqrt{X}^\dagger\) gate.

gates.RX(arg_value[, arg_label])

Single-qubit rotation gate about the X-axis.

gates.RY(arg_value[, arg_label])

Single-qubit rotation gate about the Y-axis.

gates.RZ(arg_value[, arg_label])

Single-qubit rotation gate about the Z-axis.

gates.PHASE(arg_value[, arg_label])

Single-qubit parametric phase shift gate.

gates.R(arg_value[, arg_label])

Arbitrary single-qubit rotation gate.

gates.QASMU(arg_value[, arg_label])

Universal single-qubit rotation gate (OpenQASM standard).

gates.SWAP()

SWAP gate.

gates.ISWAP()

Two-qubit iSWAP gate.

gates.ISWAPdag()

Inverse iSWAP (iSWAP dagger) gate.

gates.SQRTSWAP()

Two-qubit square root of SWAP (\(\sqrt{\mathrm{SWAP}}\)) gate.

gates.SQRTSWAPdag()

Inverse (hermitian conjugate) of SQRTSWAP gate i.e. (\(\sqrt{\mathrm{SWAP}}^\dagger\)).

gates.SQRTISWAP()

Two-qubit square root of iSWAP (\(\sqrt{\mathrm{iSWAP}}\)) gate.

gates.SQRTISWAPdag()

Inverse (hermitian conjugate) of SQRTISWAP gate i.e. (\(\sqrt{\mathrm{ISWAP}}^\dagger\)).

gates.BERKELEY()

Two-qubit Berkeley gate.

gates.BERKELEYdag()

Inverse (hermitian conjugate) of BERKELEY gate.

gates.SWAPALPHA(arg_value[, arg_label])

Two-qubit parameterized fractional SWAP (SWAP-alpha) gate.

gates.MS(arg_value[, arg_label])

Two-qubit parameterized Mølmer–Sørensen (MS) gate.

gates.CX(*args, **kwargs)

CNOT gate i.e. Controlled Pauli X gate.

gates.CY(*args, **kwargs)

Controlled Pauli Y gate.

gates.CZ(*args, **kwargs)

Controlled Pauli Z gate.

gates.CH(*args, **kwargs)

Controlled Hadamard gate.

gates.CS(*args, **kwargs)

Controlled S gate.

gates.CSdag(*args, **kwargs)

Inverse of CS gate.

gates.CT(*args, **kwargs)

Controlled T gate.

gates.CTdag(*args, **kwargs)

Inverse of CT gate.

gates.CRX(*args, **kwargs)

Two-qubit Controlled RX gate.

gates.CRY(*args, **kwargs)

Two-qubit Controlled RY gate.

gates.CRZ(*args, **kwargs)

Two-qubit Controlled RZ gate.

gates.CPHASE(*args, **kwargs)

Two-qubit parameterized controlled phase (CPHASE) gate.

gates.CQASMU(*args, **kwargs)

Two-qubit controlled universal rotation (CQASMU) gate.

gates.TOFFOLI(*args, **kwargs)

TOFFOLI gate (CCX).

gates.FREDKIN(*args, **kwargs)

FREDKIN gate (C-SWAP).

gates.GLOBALPHASE(arg_value[, arg_label])

Global phase gate.

gates.IDLE(T[, arg_label])

Single-qubit idle operation (delay).

Functions

controlled_gate_unitary(U, num_controls, ...)

Create an N-qubit controlled gate from a single-qubit gate U with the given control and target qubits.

expand_operator(oper, dims[, targets, dtype])

Expand an operator to one that acts on a system with desired dimensions.

gate_sequence_product(U_list[, ...])

Calculate the overall unitary matrix for a given list of unitary operations.

class qutip_qip.operations.AngleParametricGate(arg_value, arg_label: str | None = None)[source]

Bases: ParametricGate

static validate_params(arg_value) None[source]

Validate the provided parameters.

This method should be implemented by subclasses to check if the parameters are valid type and within valid range (e.g., $0 le theta < 2pi$).

Parameters:
arg_valuelist of float

The parameters to validate.

class qutip_qip.operations.ControlledGate(*args, **kwargs)[source]

Bases: Gate

Abstract base class for controlled quantum gates.

A controlled gate applies a target unitary operation only when the control qubits are in a specific state.

Attributes:
target_gateGate

The gate to be applied to the target qubits.

num_ctrl_qubitsint

The number of qubits acting as controls.

ctrl_valueint

The decimal value of the control state required to execute the unitary operator on the target qubits.

Example: If the gate should execute when the 0-th qubit is $|1rangle$ set ctrl_value=1. If the gate should execute when two control qubits are $|10rangle$ (binary 10), set ctrl_value=0b10.

get_qobj() Qobj

Construct the full Qobj representation of the controlled gate.

Returns:
qobjqutip.Qobj

The unitary matrix representing the controlled operation.

class qutip_qip.operations.Gate[source]

Bases: ABC

Abstract base class for a quantum gate.

Concrete gate classes or gate implementations should be defined as subclasses of this class.

Attributes:
namestr

The name of the gate. If not manually set, this defaults to the class name. This is a class attribute; modifying it affects all instances.

num_qubitsint

The number of qubits the gate acts upon. This is a mandatory class attribute for subclasses.

self_inverse: bool

Indicates if the gate is its own inverse (e.g., $U = U^{-1}$). Default value is False.

is_clifford: bool

Indicates if the gate belongs to the Clifford group, which maps Pauli operators to Pauli operators. Default value is False

latex_strstr

The LaTeX string representation of the gate (used for circuit drawing). Defaults to the class name if not provided.

abstractmethod static get_qobj(dtype: str = 'dense') Qobj[source]

Get the qutip.Qobj representation of the gate operator.

Returns:
qobjqutip.Qobj

The compact gate operator as a unitary matrix.

classmethod inverse() Type[Gate][source]

Return the inverse of the gate.

If self_inverse is True, returns self. Otherwise, returns the specific inverse gate class.

Returns:
Type[Gate]

A Gate instance representing $G^{-1}$.

class qutip_qip.operations.Measurement(name=None, targets=None, index=None, classical_store=None)[source]

Bases: object

Representation of a quantum measurement, with its required parameters, and target qubits.

classmethod measurement_comp_basis(state, qubits)[source]

Measures a particular qubit (determined by the target) whose ket vector/ density matrix is specified in the computational basis and returns collapsed_states and probabilities (retains full dimension).

Parameters:
stateket or oper

state to be measured on specified by ket vector or density matrix

qubitslist or tuple of int

The indices of the qubits to be measured.

Returns:
collapsed_statesList of Qobjs

the collapsed state obtained after measuring the qubits and obtaining the qubit specified by the target in the state specified by the index.

probabilitiesList of floats

the probability of measuring a state in a the state specified by the index.

class qutip_qip.operations.NameSpace(local_name: str, parent: NameSpace | None = None, _registry: dict[str, any]=<factory>)[source]

Bases: object

Represents a distinct, optionally hierarchical namespace for registering quantum operations.

Parameters:
local_namestr

The local identifier for the namespace. Must not contain periods (‘.’).

parentNameSpace or None, optional

The parent namespace, if this is a nested sub-namespace. Default is None.

get(name: str | tuple[str, int, int]) any[source]

Retrieves a registered item from the namespace.

Parameters:
namestr or tuple of (str, int, int)

The identifier of the registered operation.

Returns:
any

The registered operation class or object, or None if it is not found.

property name: str

The fully qualified, hierarchical name of the namespace. (e.g., ‘std.gates’).

Type:

str

register(name: str | tuple[str, int, int], operation_cls: any) None[source]

Safely adds an item to this specific namespace.

Parameters:
namestr or tuple of (str, int, int)

The identifier for the operation. Use a string for a non-controlled gate. Use a tuple (target_gate.name, num_ctrl_qubits, ctrl_values) as a second key for controlled gates.

operation_clsany

The operation class or object to register.

Raises:
NameError

If an operation with the given name already exists in this namespace.

class qutip_qip.operations.ParametricGate(arg_value, arg_label: str | None = None)[source]

Bases: Gate

Abstract base class for parametric quantum gates.

Parameters:
arg_valuefloat or Sequence

The argument value(s) for the gate. If a single float is provided, it is converted to a list. These values are saved as attributes and can be accessed or modified later.

arg_labelstr, optional

Label for the argument to be shown in the circuit plot.

Example: If arg_label="\phi", the LaTeX name for the gate in the circuit plot will be rendered as $U(\phi)$.

Attributes:
num_paramsint

The number of parameters required by the gate. This is a mandatory class attribute for subclasses.

arg_valueSequence

The numerical values of the parameters provided to the gate.

arg_labelstr, optional

The LaTeX string representing the parameter variable in circuit plots.

Raises:
ValueError

If the number of provided arguments does not match num_params.

abstractmethod get_qobj(dtype: str = 'dense') Qobj[source]

Get the QuTiP quantum object representation using the current parameters.

Returns:
qobjqutip.Qobj

The unitary matrix representing the gate with the specific arg_value.

inverse() Gate[source]

Return the inverse of the gate.

If self_inverse is True, returns self. Otherwise, returns the specific inverse gate class.

Returns:
Type[Gate]

A Gate instance representing $G^{-1}$.

abstractmethod static validate_params(arg_value)[source]

Validate the provided parameters.

This method should be implemented by subclasses to check if the parameters are valid type and within valid range (e.g., $0 le theta < 2pi$).

Parameters:
arg_valuelist of float

The parameters to validate.

qutip_qip.operations.berkeley(*args, **kwargs)[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', dtype=Dense, 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.cnot(*args, **kwargs)[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', dtype=Dense, 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.controlled_gate_unitary(U: Qobj, num_controls: int, control_value: int) Qobj[source]

Create an N-qubit controlled gate from a single-qubit gate U with the given control and target qubits.

Parameters:
Uqutip.Qobj

An arbitrary unitary gate.

controlslist of int

The index of the first control qubit.

targetslist of int

The index of the target qubit.

Nint

The total number of qubits.

control_valueint

The decimal value of the controlled qubits that activates the gate U.

Returns:
resultqobj

Quantum object representing the controlled-U gate.

qutip_qip.operations.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.cs_gate(*args, **kwargs)[source]

Controlled S gate.

Returns:
resultqutip.Qobj

Quantum object for operator describing the rotation.

qutip_qip.operations.csign(*args, **kwargs)[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', dtype=Dense, 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.ct_gate(*args, **kwargs)[source]

Controlled T gate.

Returns:
resultqutip.Qobj

Quantum object for operator describing the rotation.

qutip_qip.operations.cy_gate(*args, **kwargs)[source]

Controlled Y gate.

Returns:
resultqutip.Qobj

Quantum object for operator describing the rotation.

qutip_qip.operations.cz_gate(*args, **kwargs)[source]

Controlled Z gate.

Returns:
resultqutip.Qobj

Quantum object for operator describing the rotation.

qutip_qip.operations.expand_operator(oper: Qobj, dims: Iterable[int], targets: int | Iterable[int] | None = None, dtype: str | None = None) Qobj[source]

Expand an operator to one that acts on a system with desired dimensions.

Parameters:
operqutip.Qobj

An operator that act on the subsystem, has to be an operator and the dimension matches the tensored dims Hilbert space e.g. oper.dims = [[2, 3], [2, 3]]

dimslist

A list of integer for the dimension of each composite system. E.g [2, 3, 2, 3, 4].

targetsint or list of int

The indices of subspace that are acted on. Permutation can also be realized by changing the orders of the indices.

dtypestr, optional

Data type of the output Qobj.

Returns:
expanded_operqutip.Qobj

The expanded operator acting on a system with desired dimension.

Examples

>>> import qutip
>>> from qutip_qip.operations import expand_operator
>>> from qutip_qip.operations.gates import X, CX
>>> expand_operator(X.get_qobj(), dims=[2,3], targets=[0])
Quantum object: dims=[[2, 3], [2, 3]], shape=(6, 6), type='oper', dtype=CSR, isherm=True
Qobj data =
[[0. 0. 0. 1. 0. 0.]
 [0. 0. 0. 0. 1. 0.]
 [0. 0. 0. 0. 0. 1.]
 [1. 0. 0. 0. 0. 0.]
 [0. 1. 0. 0. 0. 0.]
 [0. 0. 1. 0. 0. 0.]]
>>> expand_operator(CX.get_qobj(), dims=[2,2,2], targets=[1, 2])
Quantum object: dims=[[2, 2, 2], [2, 2, 2]], shape=(8, 8), type='oper', dtype=CSR, isherm=True
Qobj data =
[[1. 0. 0. 0. 0. 0. 0. 0.]
 [0. 1. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 1. 0. 0. 0. 0.]
 [0. 0. 1. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 1. 0. 0. 0.]
 [0. 0. 0. 0. 0. 1. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 1.]
 [0. 0. 0. 0. 0. 0. 1. 0.]]
>>> expand_operator(CX.get_qobj(), dims=[2, 2, 2], targets=[2, 0])
Quantum object: dims=[[2, 2, 2], [2, 2, 2]], shape=(8, 8), type='oper', dtype=CSR, isherm=True
Qobj data =
[[1. 0. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 1. 0. 0.]
 [0. 0. 1. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 0. 1.]
 [0. 0. 0. 0. 1. 0. 0. 0.]
 [0. 1. 0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0. 1. 0.]
 [0. 0. 0. 1. 0. 0. 0. 0.]]
qutip_qip.operations.fredkin(*args, **kwargs)[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', dtype=Dense, 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.gate_sequence_product(U_list: list[Qobj], left_to_right: bool = True, inds_list: list[list[int]] | None = None, expand: bool = False) Qobj | tuple[Qobj, list[int]][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.get_controlled_gate(gate: Type[Gate], n_ctrl_qubits: int = 1, control_value: int | None = None, gate_name: str | None = None, gate_namespace: NameSpace | None = None) ControlledGate[source]

Gate Factory for Controlled Gate that takes a gate and num_ctrl_qubits.

qutip_qip.operations.get_unitary_gate(gate_name: str, U: Qobj, gate_namespace: NameSpace | None = None) Type[Gate][source]

Gate Factory for Custom Gate that wraps an arbitrary unitary matrix U.

qutip_qip.operations.globalphase(theta, N=1, *args, **kwargs)[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', dtype=Dense, isherm=False
Qobj data =
[[ 0.70710678+0.70710678j          0.00000000+0.j]
 [ 0.00000000+0.j          0.70710678+0.70710678j]]
qutip_qip.operations.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.iswap(*args, **kwargs)[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', dtype=Dense, 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.molmer_sorensen(theta, phi=0.0, *args, **kwargs)[source]

Quantum object of a Mølmer–Sørensen gate.

Parameters:
theta: float

The duration of the interaction pulse.

phi: float

Rotation axis. phi = 0 for XX; phi=pi for YY

N: int

Number of qubits in the system.

target: int

The indices of the target qubits.

Returns:
molmer_sorensen_gatequtip.Qobj

Quantum object representation of the Mølmer–Sørensen gate.

qutip_qip.operations.phasegate(theta, *args, **kwargs)[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', dtype=Dense, isherm=False
Qobj data =
[[ 1.00000000+0.j          0.00000000+0.j        ]
 [ 0.00000000+0.j          0.70710678+0.70710678j]]
qutip_qip.operations.qasmu_gate(args, **kwargs)[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_gatequtip.Qobj

Quantum object representation of the QASM U-gate as defined in the OpenQASM standard.

qutip_qip.operations.qrot(theta, phi, *args, **kwargs)[source]

Single qubit rotation driving by Rabi oscillation with 0 detune.

Parameters:
phifloat

The initial 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_gatequtip.Qobj

Quantum object representation of physical qubit rotation under a rabi pulse.

qutip_qip.operations.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.rotation(op, phi, *args, **kwargs)[source]

Single-qubit rotation for operator op with angle phi.

Returns:
resultqobj

Quantum object for operator describing the rotation.

qutip_qip.operations.rx(phi, *args, **kwargs)[source]

Single-qubit rotation for operator sigmax with angle phi.

Returns:
resultqobj

Quantum object for operator describing the rotation.

qutip_qip.operations.ry(phi, *args, **kwargs)[source]

Single-qubit rotation for operator sigmay with angle phi.

Returns:
resultqobj

Quantum object for operator describing the rotation.

qutip_qip.operations.rz(phi, *args, **kwargs)[source]

Single-qubit rotation for operator sigmaz with angle phi.

Returns:
resultqobj

Quantum object for operator describing the rotation.

qutip_qip.operations.s_gate(*args, **kwargs)[source]

Single-qubit rotation also called Phase gate or the Z90 gate.

Returns:
resultqutip.Qobj

Quantum object for operator describing a 90 degree rotation around the z-axis.

qutip_qip.operations.snot(*args, **kwargs)[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', dtype=Dense, isherm=True
Qobj data =
[[ 0.70710678+0.j  0.70710678+0.j]
 [ 0.70710678+0.j -0.70710678+0.j]]
qutip_qip.operations.sqrtiswap(*args, **kwargs)[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', dtype=Dense, 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.sqrtnot(*args, **kwargs)[source]

Single-qubit square root NOT gate.

Returns:
resultqobj

Quantum object for operator describing the square root NOT gate.

qutip_qip.operations.sqrtswap(*args, **kwargs)[source]

Quantum object representing the square root SWAP gate.

Returns:
sqrtswap_gateqobj

Quantum object representation of square root SWAP gate

qutip_qip.operations.swap(*args, **kwargs)[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', dtype=Dense, 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.swapalpha(alpha, *args, **kwargs)[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', dtype=Dense, 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.t_gate(*args, **kwargs)[source]

Single-qubit rotation related to the S gate by the relationship S=T*T.

Returns:
resultqutip.Qobj

Quantum object for operator describing a phase shift of pi/4.

qutip_qip.operations.toffoli(*args, **kwargs)[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', dtype=Dense, 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.x_gate(*args, **kwargs)[source]

Pauli-X gate or sigmax operator.

Returns:
resultqutip.Qobj

Quantum object for operator describing a single-qubit rotation through pi radians around the x-axis.

qutip_qip.operations.y_gate(*args, **kwargs)[source]

Pauli-Y gate or sigmay operator.

Returns:
resultqutip.Qobj

Quantum object for operator describing a single-qubit rotation through pi radians around the y-axis.

qutip_qip.operations.z_gate(*args, **kwargs)[source]

Pauli-Z gate or sigmaz operator.

Returns:
resultqutip.Qobj

Quantum object for operator describing a single-qubit rotation through pi radians around the z-axis.