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
abfd032b8e7247f8b271c4b0134f1d89
0
41b8c4ce6d0e4076940eaebd1e0d2982
X
abfd032b8e7247f8b271c4b0134f1d89--41b8c4ce6d0e4076940eaebd1e0d2982
a62fa9d8a530436bbced3c10bed2d6c9
1
aa3feeceff4a4017869ea0f7f267514a
41b8c4ce6d0e4076940eaebd1e0d2982--aa3feeceff4a4017869ea0f7f267514a
c8735a5ab7b947e89f14b34edfa32912
60bac353194d4fd598ec51bae2336e21
Y
a62fa9d8a530436bbced3c10bed2d6c9--60bac353194d4fd598ec51bae2336e21
60bac353194d4fd598ec51bae2336e21--c8735a5ab7b947e89f14b34edfa32912
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
fa151c28fcff4938adfb87cd634fba9c
0
c2b6e14872324614b64f18a74f9dd485
X
fa151c28fcff4938adfb87cd634fba9c--c2b6e14872324614b64f18a74f9dd485
2cdd542c69fd4fb89342ef11869d833c
Y
c2b6e14872324614b64f18a74f9dd485--2cdd542c69fd4fb89342ef11869d833c
3c4bbe9f2e8348c1bc7315af83ba43a8
2cdd542c69fd4fb89342ef11869d833c--3c4bbe9f2e8348c1bc7315af83ba43a8
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
4bf3b56e16564646bda87b70cf3919ec
0
79211878871043c29db8e8dd5dac2cbd
X
4bf3b56e16564646bda87b70cf3919ec--79211878871043c29db8e8dd5dac2cbd
b9929934bacd4fde91f710ef7c035fd5
1
913188d0c0cb4982ab9b8aa54b47dc12
79211878871043c29db8e8dd5dac2cbd--913188d0c0cb4982ab9b8aa54b47dc12
46d30057bdc644e4aae485418f878268
913188d0c0cb4982ab9b8aa54b47dc12--46d30057bdc644e4aae485418f878268
07ef90f2d7fd4f87903bb05b48920b67
c516df70af2249309549509e4cca6631
b9929934bacd4fde91f710ef7c035fd5--c516df70af2249309549509e4cca6631
0adcdc9a35f3414b9d433a6961e71f8e
Y
c516df70af2249309549509e4cca6631--0adcdc9a35f3414b9d433a6961e71f8e
0adcdc9a35f3414b9d433a6961e71f8e--07ef90f2d7fd4f87903bb05b48920b67
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_152d6d037a9e42e9a1862cda0212d366
d60c13967b4d448fa6f859968700452c
0
c655e535367f41bc8df64d20085b433a
d60c13967b4d448fa6f859968700452c--c655e535367f41bc8df64d20085b433a
5b3c71902e4e428db2edac9e5d232ac8
1
2d4cf7bb09184dd89950f85b7cb5e78e
c655e535367f41bc8df64d20085b433a--2d4cf7bb09184dd89950f85b7cb5e78e
4d7a2f20350d427eaa699ce05ea8c177
dd395aef845c414daeb9e32b7dc24419
AddBlock
5b3c71902e4e428db2edac9e5d232ac8--dd395aef845c414daeb9e32b7dc24419
b5dc141e972c40bc9d86976181a97589
2
dd395aef845c414daeb9e32b7dc24419--4d7a2f20350d427eaa699ce05ea8c177
b7dc058375df450290f15ab83ddf31b3
5e9d5bfee543482dbb737e424234bdb7
b5dc141e972c40bc9d86976181a97589--5e9d5bfee543482dbb737e424234bdb7
5e9d5bfee543482dbb737e424234bdb7--b7dc058375df450290f15ab83ddf31b3
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_3ba698d1bf1c4d9f901595d331a771d8
cluster_e0b1d40be44c4cb78cce4514937c3342
rx
8c6f56369b92495eb9fdec7fd017526e
0
19667cb34995478a91b0e4fae2241d94
X
8c6f56369b92495eb9fdec7fd017526e--19667cb34995478a91b0e4fae2241d94
2dd9327eb71b4b04bafb63b0a19b9990
1
fab72cff9c004b0aa47ce65a7f9ace86
19667cb34995478a91b0e4fae2241d94--fab72cff9c004b0aa47ce65a7f9ace86
4afe6498d0ff4b2bbbb88ea72bdf523f
fab72cff9c004b0aa47ce65a7f9ace86--4afe6498d0ff4b2bbbb88ea72bdf523f
e9ff110f4ac94805b1d489a477d1100a
4afe6498d0ff4b2bbbb88ea72bdf523f--e9ff110f4ac94805b1d489a477d1100a
7b4f4d512f314547a1b6378eff7a0e83
12ee4304688c421bac34213c3cc7ca84
Y
2dd9327eb71b4b04bafb63b0a19b9990--12ee4304688c421bac34213c3cc7ca84
f6a184852f5f4acd94049e2ef1674964
2
4d9ab926d1a44a0c8a9ddfb4ea1b1f61
12ee4304688c421bac34213c3cc7ca84--4d9ab926d1a44a0c8a9ddfb4ea1b1f61
18e4a852ad134155980524d4b3039601
HamEvo
4d9ab926d1a44a0c8a9ddfb4ea1b1f61--18e4a852ad134155980524d4b3039601
18e4a852ad134155980524d4b3039601--7b4f4d512f314547a1b6378eff7a0e83
66168c0bd1e34e178be15f6c5f4bf791
77be47ffc7ed494f9d4a0d51ee46c38e
RX(x)
f6a184852f5f4acd94049e2ef1674964--77be47ffc7ed494f9d4a0d51ee46c38e
fdce2191b44143e380febc2db97ca9f4
3
9a908ceda21d42f8829367849c0e730a
77be47ffc7ed494f9d4a0d51ee46c38e--9a908ceda21d42f8829367849c0e730a
80709b9f73044b9ca1e8fdef0c4da03c
t = 10
9a908ceda21d42f8829367849c0e730a--80709b9f73044b9ca1e8fdef0c4da03c
80709b9f73044b9ca1e8fdef0c4da03c--66168c0bd1e34e178be15f6c5f4bf791
9c715679956044d28e1d23b72ca56742
8e1cc2f697674a11803c4ccbecc2dbc9
RX(0.5)
fdce2191b44143e380febc2db97ca9f4--8e1cc2f697674a11803c4ccbecc2dbc9
4c19b429c2264d9aa739e05a04460b64
X
8e1cc2f697674a11803c4ccbecc2dbc9--4c19b429c2264d9aa739e05a04460b64
4c19b429c2264d9aa739e05a04460b64--9a908ceda21d42f8829367849c0e730a
d8b0bfda55944e41bd4c8ec0d0155931
4c19b429c2264d9aa739e05a04460b64--d8b0bfda55944e41bd4c8ec0d0155931
d8b0bfda55944e41bd4c8ec0d0155931--9c715679956044d28e1d23b72ca56742
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_7ff107da122649339f838293b7e05d7f
HEA
cluster_8774637ee56d43a9ba7a140be23d1eb1
Tower Fourier FM
34db9b27200349c3a0a32a6441b76d9e
0
513362f4086947bbb6dc0df3c776458e
RX(1.0*phi)
34db9b27200349c3a0a32a6441b76d9e--513362f4086947bbb6dc0df3c776458e
23b107471c374d819f6307b197289c5f
1
751167faa4f94e00bf293f80efdf764f
RX(theta₀)
513362f4086947bbb6dc0df3c776458e--751167faa4f94e00bf293f80efdf764f
f99742784e1649e68162fb37cb488ef6
RY(theta₄)
751167faa4f94e00bf293f80efdf764f--f99742784e1649e68162fb37cb488ef6
ef08b0f51af74066ada83772e1a0cdbe
RX(theta₈)
f99742784e1649e68162fb37cb488ef6--ef08b0f51af74066ada83772e1a0cdbe
e14ebeee701b40c7a0601bc6c584de49
ef08b0f51af74066ada83772e1a0cdbe--e14ebeee701b40c7a0601bc6c584de49
e6282eb913db46fda21e1c73eee5b37e
e14ebeee701b40c7a0601bc6c584de49--e6282eb913db46fda21e1c73eee5b37e
1b33664ac61047c7a00e0881ba6c0131
RX(theta₁₂)
e6282eb913db46fda21e1c73eee5b37e--1b33664ac61047c7a00e0881ba6c0131
2153beb5302140eba2c0bcd8862edc2f
RY(theta₁₆)
1b33664ac61047c7a00e0881ba6c0131--2153beb5302140eba2c0bcd8862edc2f
c079e4fb10184ed98b83580d3f7caa26
RX(theta₂₀)
2153beb5302140eba2c0bcd8862edc2f--c079e4fb10184ed98b83580d3f7caa26
ee998453d4764b46884d92576e2172d8
c079e4fb10184ed98b83580d3f7caa26--ee998453d4764b46884d92576e2172d8
309f7117df67451e80d3c457afdf8a41
ee998453d4764b46884d92576e2172d8--309f7117df67451e80d3c457afdf8a41
b4f48d56b780414fa7eb8e763e2ed2a3
309f7117df67451e80d3c457afdf8a41--b4f48d56b780414fa7eb8e763e2ed2a3
63198c2d85d4404a9cb3459a60882ba2
dde30897b64f4560a3bcf9c503044665
RX(2.0*phi)
23b107471c374d819f6307b197289c5f--dde30897b64f4560a3bcf9c503044665
5c3ca30f1ae8448ab6dcf38f48b4375e
2
e30be129a8e545d2b53d577679177e5c
RX(theta₁)
dde30897b64f4560a3bcf9c503044665--e30be129a8e545d2b53d577679177e5c
fdf03e98ed784494811d4df7d1e3d0f1
RY(theta₅)
e30be129a8e545d2b53d577679177e5c--fdf03e98ed784494811d4df7d1e3d0f1
5d37594fdf344c5b88761cec76ce2ef3
RX(theta₉)
fdf03e98ed784494811d4df7d1e3d0f1--5d37594fdf344c5b88761cec76ce2ef3
be742bece38c44b3badc71087d486a07
X
5d37594fdf344c5b88761cec76ce2ef3--be742bece38c44b3badc71087d486a07
be742bece38c44b3badc71087d486a07--e14ebeee701b40c7a0601bc6c584de49
16676cbcf49c43dd948797910a954719
be742bece38c44b3badc71087d486a07--16676cbcf49c43dd948797910a954719
f152b7fb1044449ca38b7b6d362d1ed7
RX(theta₁₃)
16676cbcf49c43dd948797910a954719--f152b7fb1044449ca38b7b6d362d1ed7
5dd2022b5ac544e8828dfb9905261530
RY(theta₁₇)
f152b7fb1044449ca38b7b6d362d1ed7--5dd2022b5ac544e8828dfb9905261530
43d6a3cf1302448888e660b8f6ccaead
RX(theta₂₁)
5dd2022b5ac544e8828dfb9905261530--43d6a3cf1302448888e660b8f6ccaead
400d579a67b049548840189d7b6e6a8b
X
43d6a3cf1302448888e660b8f6ccaead--400d579a67b049548840189d7b6e6a8b
400d579a67b049548840189d7b6e6a8b--ee998453d4764b46884d92576e2172d8
58b34480c74b49a3ad987bf5218c3ce9
400d579a67b049548840189d7b6e6a8b--58b34480c74b49a3ad987bf5218c3ce9
58b34480c74b49a3ad987bf5218c3ce9--63198c2d85d4404a9cb3459a60882ba2
c316d05af6b440fd9de7c47cbe488e51
395a7ade8c0046c58cbc5826b3a03d1e
RX(3.0*phi)
5c3ca30f1ae8448ab6dcf38f48b4375e--395a7ade8c0046c58cbc5826b3a03d1e
4f43ef0d413e464d8ac8ba51e7fc6322
3
358a0b8c38ae4bedb6c4414a68d91ac6
RX(theta₂)
395a7ade8c0046c58cbc5826b3a03d1e--358a0b8c38ae4bedb6c4414a68d91ac6
ba611b43f32d4754900ed6e69368d6c4
RY(theta₆)
358a0b8c38ae4bedb6c4414a68d91ac6--ba611b43f32d4754900ed6e69368d6c4
b75a6a16840d494eb18ccfc49dc07af3
RX(theta₁₀)
ba611b43f32d4754900ed6e69368d6c4--b75a6a16840d494eb18ccfc49dc07af3
172a7b5750d44e3a93b0cf643b2b02f3
b75a6a16840d494eb18ccfc49dc07af3--172a7b5750d44e3a93b0cf643b2b02f3
6b9614929cb74e7f928d40cb3addbdae
X
172a7b5750d44e3a93b0cf643b2b02f3--6b9614929cb74e7f928d40cb3addbdae
6b9614929cb74e7f928d40cb3addbdae--16676cbcf49c43dd948797910a954719
eab5be6bace345d69c220d0423530074
RX(theta₁₄)
6b9614929cb74e7f928d40cb3addbdae--eab5be6bace345d69c220d0423530074
b14f5fa955e3421ca005ee80b6cfb146
RY(theta₁₈)
eab5be6bace345d69c220d0423530074--b14f5fa955e3421ca005ee80b6cfb146
bed0b4f907af4bb38a8bf68cf4a6b8e3
RX(theta₂₂)
b14f5fa955e3421ca005ee80b6cfb146--bed0b4f907af4bb38a8bf68cf4a6b8e3
36d13b6d14284f9d81cedf1397235edd
bed0b4f907af4bb38a8bf68cf4a6b8e3--36d13b6d14284f9d81cedf1397235edd
794bac5e32e345c1a91fc39d2d108ee1
X
36d13b6d14284f9d81cedf1397235edd--794bac5e32e345c1a91fc39d2d108ee1
794bac5e32e345c1a91fc39d2d108ee1--58b34480c74b49a3ad987bf5218c3ce9
794bac5e32e345c1a91fc39d2d108ee1--c316d05af6b440fd9de7c47cbe488e51
ca5f390fd2f2485db188e57c96df94fc
83e0aa9cfde54a17af89417aedb54fb5
RX(4.0*phi)
4f43ef0d413e464d8ac8ba51e7fc6322--83e0aa9cfde54a17af89417aedb54fb5
53b5f71dd19f496a8b5efd8ab9896e30
RX(theta₃)
83e0aa9cfde54a17af89417aedb54fb5--53b5f71dd19f496a8b5efd8ab9896e30
e0f4f615860d41de88bb76818666f09b
RY(theta₇)
53b5f71dd19f496a8b5efd8ab9896e30--e0f4f615860d41de88bb76818666f09b
982d0cf2594644af9e96be9202769a12
RX(theta₁₁)
e0f4f615860d41de88bb76818666f09b--982d0cf2594644af9e96be9202769a12
b257b5c8cb76418b8a8bbf58c8dec683
X
982d0cf2594644af9e96be9202769a12--b257b5c8cb76418b8a8bbf58c8dec683
b257b5c8cb76418b8a8bbf58c8dec683--172a7b5750d44e3a93b0cf643b2b02f3
2e4a7bb8a2cd492c861e392d62d0caf6
b257b5c8cb76418b8a8bbf58c8dec683--2e4a7bb8a2cd492c861e392d62d0caf6
8b5fa6bac87c4701a80ec3734a93eb82
RX(theta₁₅)
2e4a7bb8a2cd492c861e392d62d0caf6--8b5fa6bac87c4701a80ec3734a93eb82
1bfd87a952e74534b0d612ba6511c600
RY(theta₁₉)
8b5fa6bac87c4701a80ec3734a93eb82--1bfd87a952e74534b0d612ba6511c600
f283fd4ec5794f7aad3f70a20c25f238
RX(theta₂₃)
1bfd87a952e74534b0d612ba6511c600--f283fd4ec5794f7aad3f70a20c25f238
db3263059e0143dcbd3ddefcd4b2564f
X
f283fd4ec5794f7aad3f70a20c25f238--db3263059e0143dcbd3ddefcd4b2564f
db3263059e0143dcbd3ddefcd4b2564f--36d13b6d14284f9d81cedf1397235edd
adff8c83a1ef4eefaf76c9051835a0b6
db3263059e0143dcbd3ddefcd4b2564f--adff8c83a1ef4eefaf76c9051835a0b6
adff8c83a1ef4eefaf76c9051835a0b6--ca5f390fd2f2485db188e57c96df94fc
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_455b3f72ca8a4f63a2ab44c035bd9ebe
Obs.
cluster_c827464410714f95a90b96a7688f6a61
cluster_49414dd469954280af8f9031bbbc18e5
HEA
1ee5ecc6366a48c4a0258886fa6ffa28
0
ec908f7824944d7eb29cbe583372a408
RX(theta₀)
1ee5ecc6366a48c4a0258886fa6ffa28--ec908f7824944d7eb29cbe583372a408
a0a6e4f090764215adb31dc8bc2abeb6
1
ee1896d7a21743b68804c3d151e0d767
RY(theta₃)
ec908f7824944d7eb29cbe583372a408--ee1896d7a21743b68804c3d151e0d767
dd14ce3c500842ec89ea2a2ded0c8eab
RX(theta₆)
ee1896d7a21743b68804c3d151e0d767--dd14ce3c500842ec89ea2a2ded0c8eab
5439e7c25825426c83342a7b8ceba163
dd14ce3c500842ec89ea2a2ded0c8eab--5439e7c25825426c83342a7b8ceba163
a45749a8c4f64a51b0d9b2c18fdd5d29
5439e7c25825426c83342a7b8ceba163--a45749a8c4f64a51b0d9b2c18fdd5d29
affc93faf491481598f9020955bf74f1
RX(theta₉)
a45749a8c4f64a51b0d9b2c18fdd5d29--affc93faf491481598f9020955bf74f1
185af4270400454bb359c5d60e2f4a16
RY(theta₁₂)
affc93faf491481598f9020955bf74f1--185af4270400454bb359c5d60e2f4a16
aad70295302640819d166e887a572737
RX(theta₁₅)
185af4270400454bb359c5d60e2f4a16--aad70295302640819d166e887a572737
047be8cfb2044450af9e203cf160483f
aad70295302640819d166e887a572737--047be8cfb2044450af9e203cf160483f
6eb1a9e988654fcd9f2fad87042a6ccb
047be8cfb2044450af9e203cf160483f--6eb1a9e988654fcd9f2fad87042a6ccb
96d2ca428df546289cd075c52736cbf4
6eb1a9e988654fcd9f2fad87042a6ccb--96d2ca428df546289cd075c52736cbf4
2faa37cc0477465e9196d10a3326b211
96d2ca428df546289cd075c52736cbf4--2faa37cc0477465e9196d10a3326b211
8d3154ec0ace4ec895caca77fdb2d8b2
7fa26a5cb8824fe0b99db04826ced054
RX(theta₁)
a0a6e4f090764215adb31dc8bc2abeb6--7fa26a5cb8824fe0b99db04826ced054
9a87ee73119f4ee6a2f78e567f6146a8
2
47b3e42d95b9415fb509383f80f5d665
RY(theta₄)
7fa26a5cb8824fe0b99db04826ced054--47b3e42d95b9415fb509383f80f5d665
9b733197d0a94b0a81acba66733e7e5d
RX(theta₇)
47b3e42d95b9415fb509383f80f5d665--9b733197d0a94b0a81acba66733e7e5d
5092a0050cce4cc6a78b02a5ecc63af4
X
9b733197d0a94b0a81acba66733e7e5d--5092a0050cce4cc6a78b02a5ecc63af4
5092a0050cce4cc6a78b02a5ecc63af4--5439e7c25825426c83342a7b8ceba163
51c91fba1a5244e29cb71a626940cf37
5092a0050cce4cc6a78b02a5ecc63af4--51c91fba1a5244e29cb71a626940cf37
270e2900dff1411ea2840e311f7e04fe
RX(theta₁₀)
51c91fba1a5244e29cb71a626940cf37--270e2900dff1411ea2840e311f7e04fe
bb3769c173a243e88013d53cc574fe73
RY(theta₁₃)
270e2900dff1411ea2840e311f7e04fe--bb3769c173a243e88013d53cc574fe73
610e36c8c9084eb28297925b706ebf4c
RX(theta₁₆)
bb3769c173a243e88013d53cc574fe73--610e36c8c9084eb28297925b706ebf4c
c521220b375f44c3b7532558f0d9d764
X
610e36c8c9084eb28297925b706ebf4c--c521220b375f44c3b7532558f0d9d764
c521220b375f44c3b7532558f0d9d764--047be8cfb2044450af9e203cf160483f
c1498719b3524a5e8598db75b6c4e162
c521220b375f44c3b7532558f0d9d764--c1498719b3524a5e8598db75b6c4e162
64db5a9f7cdc43e8832db77ae6908614
AddBlock
c1498719b3524a5e8598db75b6c4e162--64db5a9f7cdc43e8832db77ae6908614
64db5a9f7cdc43e8832db77ae6908614--8d3154ec0ace4ec895caca77fdb2d8b2
5a84d825eeae42be9f99899d1d323c1a
fc31a341b2c946d29df6d9c4f9a05ce8
RX(theta₂)
9a87ee73119f4ee6a2f78e567f6146a8--fc31a341b2c946d29df6d9c4f9a05ce8
c0421d1a570e4ea6bd63620f4e6aeddc
RY(theta₅)
fc31a341b2c946d29df6d9c4f9a05ce8--c0421d1a570e4ea6bd63620f4e6aeddc
4dcde61fbaf04776b88e10caebdd295b
RX(theta₈)
c0421d1a570e4ea6bd63620f4e6aeddc--4dcde61fbaf04776b88e10caebdd295b
3be17655c4874be2b0a87125cbe76fe0
4dcde61fbaf04776b88e10caebdd295b--3be17655c4874be2b0a87125cbe76fe0
324b8d1acb814cca96f291329129639b
X
3be17655c4874be2b0a87125cbe76fe0--324b8d1acb814cca96f291329129639b
324b8d1acb814cca96f291329129639b--51c91fba1a5244e29cb71a626940cf37
ba1f3f142cdb4b9ea5f5352c6cf2ef69
RX(theta₁₁)
324b8d1acb814cca96f291329129639b--ba1f3f142cdb4b9ea5f5352c6cf2ef69
795cb60273b94485b222ef92aa221127
RY(theta₁₄)
ba1f3f142cdb4b9ea5f5352c6cf2ef69--795cb60273b94485b222ef92aa221127
483800da5166419787e91c0bedb3c9b7
RX(theta₁₇)
795cb60273b94485b222ef92aa221127--483800da5166419787e91c0bedb3c9b7
5170b78bb310479389341e1478add4b9
483800da5166419787e91c0bedb3c9b7--5170b78bb310479389341e1478add4b9
20edbf8e3fe348a1a9f3feb5c2b109cb
X
5170b78bb310479389341e1478add4b9--20edbf8e3fe348a1a9f3feb5c2b109cb
20edbf8e3fe348a1a9f3feb5c2b109cb--c1498719b3524a5e8598db75b6c4e162
aafd7c7fb0694057bc73437c4269ff84
20edbf8e3fe348a1a9f3feb5c2b109cb--aafd7c7fb0694057bc73437c4269ff84
aafd7c7fb0694057bc73437c4269ff84--5a84d825eeae42be9f99899d1d323c1a
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
4b212044b1d74ad6964311d0132f0187
0
2a2153d7578c400ea964bd3cb60c0524
4b212044b1d74ad6964311d0132f0187--2a2153d7578c400ea964bd3cb60c0524
fd6a4a50ae224d3c9c4f5477c9af1a35
1
534c0c50033c46b3a00914248897e748
799736d0d56040fb9fe5d6c315440678
2a2153d7578c400ea964bd3cb60c0524--799736d0d56040fb9fe5d6c315440678
bf010d1736264c8fb44396b9340c72b9
534c0c50033c46b3a00914248897e748--bf010d1736264c8fb44396b9340c72b9
8cb35584df99467ca0e84328b4165078
9fdc5eed4e064a5fb18e39e32542e4ce
bf010d1736264c8fb44396b9340c72b9--9fdc5eed4e064a5fb18e39e32542e4ce
36af6ce1ca3e4b3dbd2903f3e9cae776
8cb35584df99467ca0e84328b4165078--36af6ce1ca3e4b3dbd2903f3e9cae776
574c2688c81548c1b798d7b52a1f49ac
bfd2149808e04779a3eb80c1c74d106b
fd6a4a50ae224d3c9c4f5477c9af1a35--bfd2149808e04779a3eb80c1c74d106b
d2f33a3d3c784eeeb505315ceb4732ca
2
bfd2149808e04779a3eb80c1c74d106b--534c0c50033c46b3a00914248897e748
dbb4782a38174b199ba6496105987cf9
799736d0d56040fb9fe5d6c315440678--dbb4782a38174b199ba6496105987cf9
5c65ffbb0f974eec9c50f1851e63a2b1
dbb4782a38174b199ba6496105987cf9--5c65ffbb0f974eec9c50f1851e63a2b1
5c65ffbb0f974eec9c50f1851e63a2b1--574c2688c81548c1b798d7b52a1f49ac
44ac544f6bd84c1bbc4706c5d49535e3
f0431e2c28f341099544a2b4c90f69db
d2f33a3d3c784eeeb505315ceb4732ca--f0431e2c28f341099544a2b4c90f69db
750ab4e0bc034498865540d69940c83c
3
0869d18fa2b5491f9075c31579aa804e
f0431e2c28f341099544a2b4c90f69db--0869d18fa2b5491f9075c31579aa804e
943a48527a324d048d6cf09d7a27cae3
0869d18fa2b5491f9075c31579aa804e--943a48527a324d048d6cf09d7a27cae3
ae73380afffe478182cea04d4d1c2ba0
943a48527a324d048d6cf09d7a27cae3--ae73380afffe478182cea04d4d1c2ba0
ae73380afffe478182cea04d4d1c2ba0--44ac544f6bd84c1bbc4706c5d49535e3
a9dac20e1692473f81fd87fdd368d562
883b90ba93e4470598e81f5208885573
750ab4e0bc034498865540d69940c83c--883b90ba93e4470598e81f5208885573
d8ce3cf1a30e419086fb46e01cf327c8
883b90ba93e4470598e81f5208885573--d8ce3cf1a30e419086fb46e01cf327c8
f3b1a98b849b48b18e71faca073de9db
d8ce3cf1a30e419086fb46e01cf327c8--f3b1a98b849b48b18e71faca073de9db
f3b1a98b849b48b18e71faca073de9db--8cb35584df99467ca0e84328b4165078
9fdc5eed4e064a5fb18e39e32542e4ce--a9dac20e1692473f81fd87fdd368d562
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
e0ce6aa5110043ce964f8aac8f0ad8be
0
c557b71108fb4f98bbda8c22511a31e6
e0ce6aa5110043ce964f8aac8f0ad8be--c557b71108fb4f98bbda8c22511a31e6
1f568e89c6664e0fab50f2f6e1e97438
1
4211d6eb76924982bfd082926016587c
c557b71108fb4f98bbda8c22511a31e6--4211d6eb76924982bfd082926016587c
b69ace054c694c5f83b6763879bbd59f
4211d6eb76924982bfd082926016587c--b69ace054c694c5f83b6763879bbd59f
34a00b9c1384416ba2ea73d0d96d06ed
b69ace054c694c5f83b6763879bbd59f--34a00b9c1384416ba2ea73d0d96d06ed
ecb18316831349f7b21a4e202adf513b
defeb902f96c422e97ca3182c079bf3a
PHASE(0.5)
1f568e89c6664e0fab50f2f6e1e97438--defeb902f96c422e97ca3182c079bf3a
f3390ba356a847889886546bd06c472a
2
defeb902f96c422e97ca3182c079bf3a--c557b71108fb4f98bbda8c22511a31e6
3bec5e27c4f14e88b1c16ffb21587124
defeb902f96c422e97ca3182c079bf3a--3bec5e27c4f14e88b1c16ffb21587124
48039cd7c329485d866a0660cefbfb9d
3bec5e27c4f14e88b1c16ffb21587124--48039cd7c329485d866a0660cefbfb9d
48039cd7c329485d866a0660cefbfb9d--ecb18316831349f7b21a4e202adf513b
265fc25500c04fbb99be1911c22980f9
beda05b6ed994aa086433f8c3a1cf8a8
f3390ba356a847889886546bd06c472a--beda05b6ed994aa086433f8c3a1cf8a8
67e901d8f3664c7b90dd50440418c3e5
3
e8127c6024164459917a2d78d3e5edeb
PHASE(0.5)
beda05b6ed994aa086433f8c3a1cf8a8--e8127c6024164459917a2d78d3e5edeb
e8127c6024164459917a2d78d3e5edeb--4211d6eb76924982bfd082926016587c
fc533fbc087e4c6d87ad63e89d29d765
e8127c6024164459917a2d78d3e5edeb--fc533fbc087e4c6d87ad63e89d29d765
fc533fbc087e4c6d87ad63e89d29d765--265fc25500c04fbb99be1911c22980f9
3d00097842264f0a8ebcd43d717335e5
86daaa7d02964840b1b84d0ba016ce9c
67e901d8f3664c7b90dd50440418c3e5--86daaa7d02964840b1b84d0ba016ce9c
be29102b4cdf422b9b4f645a27fc627f
86daaa7d02964840b1b84d0ba016ce9c--be29102b4cdf422b9b4f645a27fc627f
877139e282274d6cad2da01255cb99d6
PHASE(0.5)
be29102b4cdf422b9b4f645a27fc627f--877139e282274d6cad2da01255cb99d6
877139e282274d6cad2da01255cb99d6--b69ace054c694c5f83b6763879bbd59f
877139e282274d6cad2da01255cb99d6--3d00097842264f0a8ebcd43d717335e5
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