# Module: cirq

## Modules

circuits module: Types and methods related to building and optimizing sequenced circuits.

contrib module: Package for contributions.

devices module: Types for devices, device-specific qubits, and noise models.

experiments module: Package containing characterization tools and experiments.

interop module: Package containing code for interoperating with other quantum software.

ion module: Types for representing and methods for manipulating ion trap operations.

linalg module: Types and methods related to performing linear algebra.

neutral_atoms module: Device classes and tools specific to a neutral atom quantum processor.

ops module: Types for representing and methods for manipulating circuit operation trees.

optimizers module: Circuit transformation utilities.

protocols module: Methods and classes that define cirq's protocols.

qis module: Tools and methods for quantum information science.

sim module: Base simulation classes and generic simulators.

study module: Types and methods for running studies (repeated trials).

testing module: Utilities for testing code.

type_workarounds module: Module defining NotImplementedType.

value module: Value conversion utilities and types for time and quantum states.

vis module: Visualization utilities.

work module: Workflow utilities for sampling and measurement collection.

## Classes

class ABCMetaImplementAnyOneOf: A metaclass extending abc.ABCMeta for defining abstract base classes

class AbstractCircuit: The base class for Circuit-like objects.

class ActOnArgs: State and context for an operation acting on a state tensor.

class ActOnArgsContainer: A container for a Qid-to-ActOnArgs dictionary.

class ActOnCliffordTableauArgs: State and context for an operation acting on a clifford tableau.

class ActOnDensityMatrixArgs: State and context for an operation acting on a density matrix.

class ActOnStabilizerCHFormArgs: Wrapper around a stabilizer state in CH form for the act_on protocol.

class ActOnStateVectorArgs: State and context for an operation acting on a state vector.

class AlignLeft: Aligns gates to the left of the circuit.

class AlignRight: Aligns gates to the right of the circuit.

class Alignment: An enumeration.

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 ApplyChannelArgs: Arguments for efficiently performing a channel.

class ApplyMixtureArgs: Arguments for performing a mixture of unitaries.

class ApplyUnitaryArgs: Arguments for performing an efficient left-multiplication by a unitary.

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

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

class AxisAngleDecomposition: Represents a unitary operation as an axis, angle, and global phase.

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 Circuit: A mutable list of groups of operations to apply to some qubits.

class CircuitDag: A representation of a Circuit as a directed acyclic graph.

class CircuitDiagramInfo: Describes how to draw an operation in a circuit diagram.

class CircuitDiagramInfoArgs: A request for information on drawing an operation in a circuit diagram.

class CircuitOperation: An operation that encapsulates a circuit.

class CircuitSampleJob: Describes a sampling task.

class CliffordSimulator: An efficient simulator for Clifford circuits.

class CliffordSimulatorStepResult: A StepResult that includes StateVectorMixin methods.

class CliffordState: A state of the Clifford simulation.

class CliffordTableau: Tableau representation of a stabilizer state

class CliffordTrialResult: Results of a simulation by a SimulatesFinalState.

class Collector: Collects data from a sampler, in parallel, towards some purpose.

class ConstantQubitNoiseModel: Applies noise to each qubit individually at the start of every moment.

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 ConvertToCzAndSingleGates: Attempts to convert strange multi-qubit gates into CZ and single qubit

class ConvertToIonGates: Attempts to convert non-native gates into IonGates.

class ConvertToNeutralAtomGates: Attempts to convert gates into native Atom gates.

class DensePauliString: Parent class for DensePauliString and MutableDensePauliString.

class DensityMatrixSimulator: A simulator for density matrices and noisy quantum circuits.

class DensityMatrixSimulatorState: The simulator state for DensityMatrixSimulator

class DensityMatrixStepResult: A single step in the simulation of the DensityMatrixSimulator.

class DensityMatrixTrialResult: A SimulationTrialResult for DensityMatrixSimulator runs.

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

class Device: Hardware constraints for validating circuits.

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

class DropEmptyMoments: Removes empty moments from a circuit.

class DropNegligible: An optimization pass that removes operations with tiny effects.

class Duration: A time delta that supports symbols and picosecond accuracy.

class EigenGate: A gate with a known eigendecomposition.

class EjectPhasedPaulis: Pushes X, Y, and PhasedX gates towards the end of the circuit.

class EjectZ: Pushes Z gates towards the end of the circuit.

