qml.pow¶
- pow(base, z=1, lazy=True, id=None)[source]¶
Raise an Operator to a power.
- Parameters
base (Operator) – the operator to be raised to a power
z (float) – the exponent (default value is 1)
- Keyword Arguments
lazy=True (bool) – In lazy mode, all operations are wrapped in a
Pow
class and handled later. Iflazy=False
, operation-specific simplifications are first attempted.id (str) – custom label given to an operator instance, can be useful for some applications where the instance has to be identified
- Returns
Operator
Note
This operator supports a batched base, a batched coefficient and a combination of both:
>>> op = qml.pow(qml.RX([1, 2, 3], wires=0), z=4) >>> qml.matrix(op).shape (3, 2, 2) >>> op = qml.pow(qml.RX(1, wires=0), z=[1, 2, 3]) >>> qml.matrix(op).shape (3, 2, 2) >>> op = qml.pow(qml.RX([1, 2, 3], wires=0), z=[4, 5, 6]) >>> qml.matrix(op).shape (3, 2, 2)
But it doesn’t support batching of operators:
>>> op = qml.pow([qml.RX(1, wires=0), qml.RX(2, wires=0)], z=4) AttributeError: 'list' object has no attribute 'name'
Example
>>> qml.pow(qml.X(0), 0.5) X(0)**0.5 >>> qml.pow(qml.X(0), 0.5, lazy=False) SX(wires=[0]) >>> qml.pow(qml.X(0), 0.1, lazy=False) X(0)**0.1 >>> qml.pow(qml.X(0), 2, lazy=False) I(0)
Lazy behaviour can also be accessed via
op ** z
.
code/api/pennylane.pow
Download Python script
Download Notebook
View on GitHub