Power
The power statement applies the unitary operation raised to some integer power, where the unitary is specified as a nested statement block.Syntax
- Python
- Native
Semantics
- If the statement block specifies the unitary operation on some quantum object, power applies .
- In the general case, the statement block is iterated over exponent times, but in some important special cases the operation is implemented more efficiently.
- Quantum variables declared outside the power statement and used inside its nested block must be initialized prior to it and remain initialized subsequently.
- Quantum variables declared inside the power statement, including in nested function calls, must be uninitialized at the end of the statement.
Examples
In the following examplepower is applied 3 times - to gate-level functions H and RX,
and to a user-defined function foo. It demonstrates both special and general treatment
of the power operation.
- Python
- Native
H cancel each other out, raising H to the power
of 5 is equivalent to applying H once. Raising RX with rotation angle to the
power 5 is equivalent to applying RX with rotation angle . However, raising
foo to the power 2 requires 2 consecutive applications of foo.
