# Module: cirq.ops

Types for representing and methods for manipulating circuit operation trees.

## Modules

arithmetic_operation module: Helper class for implementing classical arithmetic operations.

boolean_hamiltonian module: Represents Boolean functions as a series of CNOT and rotation gates. The Boolean functions are

clifford_gate module

common_channels module: Quantum channels that are commonly used in the literature.

common_gate_families module: Common Gate Families used in cirq-core

common_gates module: Quantum gates that are commonly used in the literature.

diagonal_gate module: Creates the gate instance for any number qubits diagonal gate.

eigen_gate module

fsim_gate module: Defines the fermionic simulation gate family.

gate_features module: Marker classes for indicating which additional features gates support.

gate_operation module: Basic types defining qubits, gates, and operations.

gateset module: Functionality for grouping and validating Cirq Gates

global_phase_op module: A no-qubit global phase operation.

identity module: IdentityGate.

kraus_channel module

matrix_gates module: Quantum gates defined by a matrix.

measure_util module

moment module: A simplified time-slice of operations within a sequenced circuit.

named_qubit module

op_tree module: A recursive type describing trees of operations, and utility methods for it.

parallel_gate module

parity_gates module: Quantum gates that phase with respect to product-of-pauli observables.

pauli_gates module

pauli_string module

phased_iswap_gate module: ISWAPPowGate conjugated by tensor product Rz(phi) and Rz(-phi).

phased_x_gate module: An XPowGate conjugated by ZPowGates.

projector module

qubit_order module

qubit_order_or_list module: Any method taking a QubitOrder instance should also take raw qubit lists.

raw_types module: Basic types defining qubits, gates, and operations.

state_preparation_channel module: Quantum gates to prepare a given target state.

swap_gates module: SWAP and ISWAP gates.

tags module: Canonical tags for the TaggedOperation class.

three_qubit_gates module: Common quantum gates that target three qubits.

two_qubit_diagonal_gate module: Creates the gate instance for a two qubit diagonal gate.

wait_gate module

## Classes

class AmplitudeDampingChannel: Dampen qubit amplitudes through dissipation.

class AnyIntegerPowerGateFamily: GateFamily which accepts instances of a given cirq.EigenGate, raised to integer power.

class AnyUnitaryGateFamily: GateFamily which accepts any N-Qubit unitary gate.

class ArithmeticOperation: A helper class for implementing reversible classical arithmetic.

class AsymmetricDepolarizingChannel: A channel that depolarizes asymmetrically along different directions.

class BaseDensePauliString: Parent class for DensePauliString and MutableDensePauliString.

class BitFlipChannel: Probabilistically flip a qubit from 1 to 0 state or vice versa.

class BooleanHamiltonian: An operation that represents a Hamiltonian from a set of Boolean functions.

class CCNotPowGate: A Toffoli (doubly-controlled-NOT) that can be raised to a power.

class CCXPowGate: A Toffoli (doubly-controlled-NOT) that can be raised to a power.

class CCZPowGate: A doubly-controlled-Z that can be raised to a power.

class CNotPowGate: A gate that applies a controlled power of an X gate.

class CSwapGate: A controlled swap gate. The Fredkin gate.

class CXPowGate: A gate that applies a controlled power of an X gate.

class CZPowGate: A gate that applies a phase to the |11⟩ state of two qubits.

class ControlledGate: Augments existing gates to have one or more control qubits.

class ControlledOperation: Augments existing operations to have one or more control qubits.

class DensePauliString: Parent class for DensePauliString and MutableDensePauliString.

class DepolarizingChannel: A channel that depolarizes one or several qubits.

class DiagonalGate: A gate given by a diagonal (2^n)\times(2^n) matrix.

class EigenGate: A gate with a known eigendecomposition.

class FSimGate: Fermionic simulation gate family.

class Gate: An operation type that can be applied to a collection of qubits.

class GateFamily: Wrapper around gate instances/types describing a set of accepted gates.

class GateOperation: An application of a gate to a sequence of qubits.

class Gateset: Gatesets represent a collection of cirq.GateFamily objects.

class GeneralizedAmplitudeDampingChannel: Dampen qubit amplitudes through non ideal dissipation.

class GlobalPhaseOperation: An effect applied to a collection of qubits.

class HPowGate: A Gate that performs a rotation around the X+Z axis of the Bloch sphere.