class ExpandComposite: An optimizer that expands composite operations via cirq.decompose.

class ExpressionMap: A dictionary with sympy expressions and symbols for keys and sympy

class FSimGate: Fermionic simulation gate family.

class FrozenCircuit: An immutable version of the Circuit data structure.

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 GenericMetaImplementAnyOneOf: Generic version of ABCMetaImplementAnyOneOf.

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

class GridQid: A qid on a 2d square lattice

class GridQubit: A qubit on a 2d square lattice.

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

class Heatmap: Distribution of a value in 2D qubit lattice as a color map.

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 InsertStrategy: Indicates preferences on how to add multiple operations to a circuit.

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

class IonDevice: A device with qubits placed on a line.

class JsonResolver: Protocol for json resolver functions passed to read_json.

class KakDecomposition: A convenient description of an arbitrary two-qubit operation.

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

class LineQid: A qid on a 1d lattice with nearest-neighbor connectivity.

class LineQubit: A qubit on a 1d lattice with nearest-neighbor connectivity.

class LineTopology: A 1D linear topology.

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

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

class LinearDict: Represents linear combination of things.

class Linspace: A simple sweep over linearly-spaced values.

class ListSweep: A wrapper around a list of ParamResolvers.

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 MeasurementKey: A class representing a Measurement Key.

class MergeInteractions: Combines series of adjacent one- and two-qubit, non-parametrized gates

class MergeInteractionsToSqrtIswap: Combines series of adjacent one- and two-qubit, non-parametrized gates

class MergeSingleQubitGates: Optimizes runs of adjacent unitary 1-qubit operations.

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 NamedTopology: A topology (graph) with a name.

class NeutralAtomDevice: A device with qubits placed on a grid.

class NoiseModel: Replaces operations and moments with noisy counterparts.

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

class OperationTarget: An interface for quantum states as targets for operations.

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 ParamResolver: Resolves parameters to actual values.

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 PauliSumCollector: Estimates the energy of a linear combination of Pauli observables.

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

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

class PeriodicValue: Wrapper for periodic numerical values.

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 PointOptimizationSummary: A description of a local optimization to perform.

class PointOptimizer: Makes circuit improvements focused on a specific location.

class Points: A simple sweep with explicitly supplied values.

class Product: Cartesian product of one or more sweeps.

class ProductState: A quantum state that is a tensor product of one qubit states.

class ProjectorString

class ProjectorSum

class QasmArgs

class QasmOutput: Representation of a circuit in QASM (quantum assembly) format.

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 QuantumState: A quantum state.

class QubitOrder: Defines the kronecker product order of qubits.

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

class QuilFormatter: A unique formatter to correctly output values to QUIL.

class QuilOutput: An object for passing operations and qubits then outputting them to

class RandomGateChannel: Applies a sub gate with some probability.

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

class Result: The results of multiple executions of a circuit with fixed parameters.

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 Sampler: Something capable of sampling quantum circuits. Simulator or hardware.

class SerializableByKey: Protocol for objects that can be serialized to a key + context.

class SimulatesAmplitudes: Simulator that computes final amplitudes of given bitstrings.

class SimulatesExpectationValues: Simulator that computes exact expectation values of observables.

class SimulatesFinalState: Simulator that allows access to the simulator's final state.

class SimulatesIntermediateState: A SimulatesFinalState that simulates a circuit by moments.

class SimulatesIntermediateStateVector: A simulator that accesses its state vector as it does its simulation.

class SimulatesSamples: Simulator that mimics running on quantum hardware.

class SimulationTrialResult: Results of a simulation by a SimulatesFinalState.

class Simulator: A sparse matrix state vector simulator that uses numpy.

class SimulatorBase: A base class for the built-in simulators.

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 SparseSimulatorStep: A StepResult that includes StateVectorMixin methods.

class StabilizerSampler: An efficient sampler for stabilizer circuits.

class StabilizerStateChForm: A representation of stabilizer states using the CH form,

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

class StateVectorMixin: A mixin that provide methods for objects that have a state vector.

class StateVectorSimulatorState

class StateVectorStepResult: A base class for step results.

class StateVectorTrialResult: A SimulationTrialResult that includes the StateVectorMixin methods.

class StepResult: Results of a step of a SimulatesIntermediateState.

class StepResultBase: A base class for step results.

class SupportsActOn: An object that explicitly specifies how to act on simulator states.

class SupportsActOnQubits: An object that explicitly specifies how to act on specific qubits.

