LoginSignup
0
0

More than 3 years have passed since last update.

blueqatで量子ゲート その5

Posted at

概要

blueqatで量子ゲートやってみた。
3bit加算器作ってみた。

3bit加算器

3bit.jpg

サンプルコード

c0 = Circuit(18).h[0 : 3].h[3 : 6].cx[2, 17].cx[5, 17].ccx[2, 5, 6].cx[1, 7].cx[4, 7].ccx[1, 4, 8].cx[6, 16].cx[7, 16].ccx[6, 7, 9].ccx[9, 8, 10].cx[9, 10].cx[8, 10].cx[0, 11].cx[3, 11].ccx[0, 3, 12].cx[10, 15].cx[11, 15].ccx[10, 11, 13].ccx[13, 12, 14].cx[13, 14].cx[12, 14].m[:].run(shots = 100)
for cnt in c0:
  print("{} + {} = {}".format(int(cnt[0 : 3], 2), int(cnt[3 : 6], 2), int(cnt[14 : 18], 2)))

結果

1 + 7 = 8
0 + 7 = 7
1 + 5 = 6
0 + 0 = 0
1 + 4 = 5
5 + 5 = 10
5 + 7 = 12
5 + 0 = 5
0 + 6 = 6
6 + 6 = 12
4 + 0 = 4
5 + 4 = 9
2 + 2 = 4
2 + 1 = 3
2 + 6 = 8
6 + 3 = 9
7 + 2 = 9
2 + 0 = 2
0 + 4 = 4
4 + 5 = 9
3 + 7 = 10
1 + 3 = 4
2 + 5 = 7
4 + 2 = 6
0 + 3 = 3
3 + 4 = 7
7 + 1 = 8
7 + 4 = 11
5 + 2 = 7
2 + 7 = 9
0 + 5 = 5
1 + 0 = 1
4 + 4 = 8
6 + 0 = 6
0 + 1 = 1
6 + 1 = 7
7 + 7 = 14
3 + 6 = 9
4 + 3 = 7
6 + 4 = 10
2 + 3 = 5
5 + 3 = 8
7 + 6 = 13
3 + 0 = 3
7 + 0 = 7
6 + 5 = 11
1 + 6 = 7
6 + 7 = 13
7 + 5 = 12
4 + 1 = 5
3 + 2 = 5



以上。

0
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
0
0