mimiqcircuits.operations.utils

Operation utilities.

Functions

control_one_defined(n, op, cop[, ccop, c3op])

Return op controlled by n qubits, preferring named gates.

power_idempotent(op, pow)

Return op raised to pow for an operation that squares to the identity.

power_idempotent(op, pow)[source]

Return op raised to pow for an operation that squares to the identity.

The exponent is reduced modulo 2: even exponents give the identity on op.num_qubits qubits, odd exponents give op, and other values give a Power with the reduced exponent.

Raises:

ValueError – If the exponent is even and op acts on no qubits.

control_one_defined(n, op, cop, ccop=None, c3op=None)[source]

Return op controlled by n qubits, preferring named gates.

Returns cop, ccop or c3op for one, two or three controls when given, and Control(n, op) otherwise.