class SupportsApplyChannel: An object that can efficiently implement a channel.

class SupportsApplyMixture: An object that can efficiently implement a mixture.

class SupportsApproximateEquality: Object which can be compared approximately.

class SupportsCircuitDiagramInfo: A diagrammable operation on qubits.

class SupportsCommutes: An object that can determine commutation relationships vs others.

class SupportsConsistentApplyUnitary: An object that can be efficiently left-multiplied into tensors.

class SupportsDecompose: An object that can be decomposed into simpler operations.

class SupportsDecomposeWithQubits: An object that can be decomposed into operations on given qubits.

class SupportsEqualUpToGlobalPhase: Object which can be compared for equality mod global phase.

class SupportsExplicitHasUnitary: An object that explicitly specifies whether it has a unitary effect.

class SupportsExplicitNumQubits: A unitary, channel, mixture or other object that operates on a known

class SupportsExplicitQidShape: A unitary, channel, mixture or other object that operates on a known

class SupportsJSON: An object that can be turned into JSON dictionaries.

class SupportsKraus: An object that may be describable as a quantum channel.

class SupportsMeasurementKey: An object that is a measurement and has a measurement key or keys.

class SupportsMixture: An object that decomposes into a probability distribution of unitaries.

class SupportsParameterization: An object that can be parameterized by Symbols and resolved

class SupportsPauliExpansion: An object that knows its expansion in the Pauli basis.

class SupportsPhase: An effect that can be phased around the Z axis of target qubits.

class SupportsQasm: An object that can be turned into QASM code.

class SupportsQasmWithArgs: An object that can be turned into QASM code.

class SupportsQasmWithArgsAndQubits: An object that can be turned into QASM code if it knows its qubits.

class SupportsTraceDistanceBound: An effect with known bounds on how easy it is to detect.

class SupportsUnitary: An object that may be describable by a unitary matrix.

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

class Sweep: A sweep is an iterator over ParamResolvers.

class SymmetricalQidPair

class SynchronizeTerminalMeasurements: Move measurements to the end of the circuit.

class TaggedOperation: Operation annotated with a set of Tags.

class TextDiagramDrawer: A utility class for creating simple text diagrams.

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

class ThreeQubitGate: THIS CLASS IS DEPRECATED.

class TiltedSquareLattice: A grid lattice rotated 45-degrees.

class Timestamp: A location in time with picosecond accuracy.

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

class TwoQubitGate: THIS CLASS IS DEPRECATED.

class TwoQubitInteractionHeatmap: Visualizing interactions between neighboring qubits on a 2D grid.

class Unique: A wrapper for a value that doesn't compare equal to other instances.

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.

class ZerosSampler: A dummy sampler for testing. Immediately returns zeroes.

class Zip: Zip product (direct sum) of one or more sweeps.

## 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.

KET_IMAG(...): The |i⟩ State

KET_MINUS(...): The |-⟩ State

KET_MINUS_IMAG(...): The |-i⟩ State

KET_ONE(...): The |1⟩ State

KET_PLUS(...): The |+⟩ State

KET_ZERO(...): The |0⟩ State

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.

act_on(...): Applies an action to a state argument.

all_near_zero(...): Checks if the tensor's elements are all near zero.

all_near_zero_mod(...): Checks if the tensor's elements are all near multiples of the period.

allclose_up_to_global_phase(...): Determines if a ~= b * exp(i t) for some t.

alternative(...): A decorator indicating an abstract method with an alternative default

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

apply_channel(...): High performance evolution under a channel evolution.

apply_matrix_to_slices(...): Left-multiplies an NxN matrix onto N slices of a numpy array.

apply_mixture(...): High performance evolution under a mixture of unitaries evolution.

apply_unitaries(...): Apply a series of unitaries onto a state tensor.

apply_unitary(...): High performance left-multiplication of a unitary effect onto a tensor.

approx_eq(...): Approximately compares two objects.

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

axis_angle(...): Decomposes a single-qubit unitary into axis, angle, and global phase.

bidiagonalize_real_matrix_pair_with_symmetric_products(...): Finds orthogonal matrices that diagonalize both mat1 and mat2.

bidiagonalize_unitary_with_special_orthogonals(...): Finds orthogonal matrices L, R such that L @ matrix @ R is diagonal.

big_endian_bits_to_int(...): Returns the big-endian integer specified by the given bits.

