qadence.draw
example plots
Mostly for quick, manual checking of correct plotting output.
from qadence import X , Y , kron
from qadence.draw import display
b = kron ( X ( 0 ), Y ( 1 ))
%3
a00d46440d5a4618a65eec8b76010f41
0
09acb688862e4243899cef325d666eed
X
a00d46440d5a4618a65eec8b76010f41--09acb688862e4243899cef325d666eed
acff06ea0abb4b0987b3884aea52503c
1
3d43413a22664715906000e70f9424e1
09acb688862e4243899cef325d666eed--3d43413a22664715906000e70f9424e1
b81a211225f14e16be62dbd1deea642a
359c8e817e9b4b7a8fc5b34d8bfbe7f3
Y
acff06ea0abb4b0987b3884aea52503c--359c8e817e9b4b7a8fc5b34d8bfbe7f3
359c8e817e9b4b7a8fc5b34d8bfbe7f3--b81a211225f14e16be62dbd1deea642a
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
121bc7651c8d45ae8e6c85bdbea0e073
0
9a5073e700dc4fbf8ba6622b59ec69e1
X
121bc7651c8d45ae8e6c85bdbea0e073--9a5073e700dc4fbf8ba6622b59ec69e1
417eb86ce1254c469e154251e836a8bb
Y
9a5073e700dc4fbf8ba6622b59ec69e1--417eb86ce1254c469e154251e836a8bb
2f60cf6560ff4e429c830b6d8457ad38
417eb86ce1254c469e154251e836a8bb--2f60cf6560ff4e429c830b6d8457ad38
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
daee64427fe64742b6ffc0167a86a5af
0
d5490a34a7b04ddca0f87247a2ef18c2
X
daee64427fe64742b6ffc0167a86a5af--d5490a34a7b04ddca0f87247a2ef18c2
77be95aa2afb411d997e51b90a2ace88
1
d8d372f9664b43bb8b1d19823dbb150d
d5490a34a7b04ddca0f87247a2ef18c2--d8d372f9664b43bb8b1d19823dbb150d
f4d25d58d71144768c876684f1844a7c
d8d372f9664b43bb8b1d19823dbb150d--f4d25d58d71144768c876684f1844a7c
5d242bcd040b4a9e84629c6c48882b01
dd6e9339ced34e689e668826492c8793
77be95aa2afb411d997e51b90a2ace88--dd6e9339ced34e689e668826492c8793
fa25b69293c94c91948b0a9724b2dca0
Y
dd6e9339ced34e689e668826492c8793--fa25b69293c94c91948b0a9724b2dca0
fa25b69293c94c91948b0a9724b2dca0--5d242bcd040b4a9e84629c6c48882b01
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_62f2753ce8e041e58c43bb0a070a3408
28f9ce3e367449639641c0b0f6e19665
0
e96e591a92ff42de88a06467737fa46c
28f9ce3e367449639641c0b0f6e19665--e96e591a92ff42de88a06467737fa46c
9ff01bf1d03c433399935a3529e8a58f
1
a29507d2f58d472fa479b8ebd971a21e
e96e591a92ff42de88a06467737fa46c--a29507d2f58d472fa479b8ebd971a21e
8ec39d8156f442f794c88fa882afa04a
13b144483db8423b80060d4a56b96389
AddBlock
9ff01bf1d03c433399935a3529e8a58f--13b144483db8423b80060d4a56b96389
9875a7995548476c80cb471b741b3edc
2
13b144483db8423b80060d4a56b96389--8ec39d8156f442f794c88fa882afa04a
c6a2aa77c9d6435483813ebb2567c883
8b7024e5cbdf49bf937a0e03b3a83584
9875a7995548476c80cb471b741b3edc--8b7024e5cbdf49bf937a0e03b3a83584
8b7024e5cbdf49bf937a0e03b3a83584--c6a2aa77c9d6435483813ebb2567c883
from qadence import CNOT , RX , HamEvo , X , Y , Z , chain , kron
rx = kron ( RX ( 3 , 0.5 ), RX ( 2 , "x" ))
rx . tag = "rx"
gen = chain ( Z ( i ) for i in range ( 4 ))
# `chain` puts things in sequence
block = chain (
kron ( X ( 0 ), Y ( 1 ), rx ),
CNOT ( 2 , 3 ),
HamEvo ( gen , 10 )
)
%3
cluster_68c1ce1d550045a79fb2f79ce36a5064
cluster_29ce94d9d66e413e8a5729f17c450ae5
rx
efe4e2e2e5064e369b0893c30e417028
0
dffcc76d03e445c28f768bd51922f622
X
efe4e2e2e5064e369b0893c30e417028--dffcc76d03e445c28f768bd51922f622
5505fe506e0747c7b557d40fcac99698
1
2d72b9c114a0478bbfa22591b7894a5f
dffcc76d03e445c28f768bd51922f622--2d72b9c114a0478bbfa22591b7894a5f
07a4ed02f49643329177a923dacf101c
2d72b9c114a0478bbfa22591b7894a5f--07a4ed02f49643329177a923dacf101c
3e74f8c7de5c4956822c58a8e03b5935
07a4ed02f49643329177a923dacf101c--3e74f8c7de5c4956822c58a8e03b5935
51f3bb05dede48e692e33485b504353b
a8766c358012499ab8d3b640875d36fb
Y
5505fe506e0747c7b557d40fcac99698--a8766c358012499ab8d3b640875d36fb
85952245ae4d45f183770cdc5a31ff18
2
0995d8ff23604284bec5aeb68175a9dc
a8766c358012499ab8d3b640875d36fb--0995d8ff23604284bec5aeb68175a9dc
de98f26c826c4a47a6a4c907527b4d36
HamEvo
0995d8ff23604284bec5aeb68175a9dc--de98f26c826c4a47a6a4c907527b4d36
de98f26c826c4a47a6a4c907527b4d36--51f3bb05dede48e692e33485b504353b
ed42d7b45a7f4034ba7cdca7cc5aa462
9db8936fa512456faf75d83d1e53364e
RX(x)
85952245ae4d45f183770cdc5a31ff18--9db8936fa512456faf75d83d1e53364e
70681761fc494aa0b03ec8adbcf5065d
3
3039236215ce494faae4d7b4548830ab
9db8936fa512456faf75d83d1e53364e--3039236215ce494faae4d7b4548830ab
ea90a92038d4432f92799f6474d7cb43
t = 10
3039236215ce494faae4d7b4548830ab--ea90a92038d4432f92799f6474d7cb43
ea90a92038d4432f92799f6474d7cb43--ed42d7b45a7f4034ba7cdca7cc5aa462
499c195ceaa7480fa383fced47123219
3234f502ea6b4f8c848a759323bd37bc
RX(0.5)
70681761fc494aa0b03ec8adbcf5065d--3234f502ea6b4f8c848a759323bd37bc
94b09d7e96d841b684a1ad919a0484a3
X
3234f502ea6b4f8c848a759323bd37bc--94b09d7e96d841b684a1ad919a0484a3
94b09d7e96d841b684a1ad919a0484a3--3039236215ce494faae4d7b4548830ab
a8af6dda8b0e470297d29bd434a82621
94b09d7e96d841b684a1ad919a0484a3--a8af6dda8b0e470297d29bd434a82621
a8af6dda8b0e470297d29bd434a82621--499c195ceaa7480fa383fced47123219
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_91530a6e1aea455baa66d80c63317cfe
HEA
cluster_b5dbdb9e031e452380340af850083f97
Tower Fourier FM
d296e989b5284aa9adc385a1c2ab9cef
0
1deaed6aa851427aa7c0a8681a8ad6b3
RX(1.0*phi)
d296e989b5284aa9adc385a1c2ab9cef--1deaed6aa851427aa7c0a8681a8ad6b3
ef05acee81514ee8acbedc78ed469426
1
f5d73f808fc14da2ba76cbcac35dcd1d
RX(theta₀)
1deaed6aa851427aa7c0a8681a8ad6b3--f5d73f808fc14da2ba76cbcac35dcd1d
203b380164254ac08738bb652c46bddb
RY(theta₄)
f5d73f808fc14da2ba76cbcac35dcd1d--203b380164254ac08738bb652c46bddb
96388d7bf23c469dbd005fab4c90b531
RX(theta₈)
203b380164254ac08738bb652c46bddb--96388d7bf23c469dbd005fab4c90b531
0492a2c6c1314f84b15e21e5716175f7
96388d7bf23c469dbd005fab4c90b531--0492a2c6c1314f84b15e21e5716175f7
edfbc908a93d49a183e2a358072f0654
0492a2c6c1314f84b15e21e5716175f7--edfbc908a93d49a183e2a358072f0654
312f40f24f5748e3ac56d7403a587aba
RX(theta₁₂)
edfbc908a93d49a183e2a358072f0654--312f40f24f5748e3ac56d7403a587aba
105611e675304dc1956f2c73e4f47e33
RY(theta₁₆)
312f40f24f5748e3ac56d7403a587aba--105611e675304dc1956f2c73e4f47e33
6f47e4256dc441b1b8f688a90ffe8d32
RX(theta₂₀)
105611e675304dc1956f2c73e4f47e33--6f47e4256dc441b1b8f688a90ffe8d32
959b9d02a0fa4e83ac11bfc06d37a1d7
6f47e4256dc441b1b8f688a90ffe8d32--959b9d02a0fa4e83ac11bfc06d37a1d7
bbedfda7ccf049f0a939bfaa14facc90
959b9d02a0fa4e83ac11bfc06d37a1d7--bbedfda7ccf049f0a939bfaa14facc90
d5204a012914439eaf5b292d84c8346c
bbedfda7ccf049f0a939bfaa14facc90--d5204a012914439eaf5b292d84c8346c
e73a8f81b87d4975915b5947659d2051
bc77ce435f684794834899afeea77ba5
RX(2.0*phi)
ef05acee81514ee8acbedc78ed469426--bc77ce435f684794834899afeea77ba5
185cc06e09c24021a48c712c59ec81fe
2
883ab2fef7374f69b45c114077430961
RX(theta₁)
bc77ce435f684794834899afeea77ba5--883ab2fef7374f69b45c114077430961
1430fa0630584faaa7c45e1eb11578c2
RY(theta₅)
883ab2fef7374f69b45c114077430961--1430fa0630584faaa7c45e1eb11578c2
fefb41ad9b0d4bfab94f0bd4691c32ea
RX(theta₉)
1430fa0630584faaa7c45e1eb11578c2--fefb41ad9b0d4bfab94f0bd4691c32ea
da0d03a17a30441cb6422f963a56f840
X
fefb41ad9b0d4bfab94f0bd4691c32ea--da0d03a17a30441cb6422f963a56f840
da0d03a17a30441cb6422f963a56f840--0492a2c6c1314f84b15e21e5716175f7
318131972f314dd982760e6cecdee648
da0d03a17a30441cb6422f963a56f840--318131972f314dd982760e6cecdee648
8d914ce911f54c17a05b9bb22d071522
RX(theta₁₃)
318131972f314dd982760e6cecdee648--8d914ce911f54c17a05b9bb22d071522
1cf76ebebcb848a58a0d5424015a5a3e
RY(theta₁₇)
8d914ce911f54c17a05b9bb22d071522--1cf76ebebcb848a58a0d5424015a5a3e
1bd639d7821f473ab238bf2c7887acfc
RX(theta₂₁)
1cf76ebebcb848a58a0d5424015a5a3e--1bd639d7821f473ab238bf2c7887acfc
1d35cb48ff7d45c78c8a634498b02262
X
1bd639d7821f473ab238bf2c7887acfc--1d35cb48ff7d45c78c8a634498b02262
1d35cb48ff7d45c78c8a634498b02262--959b9d02a0fa4e83ac11bfc06d37a1d7
3fb9a32ee0fc4db5a2abc53e27813f01
1d35cb48ff7d45c78c8a634498b02262--3fb9a32ee0fc4db5a2abc53e27813f01
3fb9a32ee0fc4db5a2abc53e27813f01--e73a8f81b87d4975915b5947659d2051
5e804212bfa048ccbf7733fe5f9f4f5c
9f5c6952ece54226b041bcb62a96bf95
RX(3.0*phi)
185cc06e09c24021a48c712c59ec81fe--9f5c6952ece54226b041bcb62a96bf95
6a70f057404c49b29fa49b62f0cc3109
3
f2b047aa370a434e9296a9d8f6fde316
RX(theta₂)
9f5c6952ece54226b041bcb62a96bf95--f2b047aa370a434e9296a9d8f6fde316
17f0efe8bde34620baeb02c20340f0a9
RY(theta₆)
f2b047aa370a434e9296a9d8f6fde316--17f0efe8bde34620baeb02c20340f0a9
d6c0816dfd1646f6904f4346f1a49114
RX(theta₁₀)
17f0efe8bde34620baeb02c20340f0a9--d6c0816dfd1646f6904f4346f1a49114
91bb516f49c044d6b950f843533c2bef
d6c0816dfd1646f6904f4346f1a49114--91bb516f49c044d6b950f843533c2bef
7a19588206a44b58b1453158d78ed827
X
91bb516f49c044d6b950f843533c2bef--7a19588206a44b58b1453158d78ed827
7a19588206a44b58b1453158d78ed827--318131972f314dd982760e6cecdee648
67dd3941e4df4dcf95bbd4ecabaad124
RX(theta₁₄)
7a19588206a44b58b1453158d78ed827--67dd3941e4df4dcf95bbd4ecabaad124
d605f5974c9b4be68380ee0047c42596
RY(theta₁₈)
67dd3941e4df4dcf95bbd4ecabaad124--d605f5974c9b4be68380ee0047c42596
7578f0c3f78f4fcd977c8050852ae0cc
RX(theta₂₂)
d605f5974c9b4be68380ee0047c42596--7578f0c3f78f4fcd977c8050852ae0cc
fda3fc31887745ab9fc8dd6ac2a8de36
7578f0c3f78f4fcd977c8050852ae0cc--fda3fc31887745ab9fc8dd6ac2a8de36
c02f19f491844055a1c30c4739a84cf7
X
fda3fc31887745ab9fc8dd6ac2a8de36--c02f19f491844055a1c30c4739a84cf7
c02f19f491844055a1c30c4739a84cf7--3fb9a32ee0fc4db5a2abc53e27813f01
c02f19f491844055a1c30c4739a84cf7--5e804212bfa048ccbf7733fe5f9f4f5c
68c3d8d9de644e89802fd95b6715e9ab
ed689f2d8929413585ccea8fb16d0e9e
RX(4.0*phi)
6a70f057404c49b29fa49b62f0cc3109--ed689f2d8929413585ccea8fb16d0e9e
1de75a7b85d04e39b579bfd96a09ca53
RX(theta₃)
ed689f2d8929413585ccea8fb16d0e9e--1de75a7b85d04e39b579bfd96a09ca53
859b7c63f6cf44aaa009fcf828bfb523
RY(theta₇)
1de75a7b85d04e39b579bfd96a09ca53--859b7c63f6cf44aaa009fcf828bfb523
d65479c9457a4eb3b89c49298de75872
RX(theta₁₁)
859b7c63f6cf44aaa009fcf828bfb523--d65479c9457a4eb3b89c49298de75872
d1eee458e3bc445c931b484d21452e38
X
d65479c9457a4eb3b89c49298de75872--d1eee458e3bc445c931b484d21452e38
d1eee458e3bc445c931b484d21452e38--91bb516f49c044d6b950f843533c2bef
0ddb4806e0e042a9a4e0db180191089e
d1eee458e3bc445c931b484d21452e38--0ddb4806e0e042a9a4e0db180191089e
27d2a37f5d1348db950ccaaf29fa70de
RX(theta₁₅)
0ddb4806e0e042a9a4e0db180191089e--27d2a37f5d1348db950ccaaf29fa70de
414b6848d40b4c1baea5196c675cfddb
RY(theta₁₉)
27d2a37f5d1348db950ccaaf29fa70de--414b6848d40b4c1baea5196c675cfddb
53a4435ba68c48f1bc2653e820b83e51
RX(theta₂₃)
414b6848d40b4c1baea5196c675cfddb--53a4435ba68c48f1bc2653e820b83e51
1449daab257b4bc1981fca52bbe3885a
X
53a4435ba68c48f1bc2653e820b83e51--1449daab257b4bc1981fca52bbe3885a
1449daab257b4bc1981fca52bbe3885a--fda3fc31887745ab9fc8dd6ac2a8de36
c2fb6ffaf8e243c197c8e6983dabd2b7
1449daab257b4bc1981fca52bbe3885a--c2fb6ffaf8e243c197c8e6983dabd2b7
c2fb6ffaf8e243c197c8e6983dabd2b7--68c3d8d9de644e89802fd95b6715e9ab
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_3ff90e4b80454c6fabf2869179773fb6
Obs.
cluster_80c0fe5d948e44e0a9e6564cdc0de409
cluster_4d4b3267ab3e43a391c6632e87e1e170
HEA
37347b1b38014412b9ecd7e4312f075e
0
b4daab62927b4edf907b47adce9b925f
RX(theta₀)
37347b1b38014412b9ecd7e4312f075e--b4daab62927b4edf907b47adce9b925f
6252fcc6f0ec4377a482fb8c7c104a17
1
452f68a3975a4097a6ee76b64e35b100
RY(theta₃)
b4daab62927b4edf907b47adce9b925f--452f68a3975a4097a6ee76b64e35b100
ad1184fd36bf4b2ba3185d80bded28ce
RX(theta₆)
452f68a3975a4097a6ee76b64e35b100--ad1184fd36bf4b2ba3185d80bded28ce
af6ce40d5b8c4526bc5e0e307fd61a71
ad1184fd36bf4b2ba3185d80bded28ce--af6ce40d5b8c4526bc5e0e307fd61a71
0ae63b78a36b443eb862f77278360b68
af6ce40d5b8c4526bc5e0e307fd61a71--0ae63b78a36b443eb862f77278360b68
de7c44a987f141ca9abb047bcfeed0e4
RX(theta₉)
0ae63b78a36b443eb862f77278360b68--de7c44a987f141ca9abb047bcfeed0e4
01af042632e44d4db957a061820cf76c
RY(theta₁₂)
de7c44a987f141ca9abb047bcfeed0e4--01af042632e44d4db957a061820cf76c
899948b94d9940a680fe1febb7b1b8a5
RX(theta₁₅)
01af042632e44d4db957a061820cf76c--899948b94d9940a680fe1febb7b1b8a5
685de9bb68da4874a80c00ed671ee363
899948b94d9940a680fe1febb7b1b8a5--685de9bb68da4874a80c00ed671ee363
0a9727db6f584ff2bb266b1020df9705
685de9bb68da4874a80c00ed671ee363--0a9727db6f584ff2bb266b1020df9705
b210cb10a6a748bfb1058fe8b99b67a1
0a9727db6f584ff2bb266b1020df9705--b210cb10a6a748bfb1058fe8b99b67a1
a49e4e9365284b0d8339077cb08a329a
b210cb10a6a748bfb1058fe8b99b67a1--a49e4e9365284b0d8339077cb08a329a
8aec05941a794f6bbb5e0dec581dd61e
08e96e99697245ddab209d1f9d2d2d3d
RX(theta₁)
6252fcc6f0ec4377a482fb8c7c104a17--08e96e99697245ddab209d1f9d2d2d3d
4b0ac100794a4166aa3c100a5a68f86c
2
65c4173163c14bbdb222ddf004147c08
RY(theta₄)
08e96e99697245ddab209d1f9d2d2d3d--65c4173163c14bbdb222ddf004147c08
622fa6af4a2d4b5694c0ce0d18d054da
RX(theta₇)
65c4173163c14bbdb222ddf004147c08--622fa6af4a2d4b5694c0ce0d18d054da
790841d86aa74829bc1f56a4df0dd654
X
622fa6af4a2d4b5694c0ce0d18d054da--790841d86aa74829bc1f56a4df0dd654
790841d86aa74829bc1f56a4df0dd654--af6ce40d5b8c4526bc5e0e307fd61a71
012b99a1fe054f35933ac6096effd44f
790841d86aa74829bc1f56a4df0dd654--012b99a1fe054f35933ac6096effd44f
aae7c9bb1b7f475aa33e26baa99fc2f4
RX(theta₁₀)
012b99a1fe054f35933ac6096effd44f--aae7c9bb1b7f475aa33e26baa99fc2f4
d44fc6b026d8432380ab9585b0a60a7f
RY(theta₁₃)
aae7c9bb1b7f475aa33e26baa99fc2f4--d44fc6b026d8432380ab9585b0a60a7f
26960d2abba34bbe9d2f8606bbe6f273
RX(theta₁₆)
d44fc6b026d8432380ab9585b0a60a7f--26960d2abba34bbe9d2f8606bbe6f273
5b7b5b3e18114713a8e3573e51cc4630
X
26960d2abba34bbe9d2f8606bbe6f273--5b7b5b3e18114713a8e3573e51cc4630
5b7b5b3e18114713a8e3573e51cc4630--685de9bb68da4874a80c00ed671ee363
d607382632a749d5bd92c693323ef94e
5b7b5b3e18114713a8e3573e51cc4630--d607382632a749d5bd92c693323ef94e
47244fcf35514322aa6defb519529240
AddBlock
d607382632a749d5bd92c693323ef94e--47244fcf35514322aa6defb519529240
47244fcf35514322aa6defb519529240--8aec05941a794f6bbb5e0dec581dd61e
e2c07102001e40a690b382094a2c7f4f
643a0920e212459385abd2d91b098af8
RX(theta₂)
4b0ac100794a4166aa3c100a5a68f86c--643a0920e212459385abd2d91b098af8
e8cd00321f354814b2d980387afad4a1
RY(theta₅)
643a0920e212459385abd2d91b098af8--e8cd00321f354814b2d980387afad4a1
f10c49bd5d8c4a29bd663782691f0ba9
RX(theta₈)
e8cd00321f354814b2d980387afad4a1--f10c49bd5d8c4a29bd663782691f0ba9
7201f8e7138549269f2da9013010e567
f10c49bd5d8c4a29bd663782691f0ba9--7201f8e7138549269f2da9013010e567
36a9fd3d1e1b47e18c9de8416b321351
X
7201f8e7138549269f2da9013010e567--36a9fd3d1e1b47e18c9de8416b321351
36a9fd3d1e1b47e18c9de8416b321351--012b99a1fe054f35933ac6096effd44f
a88a4e8796b1456db3ff664ac12e7f75
RX(theta₁₁)
36a9fd3d1e1b47e18c9de8416b321351--a88a4e8796b1456db3ff664ac12e7f75
bb0b6c1b2bc3446897ee68d37828f8ab
RY(theta₁₄)
a88a4e8796b1456db3ff664ac12e7f75--bb0b6c1b2bc3446897ee68d37828f8ab
0ffb3d2a57e24e66b2c52689ad178316
RX(theta₁₇)
bb0b6c1b2bc3446897ee68d37828f8ab--0ffb3d2a57e24e66b2c52689ad178316
c2271c3d114f450cb1088b3079f6551e
0ffb3d2a57e24e66b2c52689ad178316--c2271c3d114f450cb1088b3079f6551e
f1b68527fc6849ebb326a609d9302503
X
c2271c3d114f450cb1088b3079f6551e--f1b68527fc6849ebb326a609d9302503
f1b68527fc6849ebb326a609d9302503--d607382632a749d5bd92c693323ef94e
dc038862eab64f12a6a70b2265f8b395
f1b68527fc6849ebb326a609d9302503--dc038862eab64f12a6a70b2265f8b395
dc038862eab64f12a6a70b2265f8b395--e2c07102001e40a690b382094a2c7f4f
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
06e4e8e7c1064934a7ef3a56057e9313
0
f084e2a5b1ba4f1cb8a254277db3a5ef
06e4e8e7c1064934a7ef3a56057e9313--f084e2a5b1ba4f1cb8a254277db3a5ef
0455dd314c464b84b02989d907ad5e62
1
20e7f8bf5a214949bf438d7a2deb106a
ec331c50f2f0488e8d355556c65f5e81
f084e2a5b1ba4f1cb8a254277db3a5ef--ec331c50f2f0488e8d355556c65f5e81
809adcde008a47dd8a13f89635c78ae3
20e7f8bf5a214949bf438d7a2deb106a--809adcde008a47dd8a13f89635c78ae3
e7f150a6643741069bbffcf9a80ca125
1cb96cfc6490477d92a26f6c53d7fea6
809adcde008a47dd8a13f89635c78ae3--1cb96cfc6490477d92a26f6c53d7fea6
406afee553d94010b9ca3812c7c72a05
e7f150a6643741069bbffcf9a80ca125--406afee553d94010b9ca3812c7c72a05
e05ff08829164fe1a2dbab13766a741e
d77ff2e200244b9795982e6d51d52156
0455dd314c464b84b02989d907ad5e62--d77ff2e200244b9795982e6d51d52156
61e2b5f00e65487d957c9f151e944215
2
d77ff2e200244b9795982e6d51d52156--20e7f8bf5a214949bf438d7a2deb106a
5535f8404bae4097bfb3059587430375
ec331c50f2f0488e8d355556c65f5e81--5535f8404bae4097bfb3059587430375
ab0f89e5d6324a5cae43ecf902c14e2f
5535f8404bae4097bfb3059587430375--ab0f89e5d6324a5cae43ecf902c14e2f
ab0f89e5d6324a5cae43ecf902c14e2f--e05ff08829164fe1a2dbab13766a741e
5bc4249dd07e469c80c41c314ca3453a
fcca21a0adce489cb9d96f609ce1cd47
61e2b5f00e65487d957c9f151e944215--fcca21a0adce489cb9d96f609ce1cd47
c8b16280618e41cd905f6498b43e9b06
3
1736ee48597d40edb888b2fb3b5472be
fcca21a0adce489cb9d96f609ce1cd47--1736ee48597d40edb888b2fb3b5472be
936c034bc8474f5a98cf495726792b90
1736ee48597d40edb888b2fb3b5472be--936c034bc8474f5a98cf495726792b90
d965e908706f43b8b8de461070d14a18
936c034bc8474f5a98cf495726792b90--d965e908706f43b8b8de461070d14a18
d965e908706f43b8b8de461070d14a18--5bc4249dd07e469c80c41c314ca3453a
90d5dfd2dd004fd59fb531a4d3ef9498
688ddcff6ef24372939a60cca2a5af34
c8b16280618e41cd905f6498b43e9b06--688ddcff6ef24372939a60cca2a5af34
5ca5777847eb421ead8409fde0ec8904
688ddcff6ef24372939a60cca2a5af34--5ca5777847eb421ead8409fde0ec8904
f620170f2eb04cb588362db8085ac390
5ca5777847eb421ead8409fde0ec8904--f620170f2eb04cb588362db8085ac390
f620170f2eb04cb588362db8085ac390--e7f150a6643741069bbffcf9a80ca125
1cb96cfc6490477d92a26f6c53d7fea6--90d5dfd2dd004fd59fb531a4d3ef9498
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
53b08cb3e9d44b8aaede0788d28bb91f
0
923f87943c1e42c49845a5f948f1183a
53b08cb3e9d44b8aaede0788d28bb91f--923f87943c1e42c49845a5f948f1183a
b17e28cf57a24b489cc372757b0b041d
1
c43e4a87a799404486e16c6eebb5a3e9
923f87943c1e42c49845a5f948f1183a--c43e4a87a799404486e16c6eebb5a3e9
dd03e80f74d642ef8c495a32e04dd2f8
c43e4a87a799404486e16c6eebb5a3e9--dd03e80f74d642ef8c495a32e04dd2f8
5880642aa2e149339bd0e51bef89734d
dd03e80f74d642ef8c495a32e04dd2f8--5880642aa2e149339bd0e51bef89734d
66663fdb83714f029f8c20def3c2eb7d
1141b2be54d146a891ef5e688dea5d0b
PHASE(0.5)
b17e28cf57a24b489cc372757b0b041d--1141b2be54d146a891ef5e688dea5d0b
427005a6ccd74f01be147464cf428471
2
1141b2be54d146a891ef5e688dea5d0b--923f87943c1e42c49845a5f948f1183a
178dba51d8ac4166a09014dee16f2448
1141b2be54d146a891ef5e688dea5d0b--178dba51d8ac4166a09014dee16f2448
8aa9f64040d34a05baeaa028844e2d51
178dba51d8ac4166a09014dee16f2448--8aa9f64040d34a05baeaa028844e2d51
8aa9f64040d34a05baeaa028844e2d51--66663fdb83714f029f8c20def3c2eb7d
2c56bf1052e346b38389376aa651c860
cd66582fceb6432681d434c63f7cde00
427005a6ccd74f01be147464cf428471--cd66582fceb6432681d434c63f7cde00
25057b8f78c94be8b83005da7dc20a2a
3
b6e078c7d04749b787fa59975cc45329
PHASE(0.5)
cd66582fceb6432681d434c63f7cde00--b6e078c7d04749b787fa59975cc45329
b6e078c7d04749b787fa59975cc45329--c43e4a87a799404486e16c6eebb5a3e9
f0092f1d8a8b424faaf4d8025cbe156c
b6e078c7d04749b787fa59975cc45329--f0092f1d8a8b424faaf4d8025cbe156c
f0092f1d8a8b424faaf4d8025cbe156c--2c56bf1052e346b38389376aa651c860
494a2c857d244e6981928710c1c49e22
427f7bcf108142b49df6f77f0dd8d037
25057b8f78c94be8b83005da7dc20a2a--427f7bcf108142b49df6f77f0dd8d037
bad7c08ddd9443508555efce7929fa8a
427f7bcf108142b49df6f77f0dd8d037--bad7c08ddd9443508555efce7929fa8a
df3f2aae981b454fa0c266f2c0da513b
PHASE(0.5)
bad7c08ddd9443508555efce7929fa8a--df3f2aae981b454fa0c266f2c0da513b
df3f2aae981b454fa0c266f2c0da513b--dd03e80f74d642ef8c495a32e04dd2f8
df3f2aae981b454fa0c266f2c0da513b--494a2c857d244e6981928710c1c49e22
Developer documentation
This section contains examples in pure graphviz that can be used to understand roughly what is done
in the actual drawing backend.
import graphviz
font_name = "Sans-Serif"
font_size = "8"
graph_attr = {
"rankdir" : "LR" , # LR = left to right, TB = top to bottom
"nodesep" : "0.1" , # In inches, tells distance between nodes without edges
"compound" : "true" , # Needed to draw properly edges in hamevo when content is hidden
"splines" : "false" , # Needed to draw control gates vertical lines one over the other
} # These are the default values for graphs
node_attr = {
"shape" : "box" , # 'box' for normal nodes, 'point' for control gates or 'plaintext' for starting nodes (the qubit label).
"style" : "rounded" , # Unfortunately we can't specify the radius of the rounded, at least for this version
"fontname" : font_name ,
"fontsize" : font_size ,
"width" : "0.1" , # In inches, it doesn't get tinier than the label font.
"height" : "0.1" # In inches, it doesn't get tinier than the label font.
} # These are the defaults values that can be overridden at node declaration.
default_cluster_attr = {
"fontname" : font_name ,
"fontsize" : font_size ,
"labelloc" : "b" , # location of cluster label. b as bottom, t as top
"style" : "rounded"
} # These are the defaults values that can be overridden at sub graph declaration
hamevo_cluster_attr = {
"label" : "HamEvo(t=10)"
}
hamevo_cluster_attr . update ( default_cluster_attr )
h = graphviz . Graph ( graph_attr = graph_attr , node_attr = node_attr )
h . node ( "Hello World!" )
h
# Define graph
h = graphviz . Graph ( node_attr = node_attr , graph_attr = graph_attr )
# Add start and end nodes
for i in range ( 4 ):
h . node ( f 's { i } ' , shape = "plaintext" , label = f ' { i } ' , group = f " { i } " )
h . node ( f 'e { i } ' , style = 'invis' , group = f " { i } " )
# Add nodes
h . node ( 'X' , group = "0" )
h . node ( 'Y' , group = "1" )
# Add hamevo and its nodes
hamevo = graphviz . Graph ( name = 'cluster_hamevo' , graph_attr = hamevo_cluster_attr )
for i in range ( 4 ):
hamevo . node ( f 'z { i } ' , shape = "box" , style = "invis" , label = f ' { i } ' , group = f " { i } " )
h . subgraph ( hamevo )
# Add rx gates cluster and its nodes
cluster_attr = { "label" : "RX gates" }
cluster_attr . update ( default_cluster_attr )
cluster = graphviz . Graph ( name = "cluster_0" , graph_attr = cluster_attr )
cluster . node ( 'RX(x)' , group = "2" )
cluster . node ( 'RX(0.5)' , group = "3" )
h . subgraph ( cluster )
h . node ( 'cnot0' , label = '' , shape = 'point' , width = '0.1' , group = '0' )
h . node ( 'cnot1' , label = 'X' , group = '1' )
h . node ( 'cnot2' , label = '' , shape = 'point' , width = '0.1' , group = '2' )
h . node ( 'cnot3' , label = '' , shape = 'point' , width = '0.1' , group = '3' )
# Add edges
h . edge ( 's0' , 'X' )
h . edge ( 'X' , 'cnot0' )
h . edge ( 'cnot0' , 'z0' , lhead = 'cluster_hamevo' )
h . edge ( 'z0' , 'e0' , ltail = 'cluster_hamevo' )
h . edge ( 's1' , 'Y' )
h . edge ( 'Y' , 'cnot1' )
h . edge ( 'cnot1' , 'z1' , lhead = 'cluster_hamevo' )
h . edge ( 'z1' , 'e1' , ltail = 'cluster_hamevo' )
h . edge ( 's2' , 'RX(x)' )
h . edge ( 'RX(x)' , 'cnot2' )
h . edge ( 'cnot2' , 'z2' , lhead = 'cluster_hamevo' )
h . edge ( 'z2' , 'e2' , ltail = 'cluster_hamevo' )
h . edge ( 's3' , 'RX(0.5)' )
h . edge ( 'RX(0.5)' , 'cnot3' )
h . edge ( 'cnot3' , 'z3' , lhead = 'cluster_hamevo' )
h . edge ( 'z3' , 'e3' , ltail = 'cluster_hamevo' )
h . edge ( 'cnot1' , 'cnot0' , constraint = 'false' ) # constraint: false is needed to draw vertical edges
h . edge ( 'cnot1' , 'cnot2' , constraint = 'false' ) # constraint: false is needed to draw vertical edges
h . edge ( 'cnot1' , 'cnot3' , constraint = 'false' ) # constraint: false is needed to draw vertical edges
h
Example of cluster of clusters
# Define graph
h = graphviz . Graph ( node_attr = node_attr , graph_attr = graph_attr )
# Define start and end nodes
for i in range ( 4 ):
h . node ( f 's { i } ' , shape = "plaintext" , label = f ' { i } ' , group = f " { i } " )
h . node ( f 'e { i } ' , style = 'invis' , group = f " { i } " )
# Define outer cluster
cluster_attr = { "label" : "Outer cluster" }
cluster_attr . update ( default_cluster_attr )
outer_cluster = graphviz . Graph ( name = "cluster_outer" , graph_attr = cluster_attr )
# Define inner cluster 1 and its nodes
cluster_attr = { "label" : "Inner cluster 1" }
cluster_attr . update ( default_cluster_attr )
inner1_cluster = graphviz . Graph ( name = "cluster_inner1" , graph_attr = cluster_attr )
inner1_cluster . node ( "a0" , group = "0" )
inner1_cluster . node ( "a1" , group = "1" )
outer_cluster . subgraph ( inner1_cluster )
# Define inner cluster 2 and its nodes
cluster_attr = { "label" : "Inner cluster 2" }
cluster_attr . update ( default_cluster_attr )
inner2_cluster = graphviz . Graph ( name = "cluster_inner2" , graph_attr = cluster_attr )
inner2_cluster . node ( "a2" , group = "2" )
inner2_cluster . node ( "a3" , group = "3" )
outer_cluster . subgraph ( inner2_cluster )
# This has to be done here, after inner clusters definitions
h . subgraph ( outer_cluster )
# Define more nodes
for i in range ( 4 ):
h . node ( f "b { i } " , group = f " { i } " )
for i in range ( 4 ):
h . edge ( f 's { i } ' , f 'a { i } ' )
h . edge ( f 'a { i } ' , f 'b { i } ' )
h . edge ( f 'b { i } ' , f 'e { i } ' )
h