class ISwapPowGate: Rotates the |01⟩ vs |10⟩ subspace of two qubits around its Bloch X-axis.

class IdentityGate: A Gate that perform no operation on qubits.

class InterchangeableQubitsGate: Indicates operations should be equal under some qubit permutations.

class KrausChannel: A generic channel that can record the index of its selected operator.

class LinearCombinationOfGates: Represents linear operator defined by a linear combination of gates.

class LinearCombinationOfOperations: Represents operator defined by linear combination of gate operations.

class MatrixGate: A unitary qubit or qudit gate defined entirely by its matrix.

class MeasurementGate: A gate that measures qubits in the computational basis.

class MixedUnitaryChannel: A generic mixture that can record the index of its selected operator.

class Moment: A time-slice of operations within a circuit.

class MutableDensePauliString: Parent class for DensePauliString and MutableDensePauliString.

class MutablePauliString: Abstract base class for generic types.

class NamedQid: A qid identified by name.

class NamedQubit: A qubit identified by name.

class Operation: An effect applied to a collection of qubits.

class ParallelGate: Augments existing gates to be applied on one or more groups of qubits.

class ParallelGateFamily: GateFamily which accepts instances of cirq.ParallelGate and it's sub_gate.

class ParallelGateOperation: THIS CLASS IS DEPRECATED.

class Pauli: Represents the Pauli gates.

class PauliInteractionGate: A CZ conjugated by arbitrary single qubit Cliffords.

class PauliMeasurementGate: A gate that measures a Pauli observable.

class PauliString: An effect applied to a collection of qubits.

class PauliStringGateOperation: An effect applied to a collection of qubits.

class PauliStringPhasor: An operation that phases the eigenstates of a Pauli string.

class PauliSum: Represents operator defined by linear combination of PauliStrings.

class PauliSumExponential: Represents an operator defined by the exponential of a PauliSum.

class PauliTransform: +X, -X, +Y, -Y, +Z, or -Z.

class PhaseDampingChannel: Dampen qubit phase.

class PhaseFlipChannel: Probabilistically flip the sign of the phase of a qubit.

class PhaseGradientGate: Phases each state |k⟩ out of n by e^(2piik/nexponent).

class PhasedFSimGate: General excitation-preserving two-qubit gate.

class PhasedISwapPowGate: Fractional ISWAP conjugated by Z rotations.

class PhasedXPowGate: A gate equivalent to the circuit ───Z^-p───X^t───Z^p───.

class PhasedXZGate: A single qubit operation expressed as $$Z^z Z^a X^x Z^{-a}$$.

class ProjectorString

class ProjectorSum

class Qid: Identifies a quantum object such as a qubit, qudit, resonator, etc.

class QuantumFourierTransformGate: Switches from the computational basis to the frequency basis.

class QubitOrder: Defines the kronecker product order of qubits.

class QubitPermutationGate: A qubit permutation gate specified by a permutation list.

class RandomGateChannel: Applies a sub gate with some probability.

class ResetChannel: Reset a qubit back to its |0⟩ state.

class Rx: A gate, with matrix e^{-i X rads/2}, that rotates around the X axis of the Bloch sphere.

class Ry: A gate, with matrix e^{-i Y rads/2}, that rotates around the Y axis of the Bloch sphere.

class Rz: A gate, with matrix e^{-i Z rads/2}, that rotates around the Z axis of the Bloch sphere.

class SingleQubitCliffordGate: Any single qubit Clifford rotation.

class SingleQubitGate: A gate that must be applied to exactly one qubit.

class SingleQubitPauliStringGateOperation: A Pauli operation applied to a qubit.

class StatePreparationChannel: A channel which prepares any state provided as the state vector on it's target qubits.

class SwapPowGate: The SWAP gate, possibly raised to a power. Exchanges qubits.

class TaggedOperation: Operation annotated with a set of Tags.

class ThreeQubitDiagonalGate: A gate given by a diagonal 8x8 matrix.

class ThreeQubitGate: THIS CLASS IS DEPRECATED.

class TwoQubitDiagonalGate: A gate given by a diagonal 4\times 4 matrix.

class TwoQubitGate: THIS CLASS IS DEPRECATED.

class VirtualTag: A TaggedOperation tag indicating that the operation is virtual.

class WaitGate: A single-qubit idle gate that represents waiting.

class XPowGate: A gate that rotates around the X axis of the Bloch sphere.

