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.

google module: Classes for working with Google's Quantum Engine API.

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

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

ionq module

json_resolver_cache module

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.

pasqal module: Devices, qubits, and sampler for Pasqal's neutrali atom device.

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 ActOnCliffordTableauArgs: State and context for an operation acting on a clifford tableau.

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 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 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 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 GateOperation: An application of a gate to a sequence of qubits.

class GeneralizedAmplitudeDampingChannel: Dampen qubit amplitudes through non ideal dissipation.

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 LineQid: A qid on a 1d lattice with nearest-neighbor connectivity.

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

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 MergeInteractions: Combines series of adjacent one and two-qubit gates operating on a pair

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

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 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 ParallelGateOperation: An application of several copies of a gate to a group of qubits.

class ParamResolver: Resolves parameters to actual values.

class Pauli: Represents the Pauli gates.

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

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 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 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 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 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 StateVectorMixin: A mixin that provide methods for objects that have a state vector.

class StateVectorSimulatorState

class StateVectorStepResult: Results of a step of a SimulatesIntermediateState.

class StateVectorTrialResult: A SimulationTrialResult that includes the StateVectorMixin methods.

class StepResult: Results of a step of a SimulatesIntermediateState.

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

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 SupportsChannel: An object that may be describable as a quantum channel.

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 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 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: A gate that must be applied to exactly three qubits.

class Timestamp: A location in time with picosecond accuracy.

class TrialResult: THIS CLASS IS DEPRECATED.

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

class TwoQubitGate: A gate that must be applied to exactly two qubits.

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.

CCX(...): The TOFFOLI gate.

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

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

CSWAP(...): The Controlled Swap gate.

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

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

FREDKIN(...): The Controlled Swap 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.

SWAP(...): The swap gate.

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

TOFFOLI(...): The TOFFOLI 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].

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

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

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

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.

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

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.

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

has_channel(...): Returns whether the value has a channel 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.

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

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.

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.

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_state_vector(...): Performs a measurement of the state in the computational basis.

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

measurement_keys(...): Gets the measurement keys 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).

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

plot_state_histogram(...): Plot the state histogram from a single result with repetitions.

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.

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.

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.

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.

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_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 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

NO_NOISE 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 The four Pauli matrices (including identity) keyed by character.
PAULI_STATES All one-qubit states stabalized by the pauli operators.
UNCONSTRAINED_DEVICE A device with no constraints on operations or qubits.
UnitSweep The singleton sweep with no parameters.
version '0.10.0'