ComposedGate

class ComposedGate[source]

Bases: Gate

A gate composed of other gates.

A ComposedGate provides methods for determining if the gate is differentiable or locally optimizable.

A ComposedGate is differentiable/locally optimizable if it inherits from the appropriate base class and all of its subgates (in either self.gate or self.gates) inherit from the base class.

For more complex behaviors, one can override is_differentiable() or is_locally_optimizable().

__init__()

Attributes

dim

The matrix dimension for this unitary.

name

The name of this gate.

num_params

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

num_qudits

The number of qudits this unitary can act on.

qasm_name

The qasm identifier for this gate.

radixes

The number of orthogonal states for each qudit.

Methods

check_parameters(params)

Check parameters are valid and match the unitary.

get_inverse()

Return the gate's inverse as a gate.

get_inverse_params([params])

Return the parameters that invert the gate.

get_qasm(params, location)

Returns the qasm string for this gate.

get_qasm_gate_def()

Returns a qasm gate definition block for this gate.

get_unitary([params])

Map real-valued params to a UnitaryMatrix.

is_constant()

Return true if this unitary doesn't take parameters.

is_differentiable()

Check if all sub gates are differentiable.

is_locally_optimizable()

Check if all sub gates are locally optimizable.

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.

with_all_frozen_params(params)

Freeze all of a gate's parameters so they don't change from optimization.

with_frozen_params(frozen_params)

Freeze some of a gate's parameters so they don't change from optimization.