big_endian_digits_to_int(...): Returns the big-endian integer specified by the given digits and base.

big_endian_int_to_bits(...): Returns the big-endian bits of an integer.

big_endian_int_to_digits(...): Separates an integer into big-endian digits.

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

bloch_vector_from_state_vector(...): Returns the bloch vector of a qubit.

block_diag(...): Concatenates blocks into a block diagonal matrix.

canonicalize_half_turns(...): Wraps the input into the range (-1, +1].

choi_to_kraus(...): Returns a Kraus representation of a channel with given Choi matrix.

choi_to_superoperator(...): Returns the superoperator matrix of a quantum channel specified via the Choi matrix.

chosen_angle_to_canonical_half_turns(...): Returns a canonicalized half_turns based on the given arguments.

chosen_angle_to_half_turns(...): Returns a half_turns value based on the given arguments.

circuit_diagram_info(...): Requests information on drawing an operation in a circuit diagram.

commutes(...): Determines whether two values commute.

compute_cphase_exponents_for_fsim_decomposition(...): Returns intervals of CZPowGate exponents valid for FSim decomposition.

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

dataclass_json_dict(...): Return a dictionary suitable for _jsondict from a dataclass.

decompose(...): Recursively decomposes a value into cirq.Operations meeting a criteria.

decompose_clifford_tableau_to_operations(...): Decompose an n-qubit Clifford Tableau into a list of one/two qubit operations.

decompose_cphase_into_two_fsim(...): Decomposes CZPowGate into two FSimGates.

decompose_multi_controlled_rotation(...): Implements action of multi-controlled unitary gate.

decompose_multi_controlled_x(...): Implements action of multi-controlled Pauli X gate.

decompose_once(...): Decomposes a value into operations, if possible.

decompose_once_with_qubits(...): Decomposes a value into operations on the given qubits.

decompose_two_qubit_interaction_into_four_fsim_gates(...): Decomposes operations into an FSimGate near theta=pi/2, phi=0.

deconstruct_single_qubit_matrix_into_angles(...): Breaks down a 2x2 unitary into more useful ZYZ angle parameters.

definitely_commutes(...): Determines whether two values definitely commute.

density_matrix(...): Create a QuantumState object from a density matrix.

density_matrix_from_state_vector(...): Returns the density matrix of the state vector.

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

diagonalize_real_symmetric_and_sorted_diagonal_matrices(...): Returns an orthogonal matrix that diagonalizes both given matrices.

diagonalize_real_symmetric_matrix(...): Returns an orthogonal matrix that diagonalizes the given matrix.

dict_to_product_sweep(...): Cartesian product of sweeps from a dictionary.

dict_to_zip_sweep(...): Zip product of sweeps from a dictionary.

dirac_notation(...): Returns the state vector as a string in Dirac notation.

dot(...): Computes the dot/matrix product of a sequence of values.

draw_gridlike(...): Draw a grid-like graph using Matplotlib.

draw_placements(...): Draw a visualization of placements from small_graph onto big_graph using Matplotlib.

entanglement_fidelity(...): Returns entanglement fidelity of a given quantum channel.

equal_up_to_global_phase(...): Determine whether two objects are equal up to global phase.

estimate_parallel_single_qubit_readout_errors(...): Estimate single qubit readout error using parallel operations.

estimate_single_qubit_readout_errors(...): Estimate single-qubit readout error.

expand_matrix_in_orthogonal_basis(...): Computes coefficients of expansion of m in basis.

eye_tensor(...): Returns an identity matrix reshaped into a tensor.

fidelity(...): Fidelity of two quantum states.

final_density_matrix(...): Returns the density matrix resulting from simulating the circuit.

final_state_vector(...): Returns the state vector resulting from acting operations on a state.

flatten(...): Creates a copy of val with any symbols or expressions replaced with

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.

flatten_with_params(...): Creates a copy of val with any symbols or expressions replaced with

flatten_with_sweep(...): Creates a copy of val with any symbols or expressions replaced with

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

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

generate_boixo_2018_supremacy_circuits_v2(...): Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2.

generate_boixo_2018_supremacy_circuits_v2_bristlecone(...): Generates Google Random Circuits v2 in Bristlecone.

generate_boixo_2018_supremacy_circuits_v2_grid(...): Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2.

get_placements(...): Get 'placements' mapping small_graph nodes onto those of big_graph.

