양자 컴파일러를 만들다.일곱

개요


양자 컴파일러를 만들다.
연습문제, 3비트 가법기, 해 봤어요.

코드를 쓰다.

make 18
in 0 5
wire 6 13
xor 0 3 14
and 0 3 6
xor 1 4 7
and 1 4 8
xor 6 7 15
and 6 7 9
or 8 9 10
xor 2 5 11
and 2 5 12
xor 10 11 16
and 10 11 13
or 12 13 17
out 14 17

컴파일 결과

from blueqat import Circuit

print (Circuit(18).h[ : 6].cx[0, 14].cx[3, 14].ccx[0, 3, 6].cx[1, 7].cx[4, 7].ccx[1, 4, 8].cx[6, 15].cx[7, 15].ccx[6, 7, 9].ccx[8, 9, 10].cx[8, 10].cx[9, 10].cx[2, 11].cx[5, 11].ccx[2, 5, 12].cx[10, 16].cx[11, 16].ccx[10, 11, 13].ccx[12, 13, 17].cx[12, 17].cx[13, 17].m[ : ].run(shots = 1000))


성과물


진리치표에서 확인하다.



성과물


회로도를 통해 확인하다.



성과물


실행 결과



Counter({
'010001010001000110': 25, 
'011100010001001110': 23, 
'110011001011011001': 22, 
'100110110110000010': 22, 
'111011001010101011': 21, 
'010010001010000010': 21, 
'011101010000101101': 21, 
'011111001010101011': 21, 
'010000010000000100': 21, 
'110111101011010101': 20, 
'110100110110000010': 20, 
'110001010001001110': 20,
'100010010000001100': 19, 
'111101110110100011': 19, 
'010101010001001110': 19, 
'101101100000100101': 19, 
'000000000000000000': 19, 
'111110101011010101': 19, 
'011110001011011001': 18, 
'100100100000000100': 18, 
'111010001011011001': 18, 
'010110001010001010': 18, 
'111100110111010001': 18, 
'100101100001000110': 18, 
'111111101010100111': 17, 
'110000010000001100': 17, 
'011001010000100101': 17, 
'000101000001001010': 16, 
'001110010001001110': 16, 
'001100000001001010': 16, 
'010011001011010001': 16, 
'001000000001000010': 16, 
'110101110111010001': 16, 
'000110010000001100': 15, 
'011011001010100011': 15, 
'101111110110100011': 15, 
'000111010001001110': 14, 
'100011010001001110': 14, 
'011010001011010001': 14, 
'001101000000101001': 14, 
'101010010001001110': 14, 
'100000000000001000': 13, 
'001011010000100101': 13, 
'100111110111010001': 13, 
'111000010001001110': 13, 
'001111010000101101': 13, 
'101110110111010001': 13, 
'000010010000000100': 12, 
'010100010000001100': 12, 
'001010010001000110': 12, 
'101000000001001010': 12, 
'000001000001000010': 12,
'110010001010001010': 12, 
'011000010001000110': 12, 
'100001000001001010': 12, 
'101001000000101001': 11, 
'000011010001000110': 11, 
'111001010000101101': 11, 
'000100000000001000': 11, 
'101100100001000110': 10, 
'010111001011011001': 10, 
'101011010000101101': 8, 
'110110101010000110': 8, 
'001001000000100001': 5
})


이상.

좋은 웹페이지 즐겨찾기