class XXPowGate: The X-parity gate, possibly raised to a power.

class YPowGate: A gate that rotates around the Y axis of the Bloch sphere.

class YYPowGate: The Y-parity gate, possibly raised to a power.

class ZPowGate: A gate that rotates around the Z axis of the Bloch sphere.

class ZZPowGate: The Z-parity gate, possibly raised to a power.

## Functions

CCNOT(...): The TOFFOLI gate, also known as the Controlled-Controlled-X gate.

CCX(...): The TOFFOLI gate, also known as the Controlled-Controlled-X gate.

CCZ(...): The Controlled-Controlled-Z gate.

CNOT(...): The controlled NOT gate.

CSWAP(...): The Controlled Swap gate, also known as the Fredkin gate.

CX(...): The controlled NOT gate.

CZ(...): The controlled Z gate.

FREDKIN(...): The Controlled Swap gate, also known as the Fredkin gate.

H(...): The Hadamard gate.

I(...): The one qubit identity gate.

ISWAP(...): The iswap gate.

S(...): The Clifford S gate.

SQRT_ISWAP(...): The square root of iswap gate.

SQRT_ISWAP_INV(...): The inverse square root of iswap gate.

SWAP(...): The swap gate.

T(...): The non-Clifford T gate.

TOFFOLI(...): The TOFFOLI gate, also known as the Controlled-Controlled-X gate.

X(...): The Pauli X gate.

XX(...): The tensor product of two X gates.

Y(...): The Pauli Y gate.

YY(...): The tensor product of two Y gates.

Z(...): The Pauli Z gate.

ZZ(...): The tensor product of two Z gates.

amplitude_damp(...): Returns an AmplitudeDampingChannel with the given probability gamma.

asymmetric_depolarize(...): Returns a AsymmetricDepolarizingChannel with given parameter.

bit_flip(...): Construct a BitFlipChannel that flips a qubit state

cphase(...): Returns a gate with the matrix diag(1, 1, 1, e^{i rads}.

depolarize(...): Returns a DepolarizingChannel with given probability of error.

flatten_op_tree(...): Performs an in-order iteration of the operations (leaves) in an OP_TREE.

flatten_to_ops(...): Performs an in-order iteration of the operations (leaves) in an OP_TREE.

flatten_to_ops_or_moments(...): Performs an in-order iteration OP_TREE, yielding ops and moments.

freeze_op_tree(...): Replaces all iterables in the OP_TREE with tuples.

generalized_amplitude_damp(...): Returns a GeneralizedAmplitudeDampingChannel with the given

givens(...): Returns gate with matrix exp(-i angle_rads (Y⊗X - X⊗Y) / 2).

identity_each(...): Returns a single IdentityGate applied to all the given qubits.

measure(...): Returns a single MeasurementGate applied to all the given qubits.

measure_each(...): Returns a list of operations individually measuring the given qubits.

measure_paulistring_terms(...): Returns a list of operations individually measuring qubits in the pauli basis.

measure_single_paulistring(...): Returns a single PauliMeasurementGate which measures the pauli observable

parallel_gate_op(...): Constructs a ParallelGate using gate and applies to all given qubits

phase_damp(...): Creates a PhaseDampingChannel with damping constant gamma.

phase_flip(...): Returns a PhaseFlipChannel that flips a qubit's phase with probability p

qft(...): The quantum Fourier transform.

reset(...): Returns a ResetChannel on the given qubit.

reset_each(...): Returns a list of ResetChannel instances on the given qubits.

riswap(...): Returns gate with matrix exp(+i angle_rads (X⊗X + Y⊗Y) / 2).

rx(...): Returns a gate with the matrix e^{-i X rads / 2}.

ry(...): Returns a gate with the matrix e^{-i Y rads / 2}.

rz(...): Returns a gate with the matrix e^{-i Z rads / 2}.

transform_op_tree(...): Maps transformation functions onto the nodes of an OP_TREE.

wait(...): Creates a WaitGate applied to all the given qubits.

## Type Aliases

OP_TREE: An operation or nested collections of operations.

PAULI_GATE_LIKE: An object that can be interpreted as a Pauli gate.

PAULI_STRING_LIKE: A cirq.PauliString or a value that can easily be converted into one.

PauliSumLike: Any value that can be easily translated into a sum of Pauli products.

QubitOrderOrList: Specifies a qubit ordering.

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]