Slide 27
Slide 27 text
回路のマクロ登録
最近のBlueqatは、回路をマクロとして登録できるようになりました。
from blueqat import BlueqatGlobalSetting
def problem(c): # 問題の回路
return c.x[2].cx[2, 1].cx[1, 2].x[1].cx[1, 0].cx[0, 2].x[0]
def problem_dag(c): # 問題の回路を逆順にしたもの
return c.x[0].cx[0, 2].cx[1, 0].x[1].cx[1, 2].cx[2, 1].x[2]
BlueqatGlobalSetting.register_macro(‘problem’, problem)
BlueqatGlobalSetting.register_macro(‘problem_dag’, problem_dag)
def oracle(c): # 問題の回路を通して|111>のときのみ位相反転する回路
return c.problem().h[2].ccx[0, 1, 2].h[2].problem_dag()
BlueqatGlobalSetting.register_macro(‘oracle’, oracle)