qutip_qip.operations
Operations on quantum circuits.
Classes
|
Abstract base class for a quantum gate. |
|
Representation of a quantum measurement, with its required parameters, and target qubits. |
|
|
|
Single-Qubit IDENTITY gate. |
|
Pauli X gate. |
|
Pauli Y gate. |
|
Pauli Z gate. |
|
Hadamard gate. |
|
S gate i.e. \(\sqrt{Z}\) gate. |
|
Sdag gate i.e. \((\sqrt{Z})^\dagger\) gate. |
|
T gate i.e. \(\sqrt[4]{Z}\) gate. |
|
Tdag gate i.e. \(\sqrt[4]{Z}^\dagger\) gate. |
|
\(\sqrt{X}\) gate. |
|
\(\sqrt{X}^\dagger\) gate. |
|
Single-qubit rotation gate about the X-axis. |
|
Single-qubit rotation gate about the Y-axis. |
|
Single-qubit rotation gate about the Z-axis. |
|
Single-qubit parametric phase shift gate. |
|
Arbitrary single-qubit rotation gate. |
|
Universal single-qubit rotation gate (OpenQASM standard). |
|
SWAP gate. |
|
Two-qubit iSWAP gate. |
|
Inverse iSWAP (iSWAP dagger) gate. |
|
Two-qubit square root of SWAP (\(\sqrt{\mathrm{SWAP}}\)) gate. |
|
Inverse (hermitian conjugate) of SQRTSWAP gate i.e. (\(\sqrt{\mathrm{SWAP}}^\dagger\)). |
|
Two-qubit square root of iSWAP (\(\sqrt{\mathrm{iSWAP}}\)) gate. |
|
Inverse (hermitian conjugate) of SQRTISWAP gate i.e. (\(\sqrt{\mathrm{ISWAP}}^\dagger\)). |
|
Two-qubit Berkeley gate. |
|
Inverse (hermitian conjugate) of BERKELEY gate. |
|
Two-qubit parameterized fractional SWAP (SWAP-alpha) gate. |
|
Two-qubit parameterized Mølmer–Sørensen (MS) gate. |
|
CNOT gate i.e. Controlled Pauli X gate. |
|
Controlled Pauli Y gate. |
|
Controlled Pauli Z gate. |
|
Controlled Hadamard gate. |
|
Controlled S gate. |
|
Inverse of CS gate. |
|
Controlled T gate. |
|
Inverse of CT gate. |
|
Two-qubit Controlled RX gate. |
|
Two-qubit Controlled RY gate. |
|
Two-qubit Controlled RZ gate. |
|
Two-qubit parameterized controlled phase (CPHASE) gate. |
|
Two-qubit controlled universal rotation (CQASMU) gate. |
|
TOFFOLI gate (CCX). |
|
FREDKIN gate (C-SWAP). |
|
Global phase gate. |
|
Single-qubit idle operation (delay). |
Functions
|
Create an N-qubit controlled gate from a single-qubit gate U with the given control and target qubits. |
|
Expand an operator to one that acts on a system with desired dimensions. |
|
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
- class qutip_qip.operations.ControlledGate(*args, **kwargs)[source]
Bases:
GateAbstract 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_gate
Gate 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), setctrl_value=0b10.
- target_gate
- class qutip_qip.operations.Gate[source]
Bases:
ABCAbstract 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.
- class qutip_qip.operations.Measurement(name=None, targets=None, index=None, classical_store=None)[source]
Bases:
objectRepresentation 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:
objectRepresents 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:
GateAbstract 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.
- 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:
- U
qutip.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.
- 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:
- result
qutip.Qobj Quantum object for operator describing the rotation.
- result
- 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:
- result
qutip.Qobj Quantum object for operator describing the rotation.
- result
- qutip_qip.operations.cy_gate(*args, **kwargs)[source]
Controlled Y gate.
- Returns:
- result
qutip.Qobj Quantum object for operator describing the rotation.
- result
- qutip_qip.operations.cz_gate(*args, **kwargs)[source]
Controlled Z gate.
- Returns:
- result
qutip.Qobj Quantum object for operator describing the rotation.
- result
- 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:
- oper
qutip.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.
- oper
- Returns:
- expanded_oper
qutip.Qobj The expanded operator acting on a system with desired dimension.
- expanded_oper
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_gate
qutip.Qobj Quantum object representation of the Mølmer–Sørensen gate.
- molmer_sorensen_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_gate
qutip.Qobj Quantum object representation of the QASM U-gate as defined in the OpenQASM standard.
- qasmu_gate
- 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_gate
qutip.Qobj Quantum object representation of physical qubit rotation under a rabi pulse.
- qrot_gate
- 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:
- result
qutip.Qobj Quantum object for operator describing a 90 degree rotation around the z-axis.
- result
- 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:
- result
qutip.Qobj Quantum object for operator describing a phase shift of pi/4.
- result
- 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:
- result
qutip.Qobj Quantum object for operator describing a single-qubit rotation through pi radians around the x-axis.
- result