qml.ops.op_math

This module contains classes and functions for Operator arithmetic.

Constructor Functions

adjoint(fn[, lazy])

Create the adjoint of an Operator or a function that applies the adjoint of the provided function.

ctrl(op, control[, control_values, work_wires])

Create a method that applies a controlled version of the provided op.

cond(condition[, true_fn, false_fn, elifs])

Quantum-compatible if-else conditionals — condition quantum operations on parameters such as the results of mid-circuit qubit measurements.

exp(op[, coeff, num_steps, id])

Take the exponential of an Operator times a coefficient.

sum(*summands[, grouping_type, method, id, lazy])

Construct an operator which is the sum of the given operators.

pow(base[, z, lazy, id])

Raise an Operator to a power.

prod(*ops[, id, lazy])

Construct an operator which represents the generalized product of the operators provided.

s_prod(scalar, operator[, lazy, id])

Construct an operator which is the scalar product of the given scalar and operator provided.

Symbolic Classes

Adjoint([base, id])

The Adjoint of an operator.

CompositeOp(*operands[, id, _pauli_rep])

A base class for operators that are composed of other operators.

Conditional(expr, then_op[, id])

A Conditional Operation.

Controlled(base, control_wires[, …])

Symbolic operator denoting a controlled operator.

ControlledOp(base, control_wires[, …])

Operation-specific methods and properties for the Controlled class.

Evolution(generator[, param, num_steps, id])

Create an exponential operator that defines a generator, of the form \(e^{-ix\hat{G}}\)

Exp(base[, coeff, num_steps, id])

A symbolic operator representing the exponential of a operator.

LinearCombination(coeffs, observables[, …])

Operator representing a linear combination of operators.

Pow([base, z, id])

Symbolic operator denoting an operator raised to a power.

Prod(*operands[, id, _pauli_rep])

Symbolic operator representing the product of operators.

Sum(*operands[, grouping_type, method, id, …])

Symbolic operator representing the sum of operators.

SProd(scalar, base[, id, _pauli_rep])

Arithmetic operator representing the scalar product of an operator with the given scalar.

SymbolicOp(base[, id])

Developer-facing base class for single-operator symbolic operators.

ScalarSymbolicOp(base, scalar[, id])

Developer-facing base class for single-operator symbolic operators that contain a scalar coefficient.

Controlled Operator Classes

ControlledQubitUnitary(U, control_wires, …)

Apply an arbitrary fixed unitary to wires with control from the control_wires.

CY(wires)

The controlled-Y operator

CZ(wires)

The controlled-Z operator

CH(wires)

The controlled-Hadamard operator

CCZ(wires)

CCZ (controlled-controlled-Z) gate.

CSWAP(wires)

The controlled-swap operator

CNOT(wires)

The controlled-NOT operator

Toffoli(wires)

Toffoli (controlled-controlled-X) gate.

MultiControlledX(control_wires, wires, …)

Apply a Pauli X gate controlled on an arbitrary computational basis state.

CRX(phi, wires[, id])

The controlled-RX operator

CRY(phi, wires[, id])

The controlled-RY operator

CRZ(phi, wires[, id])

The controlled-RZ operator

CRot(phi, theta, omega, wires[, id])

The controlled-Rot operator

ControlledPhaseShift(phi, wires[, id])

A qubit controlled phase shift.

Decompositions

one_qubit_decomposition(U, wire[, …])

Decompose a one-qubit unitary \(U\) in terms of elementary operations.

two_qubit_decomposition(U, wires)

Decompose a two-qubit unitary \(U\) in terms of elementary operations.

sk_decomposition(op, epsilon, *[, …])

Approximate an arbitrary single-qubit gate in the Clifford+T basis using the Solovay-Kitaev algorithm.

Control Decompositions

ctrl_decomp_zyz(target_operation, control_wires)

Decompose the controlled version of a target single-qubit operation

ctrl_decomp_bisect(target_operation, …)

Decompose the controlled version of a target single-qubit operation