get_state_histogram(...): Computes a state histogram from a single result with repetitions.

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

has_kraus(...): Returns whether the value has a Kraus representation.

has_mixture(...): Returns whether the value has a mixture representation.

has_stabilizer_effect(...): Returns whether the input has a stabilizer effect.

has_unitary(...): Determines whether the value has a unitary effect.

hilbert_schmidt_inner_product(...): Computes Hilbert-Schmidt inner product of two matrices.

hog_score_xeb_fidelity_from_probabilities(...): XEB fidelity estimator based on normalized HOG score.

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

integrated_histogram(...): Plot the integrated histogram for an array of data.

inverse(...): Returns the inverse val**-1 of the given value, if defined.

is_cptp(...): Determines if a channel is completely positive trace preserving (CPTP).

is_diagonal(...): Determines if a matrix is a approximately diagonal.

is_hermitian(...): Determines if a matrix is approximately Hermitian.

is_measurement(...): Determines whether or not the given value is a measurement (or contains one).

is_native_neutral_atom_gate(...)

is_native_neutral_atom_op(...)

is_negligible_turn(...)

is_normal(...): Determines if a matrix is approximately normal.

is_orthogonal(...): Determines if a matrix is approximately orthogonal.

is_parameterized(...): Returns whether the object is parameterized with any Symbols.

is_special_orthogonal(...): Determines if a matrix is approximately special orthogonal.

is_special_unitary(...): Determines if a matrix is approximately unitary with unit determinant.

is_unitary(...): Determines if a matrix is approximately unitary.

json_serializable_dataclass(...): Create a dataclass that supports JSON serialization.

kak_canonicalize_vector(...): Canonicalizes an XX/YY/ZZ interaction by swap/negate/shift-ing axes.

kak_decomposition(...): Decomposes a 2-qubit unitary into 1-qubit ops and XX/YY/ZZ interactions.

kak_vector(...): Compute the KAK vectors of one or more two qubit unitaries.

kraus(...): Returns a list of matrices describing the channel for the given value.

kraus_to_channel_matrix(...): THIS FUNCTION IS DEPRECATED.

kraus_to_choi(...): Returns the unique Choi matrix corresponding to a Kraus representation of a channel.

kraus_to_superoperator(...): Returns the matrix representation of the linear map with given Kraus operators.

kron(...): Computes the kronecker product of a sequence of values.

kron_bases(...): Creates tensor product of bases.

kron_factor_4x4_to_2x2s(...): Splits a 4x4 matrix U = kron(A, B) into A, B, and a global factor.

kron_with_controls(...): Computes the kronecker product of a sequence of values and control tags.

least_squares_xeb_fidelity_from_expectations(...): Least squares fidelity estimator.

least_squares_xeb_fidelity_from_probabilities(...): Least squares fidelity estimator with observable based on probabilities.

linear_xeb_fidelity(...): Estimates XEB fidelity from one circuit using linear estimator.

linear_xeb_fidelity_from_probabilities(...): Linear XEB fidelity estimator.

log_xeb_fidelity(...): Estimates XEB fidelity from one circuit using logarithmic estimator.

log_xeb_fidelity_from_probabilities(...): Logarithmic XEB fidelity estimator.

map_eigenvalues(...): Applies a function to the eigenvalues of a matrix.

match_global_phase(...): Phases the given matrices so that they agree on the phase of one entry.

matrix_commutes(...): Determines if two matrices approximately commute.

matrix_from_basis_coefficients(...): Computes linear combination of basis vectors with given coefficients.

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

measure_density_matrix(...): Performs a measurement of the density matrix in the computational basis.

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

measure_state_vector(...): Performs a measurement of the state in the computational basis.

measurement_key_name(...): Get the single measurement key for the given value.

measurement_key_names(...): Gets the measurement key strings of measurements within the given value.

measurement_key_obj(...): Get the single measurement key object for the given value.

measurement_key_objs(...): Gets the measurement key objects of measurements within the given value.

merge_single_qubit_gates_into_phased_x_z(...): Canonicalizes runs of single-qubit rotations in a circuit.

merge_single_qubit_gates_into_phxz(...): Canonicalizes runs of single-qubit rotations in a circuit.

mixture(...): Return a sequence of tuples representing a probabilistic unitary.

ms(...): Args:

mul(...): Returns lhs * rhs, or else a default if the operator is not implemented.

