LoginSignup
1
0

More than 1 year has passed since last update.

cirqで量子フーリエ変換(QFT)

Last updated at Posted at 2022-09-30

$$
QFT |x> = \frac{1}{2^{n/2}} \sum_{y=0}^{2^n-1} e^{2 \pi iyx / 2^n} |y>
$$

$|x_1>$ = -H-CR2-CR3-..-CRn-----------------
$|x_2>$ = ------------------H-CR2--..----------
.
.
$|x_{n-1}>$ = ---------------------..--H-CR2---
$|x_n>$ = -------------------------..--------H-

import cirq
import random
import matplotlib.pyplot as plt
import numpy as np
def make_qft(qubits):
    qreg = list(qubits)
    while len(qreg) > 0:
        q_head = qreg.pop(0)
        yield cirq.H(q_head)
        for i, qubit in enumerate(qreg):
            yield (cirq.CZ **(1 / 2 ** (i + 1)))(qubit, q_head)
qubits = cirq.LineQubit.range(4)
qft = cirq.Circuit(make_qft(qubits))
print(qft)

image.png


▼ ワンコインAI無料お試し

▼ DeepRecommendから限定情報を受け取る

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0