qml.templates.subroutines.ArbitraryUnitary

ArbitraryUnitary(weights, wires)[source]

Implements an arbitrary unitary on the specified wires.

An arbitrary unitary on \(n\) wires is parametrized by \(4^n - 1\) independent real parameters. This templates uses Pauli word rotations to parametrize the unitary.

Example

ArbitraryUnitary can be used as a building block, e.g. to parametrize arbitrary two-qubit operations in a circuit:

@qml.template
def arbitrary_nearest_neighbour_interaction(weights, wires):
    qml.broadcast(unitary=ArbitraryUnitary, pattern="double", wires=wires, params=weights)
Parameters
  • weights (array[float]) – The angles of the Pauli word rotations, needs to have length \(4^n - 1\) where \(n\) is the number of wires the template acts upon.

  • wires (Iterable or Wires) – Wires that the template acts on. Accepts an iterable of numbers or strings, or a Wires object.