num_cnots_required(...): Returns the min number of CNOT/CZ gates required by a two-qubit unitary.

num_qubits(...): Returns the number of qubits, qudits, or qids val operates on.

obj_to_dict_helper(...): Construct a dictionary containing attributes from obj

one_hot(...): Returns a numpy array with all 0s and a single non-zero entry(default 1).

operation_to_channel_matrix(...): THIS FUNCTION IS DEPRECATED.

operation_to_choi(...): Returns the unique Choi matrix associated with an operation .

operation_to_superoperator(...): Returns the matrix representation of an operation in standard basis.

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

parameter_names(...): Returns parameter names for this object.

parameter_symbols(...): Returns parameter symbols for this object.

partial_trace(...): Takes the partial trace of a given tensor.

partial_trace_of_state_vector_as_mixture(...): Returns a mixture representing a state vector with only some qubits kept.

pauli_expansion(...): Returns coefficients of the expansion of val in the Pauli basis.

phase_by(...): Returns a phased version of the effect.

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

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

pow(...): Returns val**factor of the given value, if defined.

pow_pauli_combination(...): Computes non-negative integer power of single-qubit Pauli combination.

qasm(...): Returns QASM code for the given value, if possible.

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

qid_shape(...): Returns a tuple describing the number of quantum levels of each

quantum_state(...): Create a QuantumState object from a state-like object.

quil(...): Returns the QUIL code for the given value.

quirk_json_to_circuit(...): Constructs a Cirq circuit from Quirk's JSON format.

quirk_url_to_circuit(...): Parses a Cirq circuit out of a Quirk URL.

read_json(...): Read a JSON file that optionally contains cirq objects.

read_json_gzip(...)

reflection_matrix_pow(...): Raises a matrix with two opposing eigenvalues to a power.

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

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

resolve_parameters(...): Resolves symbol parameters in the effect using the param resolver.

resolve_parameters_once(...): Performs a single parameter resolution step using the param resolver.

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}.

sample(...): Simulates sampling from the given circuit.

sample_density_matrix(...): Samples repeatedly from measurements in the computational basis.

sample_state_vector(...): Samples repeatedly from measurements in the computational basis.

sample_sweep(...): Runs the supplied Circuit, mimicking quantum hardware.

scatter_plot_normalized_kak_interaction_coefficients(...): Plots the interaction coefficients of many two-qubit operations.

single_qubit_matrix_to_gates(...): Implements a single-qubit operation with few gates.

single_qubit_matrix_to_pauli_rotations(...): Implements a single-qubit operation with few rotations.

single_qubit_matrix_to_phased_x_z(...): Implements a single-qubit operation with a PhasedX and Z gate.

single_qubit_matrix_to_phxz(...): Implements a single-qubit operation with a PhasedXZ gate.

single_qubit_op_to_framed_phase_form(...): Decomposes a 2x2 unitary M into U^-1 * diag(1, r) * U * diag(g, g).

slice_for_qubits_equal_to(...): Returns an index corresponding to a desired subset of an np.ndarray.

so4_to_magic_su2s(...): Finds 2x2 special-unitaries A, B where mat = Mag.H @ kron(A, B) @ Mag.

state_vector_to_probabilities(...)

stratified_circuit(...): Repacks avoiding simultaneous operations with different classes.

sub_state_vector(...): Attempts to factor a state vector into two parts and return one of them.

superoperator_to_choi(...): Returns the Choi matrix of a quantum channel specified via the superoperator matrix.

superoperator_to_kraus(...): Returns a Kraus representation of a channel specified via the superoperator matrix.

targeted_conjugate_about(...): Conjugates the given tensor about the target tensor.

targeted_left_multiply(...): Left-multiplies the given axes of the target tensor by the given matrix.

three_qubit_matrix_to_operations(...): Returns operations for a 3 qubit unitary.

to_json(...): Write a JSON file containing a representation of obj.

to_json_gzip(...)

to_resolvers(...): Convert a Sweepable to a list of ParamResolvers.

to_special(...): Converts a unitary matrix to a special unitary matrix.

to_sweep(...): Converts the argument into a <a href="./cirq/study/Sweep"><code>cirq.Sweep</code></a>.

to_sweeps(...): Converts a Sweepable to a list of Sweeps.

to_valid_density_matrix(...): Verifies the density_matrix_rep is valid and converts it to ndarray form.

to_valid_state_vector(...): Verifies the state_rep is valid and converts it to ndarray form.

