Operation

class Operation(gate, location, params=[])[source]

Bases: DifferentiableUnitary

An Operation groups together a gate, its parameters and location.

__init__(gate, location, params=[])[source]

Construct an operation.

Parameters:
  • gate (Gate) – The operation’s gate.

  • location (CircuitLocationLike) – The set of qudits this gate is applied to.

  • params (RealVector) – The parameters for the gate.

Raises:
  • ValueError – If gate’s size doesn’t match location’s length.

  • ValueError – If gate’s num_params doesn’t match params’s length.

Attributes

dim

The matrix dimension for this unitary.

gate

The operation's gate.

location

The qudit this operation is applied to.

num_params

The number of real parameters this unitary-valued function takes.

num_qudits

The number of qudits this unitary can act on.

params

The operation's parameters for its gate.

radixes

The number of orthogonal states for each qudit.

Methods

check_parameters(params)

Check parameters are valid and match the unitary.

get_grad([params])

Return the gradient for this operation.

get_inverse()

Return the operation's inverse operation.

get_qasm()

Return the qasm string for this operation.

get_unitary([params])

Return the unitary for this gate, see Unitary for more.

get_unitary_and_grad([params])

Return the unitary and gradient for this gate.

is_constant()

Return true if this unitary doesn't take parameters.

is_differentiable()

Check if operation is differentiable.

is_parameterized()

Return true if this unitary is parameterized.

is_qubit_only()

Return true if this unitary can only act on qubits.

is_qudit_only(radix)

Return true if this unitary can only act on radix-qudits.

is_qutrit_only()

Return true if this unitary can only act on qutrits.

is_self_inverse([params])

Checks whether the unitary is its own inverse.