mimiqcircuits.operations.gates.generalized.diffusion¶
Grover diffusion operator.
Classes
|
Grover's diffusion operator on |
- class Diffusion(*args)[source]¶
Bases:
GateGrover’s diffusion operator on
num_qubitsqubits.Implements the unitary
\[H^{\otimes n} \left(1 - 2 |0^n\rangle\langle 0^n|\right) H^{\otimes n}\]Diffusion()with no arguments returns a lazy expression that takes the number of qubits later. The gate has no matrix representation:matrix()raisesNotImplementedError.- Parameters:
num_qubits (int) – Number of qubits, at least 1.
- Raises:
ValueError – If
num_qubitsis not an integer or is less than 1, or more than one argument is given.
Examples
>>> from mimiqcircuits import * >>> c = Circuit() >>> c.push(Diffusion(2), 1, 2) 3-qubit circuit with 1 instruction: └── Diffusion @ q[1:2] >>> Diffusion(2).decompose() 2-qubit circuit with 5 instructions: ├── RY((1/2)*pi) @ q[0] ├── RY((1/2)*pi) @ q[1] ├── CZ @ q[0], q[1] ├── RY((-1/2)*pi) @ q[0] └── RY((-1/2)*pi) @ q[1]