trace_distance_bound(...): Returns a maximum on the trace distance between this effect's input

trace_distance_from_angle_list(...): Given a list of arguments of the eigenvalues of a unitary matrix,

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

two_qubit_matrix_to_diagonal_and_operations(...): Decomposes a 2-qubit unitary to a diagonal and the remaining operations.

two_qubit_matrix_to_ion_operations(...): Decomposes a two-qubit operation into MS/single-qubit rotation gates.

two_qubit_matrix_to_operations(...): Decomposes a two-qubit operation into Z/XY/CZ gates.

two_qubit_matrix_to_sqrt_iswap_operations(...): Decomposes a two-qubit operation into ZPow/XPow/YPow/sqrt-iSWAP gates.

unitary(...): Returns a unitary matrix describing the given value.

unitary_eig(...): Gives the guaranteed unitary eigendecomposition of a normal matrix.

validate_density_matrix(...): Checks that the given density matrix is valid.

validate_indices(...): Validates that the indices have values within range of num_qubits.

validate_mixture(...): Validates that the mixture's tuple are valid probabilities.

validate_normalized_state_vector(...): Checks that the given state vector is valid.

validate_probability(...): Validates that a probability is between 0 and 1 inclusively.

validate_qid_shape(...): Validates the size of the given state_vector against the given shape.

value_equality(...): Implements eq/ne/hash via a _value_equalityvalues method.

von_neumann_entropy(...): Calculates the von Neumann entropy of a quantum state in bits.

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

with_key_path(...): Adds the path to the target's measurement keys.

with_measurement_key_mapping(...): Remaps the target's measurement keys according to the provided key_map.

xeb_fidelity(...): Estimates XEB fidelity from one circuit using user-supplied estimator.

## Type Aliases

CIRCUIT_LIKE: A circuits.Circuit or a value that can be trivially converted into it:

DURATION_LIKE: A cirq.Duration or value that can trivially converted to one.

NOISE_MODEL_LIKE: A cirq.NoiseModel or a value that can be trivially converted into one.

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.

ParamDictType: Dictionary from symbols to values.

ParamResolverOrSimilarType: Something that can be used to turn parameters into values.

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

QUANTUM_STATE_LIKE: An object representing a quantum state.

QubitOrderOrList: Specifies a qubit ordering.

STATE_VECTOR_LIKE: An object representing a state vector.

Sweepable: An object or collection of objects representing a parameter sweep.

TParamKey: A parameter that a parameter resolver may map to a value.

TParamVal: A value that a parameter resolver may return for a parameter.

CONTROL_TAG Instance of numpy.ndarray

A special indicator value for cirq.kron_with_controls.

This value is a stand-in for "control operations on the other qubits based
on the value of this qubit", which otherwise doesn't have a proper matrix.


DEFAULT_RESOLVERS [<function _lazy_resolver.<locals>.json_resolver at 0x7fef5c7460e0>, <function _lazy_resolver.<locals>.json_resolver at 0x7fef504613b0>, <function _lazy_resolver.<locals>.json_resolver at 0x7fef5d60ed40>, <function _lazy_resolver.<locals>.json_resolver at 0x7fef5040e7a0>]
MEASUREMENT_KEY_SEPARATOR ':'
NO_NOISE Instance of cirq.devices.noise_model._NoNoiseModel

The trivial noise model with no effects.

This is the noise model used when a NOISE_MODEL_LIKE noise parameter is set to None.

PAULI_BASIS

{
'I': array([[1., 0.],
[0., 1.]]),
'X': array([[0., 1.],
[1., 0.]]),
'Y': array([[ 0.+0.j, -0.-1.j],
[ 0.+1.j,  0.+0.j]]),
'Z': array([[ 1.,  0.],
[ 0., -1.]])
}


The four Pauli matrices (including identity) keyed by character.

PAULI_STATES [cirq.X.basis[+1], cirq.X.basis[-1], cirq.Y.basis[+1], cirq.Y.basis[-1], cirq.Z.basis[+1], cirq.Z.basis[-1]]

All one-qubit states stabalized by the pauli operators.

UNCONSTRAINED_DEVICE Instance of cirq.devices.unconstrained_device._UnconstrainedDevice

A device with no constraints on operations or qubits.

UnitSweep Instance of cirq.study.sweeps._Unit

The singleton sweep with no parameters.

version '0.13.1'

[{ "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" }]