Skip to content

Commit

Permalink
added fourier transform to generate
Browse files Browse the repository at this point in the history
  • Loading branch information
akissinger committed Aug 14, 2024
1 parent f4de44c commit 0a001f7
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 772 deletions.
15 changes: 15 additions & 0 deletions pyzx/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"phase_poly",
"phase_poly_approximate",
"phase_poly_from_gadgets",
"qft",
]

import random
Expand Down Expand Up @@ -706,3 +707,17 @@ def build_random_parity_map(qubits: int, n_cnots: int, circuit=None) -> MatLike:
for c in circuit:
c.row_add(gate.control, gate.target)
return matrix.data


def qft(qubits: int) -> Circuit:
"""Returns a quantum Fourier transform circuit
This returns the unoptimised Fourier transform circuit. This is the version with O(n^2) gates
which reverses the order of logical qubits."""
c = Circuit(qubits)

for i in range(qubits):
c.add_gate('H', i)
for j in range(i+1, qubits):
c.add_gate('CPhase', j, i, Fraction(1, 2**(j-i+1)))
return c
863 changes: 91 additions & 772 deletions scratchpads/ak2.ipynb

Large diffs are not rendered by default.

0 comments on commit 0a001f7

Please sign in to comment.