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
d47aea37daa04eea933be0bed2353a47
0
4e639d8982b2453f92d9fea922ddd4f6
X
d47aea37daa04eea933be0bed2353a47--4e639d8982b2453f92d9fea922ddd4f6
1757ea5764fe4ab2b48540b067a6553b
1
3df8422716434f5ba94ee598e97efbbc
4e639d8982b2453f92d9fea922ddd4f6--3df8422716434f5ba94ee598e97efbbc
3963760928ec4f8888f8b33a738b5e36
beb2de416d464124b0aa9ecb2ce46bc9
Y
1757ea5764fe4ab2b48540b067a6553b--beb2de416d464124b0aa9ecb2ce46bc9
beb2de416d464124b0aa9ecb2ce46bc9--3963760928ec4f8888f8b33a738b5e36
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
14e6b97d31034802959985a2776ec568
0
e853f0fa1d364df98b01cda10c0909f7
X
14e6b97d31034802959985a2776ec568--e853f0fa1d364df98b01cda10c0909f7
aac0e1a200c04509b6aa96e841eed4f3
Y
e853f0fa1d364df98b01cda10c0909f7--aac0e1a200c04509b6aa96e841eed4f3
8713defdc97d4afb857733c1fc36bd7f
aac0e1a200c04509b6aa96e841eed4f3--8713defdc97d4afb857733c1fc36bd7f
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
7a5e1133c5af49c68466979472796099
0
0245ed2dfe284611a88bd9ef357a1383
X
7a5e1133c5af49c68466979472796099--0245ed2dfe284611a88bd9ef357a1383
862060ad46c94020a25073c9b93dfb16
1
5e6b3d5b85f04fc392b453460d1c04d3
0245ed2dfe284611a88bd9ef357a1383--5e6b3d5b85f04fc392b453460d1c04d3
f8c07355ec2649fa9b5699097ffc040b
5e6b3d5b85f04fc392b453460d1c04d3--f8c07355ec2649fa9b5699097ffc040b
bca12943d252413c8769aea65185feb5
6a69ac0a72cf423f822a59e1fb26478e
862060ad46c94020a25073c9b93dfb16--6a69ac0a72cf423f822a59e1fb26478e
be3c85caf809489d9558cd3adcec4f20
Y
6a69ac0a72cf423f822a59e1fb26478e--be3c85caf809489d9558cd3adcec4f20
be3c85caf809489d9558cd3adcec4f20--bca12943d252413c8769aea65185feb5
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_8f57b2c6d3cf4ac9a93d7bc37a8e22f8
912eda2ef3a44c5686c188977c705a1a
0
ff61117951df453f84c63c9cd745f212
912eda2ef3a44c5686c188977c705a1a--ff61117951df453f84c63c9cd745f212
2792c539f6b94eb484c2a8e91035f3af
1
d1761326192640a6b42c00ab221970f3
ff61117951df453f84c63c9cd745f212--d1761326192640a6b42c00ab221970f3
5c32a93669854db29e4f5fd965ccf7f9
847ae861812549d3bee8a35fea842024
AddBlock
2792c539f6b94eb484c2a8e91035f3af--847ae861812549d3bee8a35fea842024
1b65cd194e114af99130724570757dbb
2
847ae861812549d3bee8a35fea842024--5c32a93669854db29e4f5fd965ccf7f9
78fb70d5438941c8b44c87e158a27093
4593720fcc4a493abd35dc94999f514b
1b65cd194e114af99130724570757dbb--4593720fcc4a493abd35dc94999f514b
4593720fcc4a493abd35dc94999f514b--78fb70d5438941c8b44c87e158a27093
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_71628a0ad70d4560b4114d3083677daa
cluster_3bfa3966dacc44a29d4ee0f050d866b4
rx
093d7a1bc0a1438f82bffa18ce642ef9
0
9473c5e019bf453b916733f34d7aaa98
X
093d7a1bc0a1438f82bffa18ce642ef9--9473c5e019bf453b916733f34d7aaa98
ca76932d521d47c88d4ceb3e92e7b43c
1
cc31eb6fb6f34399b8d9575ee43d5e54
9473c5e019bf453b916733f34d7aaa98--cc31eb6fb6f34399b8d9575ee43d5e54
da7dc8e74b6a4c9987f49b0904616947
cc31eb6fb6f34399b8d9575ee43d5e54--da7dc8e74b6a4c9987f49b0904616947
da9cea2ace2141a9a15a73c8c3d81ded
da7dc8e74b6a4c9987f49b0904616947--da9cea2ace2141a9a15a73c8c3d81ded
bc376563e50d4a52a9f8e285ab7d55c9
d379292a63404720b79e62587b82dffa
Y
ca76932d521d47c88d4ceb3e92e7b43c--d379292a63404720b79e62587b82dffa
bd71aa567d54496a891d49e4b7bf5e44
2
fc1ecbd7525645a995a3564d62d6113a
d379292a63404720b79e62587b82dffa--fc1ecbd7525645a995a3564d62d6113a
c9105ce58f794be183b8d64e89634b71
HamEvo
fc1ecbd7525645a995a3564d62d6113a--c9105ce58f794be183b8d64e89634b71
c9105ce58f794be183b8d64e89634b71--bc376563e50d4a52a9f8e285ab7d55c9
d18460e9bb5546ec85412856adac0aa6
b32d606990ca4b868246c5c8a9f8e788
RX(x)
bd71aa567d54496a891d49e4b7bf5e44--b32d606990ca4b868246c5c8a9f8e788
81542e7abbaf4f64b89733c1235fedf1
3
e3d8fdda57e14ea4af8cf4c6c24f334b
b32d606990ca4b868246c5c8a9f8e788--e3d8fdda57e14ea4af8cf4c6c24f334b
3506271134a1414e86242a14b2bf0f5c
t = 10
e3d8fdda57e14ea4af8cf4c6c24f334b--3506271134a1414e86242a14b2bf0f5c
3506271134a1414e86242a14b2bf0f5c--d18460e9bb5546ec85412856adac0aa6
fcf6c8c2a9ed4fc3a17fe5ac9f8294a1
059d3790973e4e4abc0c8729c800adfe
RX(0.5)
81542e7abbaf4f64b89733c1235fedf1--059d3790973e4e4abc0c8729c800adfe
786f912665fc49838586cc32bc298cb8
X
059d3790973e4e4abc0c8729c800adfe--786f912665fc49838586cc32bc298cb8
786f912665fc49838586cc32bc298cb8--e3d8fdda57e14ea4af8cf4c6c24f334b
acd80b4b7fc446f993b5ff9892942bd7
786f912665fc49838586cc32bc298cb8--acd80b4b7fc446f993b5ff9892942bd7
acd80b4b7fc446f993b5ff9892942bd7--fcf6c8c2a9ed4fc3a17fe5ac9f8294a1
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_d7a06e8ec7fb41118747b5c41a1f0927
HEA
cluster_794824abf2764fecaabfa70603381395
Tower Fourier FM
73c76903829e4a909ab589718e90a3b5
0
55a9769715974f02a085d677b04b6c69
RX(1.0*phi)
73c76903829e4a909ab589718e90a3b5--55a9769715974f02a085d677b04b6c69
98af634a0bc3494b9c80e59246907887
1
f961cb490fcc429e8dba510193631003
RX(theta₀)
55a9769715974f02a085d677b04b6c69--f961cb490fcc429e8dba510193631003
81c8a6eb5afa4b0da4463e4942300e78
RY(theta₄)
f961cb490fcc429e8dba510193631003--81c8a6eb5afa4b0da4463e4942300e78
f18703551108477ca217969f452cabc2
RX(theta₈)
81c8a6eb5afa4b0da4463e4942300e78--f18703551108477ca217969f452cabc2
359eff4bf36a453eb66bed984634e097
f18703551108477ca217969f452cabc2--359eff4bf36a453eb66bed984634e097
51875b43d343495c9170f259cd3d13f6
359eff4bf36a453eb66bed984634e097--51875b43d343495c9170f259cd3d13f6
94d3aecca81941ac9b8ed96f8b443517
RX(theta₁₂)
51875b43d343495c9170f259cd3d13f6--94d3aecca81941ac9b8ed96f8b443517
c426917eadcc4b5db1908b63b6f9d710
RY(theta₁₆)
94d3aecca81941ac9b8ed96f8b443517--c426917eadcc4b5db1908b63b6f9d710
283e374628fd4ff68ab157503dd7c516
RX(theta₂₀)
c426917eadcc4b5db1908b63b6f9d710--283e374628fd4ff68ab157503dd7c516
41fdbfa2706c4e3fb1c9ab83dde46f49
283e374628fd4ff68ab157503dd7c516--41fdbfa2706c4e3fb1c9ab83dde46f49
b4d8ee9212cf4e94929faf23ebd4d91b
41fdbfa2706c4e3fb1c9ab83dde46f49--b4d8ee9212cf4e94929faf23ebd4d91b
4c2a9b6a1952435aabef84b83c70e987
b4d8ee9212cf4e94929faf23ebd4d91b--4c2a9b6a1952435aabef84b83c70e987
3bcbe4e2f6984a76b4a10aa8588ccb4f
2a60adfc24344cdaad94048cdf18c4dc
RX(2.0*phi)
98af634a0bc3494b9c80e59246907887--2a60adfc24344cdaad94048cdf18c4dc
61d6734e27cc4a5dadf7274eaa1ff9dd
2
f51d8196fb504aa2ab11096cfea9a32d
RX(theta₁)
2a60adfc24344cdaad94048cdf18c4dc--f51d8196fb504aa2ab11096cfea9a32d
863b547bc98046e38a03a8bafac584bc
RY(theta₅)
f51d8196fb504aa2ab11096cfea9a32d--863b547bc98046e38a03a8bafac584bc
3c2dea4cdd564cbfa1c9bf211833f17c
RX(theta₉)
863b547bc98046e38a03a8bafac584bc--3c2dea4cdd564cbfa1c9bf211833f17c
37ee48c1593d47f0a446e67fb8425945
X
3c2dea4cdd564cbfa1c9bf211833f17c--37ee48c1593d47f0a446e67fb8425945
37ee48c1593d47f0a446e67fb8425945--359eff4bf36a453eb66bed984634e097
f00d6e733330419797794a353611b741
37ee48c1593d47f0a446e67fb8425945--f00d6e733330419797794a353611b741
6e016e1064f14a29931deb1bbd284c3c
RX(theta₁₃)
f00d6e733330419797794a353611b741--6e016e1064f14a29931deb1bbd284c3c
a7e9b48348b744baaaa5514551bc9705
RY(theta₁₇)
6e016e1064f14a29931deb1bbd284c3c--a7e9b48348b744baaaa5514551bc9705
d8fad4550759406991908862d9116e9b
RX(theta₂₁)
a7e9b48348b744baaaa5514551bc9705--d8fad4550759406991908862d9116e9b
a4b001e6918c42029e06113282c9cc1b
X
d8fad4550759406991908862d9116e9b--a4b001e6918c42029e06113282c9cc1b
a4b001e6918c42029e06113282c9cc1b--41fdbfa2706c4e3fb1c9ab83dde46f49
39a574d675da4aab82a385284eb8895c
a4b001e6918c42029e06113282c9cc1b--39a574d675da4aab82a385284eb8895c
39a574d675da4aab82a385284eb8895c--3bcbe4e2f6984a76b4a10aa8588ccb4f
e73eaffd2f93449cb9d921acd9369c0c
3d800aed0d9c4d4fb936a8eee5908769
RX(3.0*phi)
61d6734e27cc4a5dadf7274eaa1ff9dd--3d800aed0d9c4d4fb936a8eee5908769
f4a0ee8aff2c419fb55e97ce48f76bfb
3
ccffefcebc514e69aa57fc4b3175b735
RX(theta₂)
3d800aed0d9c4d4fb936a8eee5908769--ccffefcebc514e69aa57fc4b3175b735
bcb05a62094b4003ab8ee264665f64d9
RY(theta₆)
ccffefcebc514e69aa57fc4b3175b735--bcb05a62094b4003ab8ee264665f64d9
37896cad05c04d6798f8b8e528111c32
RX(theta₁₀)
bcb05a62094b4003ab8ee264665f64d9--37896cad05c04d6798f8b8e528111c32
0be5ae4a9f794fb9a96e91cab43f659c
37896cad05c04d6798f8b8e528111c32--0be5ae4a9f794fb9a96e91cab43f659c
424c337b8a0746aaa650e05a2c5adf15
X
0be5ae4a9f794fb9a96e91cab43f659c--424c337b8a0746aaa650e05a2c5adf15
424c337b8a0746aaa650e05a2c5adf15--f00d6e733330419797794a353611b741
2aacf4bcc9ff42c5b1afdbdbdbc1f76b
RX(theta₁₄)
424c337b8a0746aaa650e05a2c5adf15--2aacf4bcc9ff42c5b1afdbdbdbc1f76b
750b50f435e04d058eec6e052f4b2a7d
RY(theta₁₈)
2aacf4bcc9ff42c5b1afdbdbdbc1f76b--750b50f435e04d058eec6e052f4b2a7d
6ee24874b8414211bc0b898e6a44f8f1
RX(theta₂₂)
750b50f435e04d058eec6e052f4b2a7d--6ee24874b8414211bc0b898e6a44f8f1
33168da092e34660a9e8102c179b6c4c
6ee24874b8414211bc0b898e6a44f8f1--33168da092e34660a9e8102c179b6c4c
9b80a699f2a4468ebb62f68e0edf9cb1
X
33168da092e34660a9e8102c179b6c4c--9b80a699f2a4468ebb62f68e0edf9cb1
9b80a699f2a4468ebb62f68e0edf9cb1--39a574d675da4aab82a385284eb8895c
9b80a699f2a4468ebb62f68e0edf9cb1--e73eaffd2f93449cb9d921acd9369c0c
7e1623afa7a74a9984b993c1e9827214
c141c49e563445229089893c447f7c8b
RX(4.0*phi)
f4a0ee8aff2c419fb55e97ce48f76bfb--c141c49e563445229089893c447f7c8b
07e3ddb860f8442e9407d249163a4253
RX(theta₃)
c141c49e563445229089893c447f7c8b--07e3ddb860f8442e9407d249163a4253
58e9cc1b5b1745d2912e3f086c3d75ba
RY(theta₇)
07e3ddb860f8442e9407d249163a4253--58e9cc1b5b1745d2912e3f086c3d75ba
2e0f53463b7440e99bc02f91e181d2b7
RX(theta₁₁)
58e9cc1b5b1745d2912e3f086c3d75ba--2e0f53463b7440e99bc02f91e181d2b7
a0b6b0bfb7434e6796d0beb218d8bac7
X
2e0f53463b7440e99bc02f91e181d2b7--a0b6b0bfb7434e6796d0beb218d8bac7
a0b6b0bfb7434e6796d0beb218d8bac7--0be5ae4a9f794fb9a96e91cab43f659c
8bbf8f1c1d2943ed9897b4173cfdfc65
a0b6b0bfb7434e6796d0beb218d8bac7--8bbf8f1c1d2943ed9897b4173cfdfc65
dc40fec9e6c142ddb272c2db413d0e06
RX(theta₁₅)
8bbf8f1c1d2943ed9897b4173cfdfc65--dc40fec9e6c142ddb272c2db413d0e06
2f6e5abc31e24ac7b2361abcef760233
RY(theta₁₉)
dc40fec9e6c142ddb272c2db413d0e06--2f6e5abc31e24ac7b2361abcef760233
b1cdeded32de4a59b412e3e759d0e3cc
RX(theta₂₃)
2f6e5abc31e24ac7b2361abcef760233--b1cdeded32de4a59b412e3e759d0e3cc
9bd054aa5dcc465bad98f0b4b602497b
X
b1cdeded32de4a59b412e3e759d0e3cc--9bd054aa5dcc465bad98f0b4b602497b
9bd054aa5dcc465bad98f0b4b602497b--33168da092e34660a9e8102c179b6c4c
5b768dad2e324b47b8f9b0892a55ef49
9bd054aa5dcc465bad98f0b4b602497b--5b768dad2e324b47b8f9b0892a55ef49
5b768dad2e324b47b8f9b0892a55ef49--7e1623afa7a74a9984b993c1e9827214
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_663f44cb3f9d4f96870c6a946e0adf83
Obs.
cluster_ab8ea034a1004bcca0e2fb70a27ffd10
cluster_d52270d6533443e9b50ed245e50206fb
HEA
e2218267a3264f539bf91441c2f29fb8
0
d9fe4cebc9f6426ea680302ec4cb33a4
RX(theta₀)
e2218267a3264f539bf91441c2f29fb8--d9fe4cebc9f6426ea680302ec4cb33a4
c9b8f28e010e48e784ae0a103625840f
1
c17ca36cdf3d4becaafb8f9ec8089211
RY(theta₃)
d9fe4cebc9f6426ea680302ec4cb33a4--c17ca36cdf3d4becaafb8f9ec8089211
d23f81d347674a1faab33b386e200003
RX(theta₆)
c17ca36cdf3d4becaafb8f9ec8089211--d23f81d347674a1faab33b386e200003
378b533ea04b4001b2ec6cd80206bf68
d23f81d347674a1faab33b386e200003--378b533ea04b4001b2ec6cd80206bf68
77f5893a21384c288c872c37d70c5981
378b533ea04b4001b2ec6cd80206bf68--77f5893a21384c288c872c37d70c5981
eb73aeaf09e746dba9c95dc32e16f35d
RX(theta₉)
77f5893a21384c288c872c37d70c5981--eb73aeaf09e746dba9c95dc32e16f35d
31c7ec4a408249fab92012cb7c8cf71e
RY(theta₁₂)
eb73aeaf09e746dba9c95dc32e16f35d--31c7ec4a408249fab92012cb7c8cf71e
4194968a0c754560b388449689247068
RX(theta₁₅)
31c7ec4a408249fab92012cb7c8cf71e--4194968a0c754560b388449689247068
4e7898f1e4c14df0b2dd81c4bf846f5e
4194968a0c754560b388449689247068--4e7898f1e4c14df0b2dd81c4bf846f5e
c5eeb8d4e0ad41eab3674e0503991ff7
4e7898f1e4c14df0b2dd81c4bf846f5e--c5eeb8d4e0ad41eab3674e0503991ff7
7110cc26b38c48e6a1e57d2b188460de
c5eeb8d4e0ad41eab3674e0503991ff7--7110cc26b38c48e6a1e57d2b188460de
8c82c9f613534048827b53ea142940fb
7110cc26b38c48e6a1e57d2b188460de--8c82c9f613534048827b53ea142940fb
b66d87039e3a4337a959a3844cfbb510
39a9de3cc2284c1a85b9f71a309b2984
RX(theta₁)
c9b8f28e010e48e784ae0a103625840f--39a9de3cc2284c1a85b9f71a309b2984
ee2faf7fab4f4f82a2db4126cebaaa6a
2
2cf49464beff4b64a500455b1679dc76
RY(theta₄)
39a9de3cc2284c1a85b9f71a309b2984--2cf49464beff4b64a500455b1679dc76
acaaa01258274ca3b945de76a8b59259
RX(theta₇)
2cf49464beff4b64a500455b1679dc76--acaaa01258274ca3b945de76a8b59259
f85fdbc1447348d09ec4476c77941c80
X
acaaa01258274ca3b945de76a8b59259--f85fdbc1447348d09ec4476c77941c80
f85fdbc1447348d09ec4476c77941c80--378b533ea04b4001b2ec6cd80206bf68
3f3dd2646a7b47f8b85ab88b459ab891
f85fdbc1447348d09ec4476c77941c80--3f3dd2646a7b47f8b85ab88b459ab891
a08864c1519c43949142d5cbf655fec9
RX(theta₁₀)
3f3dd2646a7b47f8b85ab88b459ab891--a08864c1519c43949142d5cbf655fec9
d68104e2b7994e668f9c15529d8886f8
RY(theta₁₃)
a08864c1519c43949142d5cbf655fec9--d68104e2b7994e668f9c15529d8886f8
2d367697b58f4e1f872901d0054e6f7b
RX(theta₁₆)
d68104e2b7994e668f9c15529d8886f8--2d367697b58f4e1f872901d0054e6f7b
6389723b3d9246248c8ac450b46431e5
X
2d367697b58f4e1f872901d0054e6f7b--6389723b3d9246248c8ac450b46431e5
6389723b3d9246248c8ac450b46431e5--4e7898f1e4c14df0b2dd81c4bf846f5e
23ebf522463247569d8cec4576f14f19
6389723b3d9246248c8ac450b46431e5--23ebf522463247569d8cec4576f14f19
16730dcb5f3646b189db4844a002824c
AddBlock
23ebf522463247569d8cec4576f14f19--16730dcb5f3646b189db4844a002824c
16730dcb5f3646b189db4844a002824c--b66d87039e3a4337a959a3844cfbb510
fe32cffc6b28422395f273fb11785f9a
3113e567b24240a582093c43eab805a6
RX(theta₂)
ee2faf7fab4f4f82a2db4126cebaaa6a--3113e567b24240a582093c43eab805a6
7b8b4388fb1d4606830dfd80ebe5bcf5
RY(theta₅)
3113e567b24240a582093c43eab805a6--7b8b4388fb1d4606830dfd80ebe5bcf5
3de25035d85d44eea953fee6077541b5
RX(theta₈)
7b8b4388fb1d4606830dfd80ebe5bcf5--3de25035d85d44eea953fee6077541b5
99d556bacb344f82b1a3d33b6a994de7
3de25035d85d44eea953fee6077541b5--99d556bacb344f82b1a3d33b6a994de7
6b80ef7db8b54302b607721d0a3f8088
X
99d556bacb344f82b1a3d33b6a994de7--6b80ef7db8b54302b607721d0a3f8088
6b80ef7db8b54302b607721d0a3f8088--3f3dd2646a7b47f8b85ab88b459ab891
e991de26657245f78bfd14de7c552dc1
RX(theta₁₁)
6b80ef7db8b54302b607721d0a3f8088--e991de26657245f78bfd14de7c552dc1
a7b7b30150084677ab53bee6bf2dcde2
RY(theta₁₄)
e991de26657245f78bfd14de7c552dc1--a7b7b30150084677ab53bee6bf2dcde2
994ea9913e1f468cb6efd97cf35f0816
RX(theta₁₇)
a7b7b30150084677ab53bee6bf2dcde2--994ea9913e1f468cb6efd97cf35f0816
3692a8d22d124e5a9cb16fc8d78151be
994ea9913e1f468cb6efd97cf35f0816--3692a8d22d124e5a9cb16fc8d78151be
c22cc1e6d44e4b9ebe2d3b580f771bf1
X
3692a8d22d124e5a9cb16fc8d78151be--c22cc1e6d44e4b9ebe2d3b580f771bf1
c22cc1e6d44e4b9ebe2d3b580f771bf1--23ebf522463247569d8cec4576f14f19
8737ece6a0ac40489ee74b99edb09182
c22cc1e6d44e4b9ebe2d3b580f771bf1--8737ece6a0ac40489ee74b99edb09182
8737ece6a0ac40489ee74b99edb09182--fe32cffc6b28422395f273fb11785f9a
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
05682f29323b4e62b56a7a442433eb0d
0
9beac7eeb47d43269545bb9057e60da6
05682f29323b4e62b56a7a442433eb0d--9beac7eeb47d43269545bb9057e60da6
9e355244aa2f4b60b1bb0fc168fe3d1a
1
c397cd336d6e492591ff0c1abe0d85be
cfc33d7b2bb64944a217921135de6ce6
9beac7eeb47d43269545bb9057e60da6--cfc33d7b2bb64944a217921135de6ce6
24f87a8c64b7473c9856a94221c1919c
c397cd336d6e492591ff0c1abe0d85be--24f87a8c64b7473c9856a94221c1919c
be59cf25bdd049c99d26b3f6ecb9a7ca
57e9525858c0428f9e1ee24d0d563cdd
24f87a8c64b7473c9856a94221c1919c--57e9525858c0428f9e1ee24d0d563cdd
8e1108873cf940ffa38fd919be6b31f2
be59cf25bdd049c99d26b3f6ecb9a7ca--8e1108873cf940ffa38fd919be6b31f2
38b2ae92c0d24c3eb01e8b0ef39b752e
65cff32bfc4c44949e2f1d7bc33570bb
9e355244aa2f4b60b1bb0fc168fe3d1a--65cff32bfc4c44949e2f1d7bc33570bb
76016eccc9944d8bb8b0d0c97732e97b
2
65cff32bfc4c44949e2f1d7bc33570bb--c397cd336d6e492591ff0c1abe0d85be
9230b063d1e54e9fa2dd3f726a6c70cb
cfc33d7b2bb64944a217921135de6ce6--9230b063d1e54e9fa2dd3f726a6c70cb
b69c6b0981a24770bb43f964b7f16255
9230b063d1e54e9fa2dd3f726a6c70cb--b69c6b0981a24770bb43f964b7f16255
b69c6b0981a24770bb43f964b7f16255--38b2ae92c0d24c3eb01e8b0ef39b752e
0adc71a6323e40aeb97811230571ac60
819d17e930cc4401ae68d9b2f67f25d7
76016eccc9944d8bb8b0d0c97732e97b--819d17e930cc4401ae68d9b2f67f25d7
0561c5a26aa34fcfaa0ca3c68dd06252
3
aede8b018faf4288a941b8eaa6f9ae6e
819d17e930cc4401ae68d9b2f67f25d7--aede8b018faf4288a941b8eaa6f9ae6e
413e859b89884478b78afd726bbefbb4
aede8b018faf4288a941b8eaa6f9ae6e--413e859b89884478b78afd726bbefbb4
07ef109f4581488cba36033e69172366
413e859b89884478b78afd726bbefbb4--07ef109f4581488cba36033e69172366
07ef109f4581488cba36033e69172366--0adc71a6323e40aeb97811230571ac60
258b05f652b7419c9dfac7b89c43ef1e
1473ce94bf43411c9fbf44e5496fbd93
0561c5a26aa34fcfaa0ca3c68dd06252--1473ce94bf43411c9fbf44e5496fbd93
a904eda9aeb24ad8b356d8f2fd4581d3
1473ce94bf43411c9fbf44e5496fbd93--a904eda9aeb24ad8b356d8f2fd4581d3
758695331ee2484a877f469e25d2031b
a904eda9aeb24ad8b356d8f2fd4581d3--758695331ee2484a877f469e25d2031b
758695331ee2484a877f469e25d2031b--be59cf25bdd049c99d26b3f6ecb9a7ca
57e9525858c0428f9e1ee24d0d563cdd--258b05f652b7419c9dfac7b89c43ef1e
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
627c2cdf6d624f949b4953566b71f75b
0
0844121030cf4d38ac7f3e661a06efa0
627c2cdf6d624f949b4953566b71f75b--0844121030cf4d38ac7f3e661a06efa0
95bdb64179934fa1951139bf460802ce
1
133ab730faea41ec9dfc556d014a4d1a
0844121030cf4d38ac7f3e661a06efa0--133ab730faea41ec9dfc556d014a4d1a
ab74f87fb1664bf6909070781b40e434
133ab730faea41ec9dfc556d014a4d1a--ab74f87fb1664bf6909070781b40e434
3f09cb14ec874d8b8b006d9f212694ca
ab74f87fb1664bf6909070781b40e434--3f09cb14ec874d8b8b006d9f212694ca
5f8cf2b2304f45429d2deea2868779f6
f0d23555af1c4dbaa19e0db6894377e7
PHASE(0.5)
95bdb64179934fa1951139bf460802ce--f0d23555af1c4dbaa19e0db6894377e7
4b01c0a1395a4bc689948273ccacc2e9
2
f0d23555af1c4dbaa19e0db6894377e7--0844121030cf4d38ac7f3e661a06efa0
a5bb9217b91a45fda7e12c2e3652d390
f0d23555af1c4dbaa19e0db6894377e7--a5bb9217b91a45fda7e12c2e3652d390
80f90d80920c4a92b682d501427b5221
a5bb9217b91a45fda7e12c2e3652d390--80f90d80920c4a92b682d501427b5221
80f90d80920c4a92b682d501427b5221--5f8cf2b2304f45429d2deea2868779f6
f5933d000c3f4a18b30f9e95bb76f240
8600edab32c5427881713dc1ba493219
4b01c0a1395a4bc689948273ccacc2e9--8600edab32c5427881713dc1ba493219
6f687fa998444334b8784d414fb856d4
3
d1ebdcf04320477b9c24be662b3291ae
PHASE(0.5)
8600edab32c5427881713dc1ba493219--d1ebdcf04320477b9c24be662b3291ae
d1ebdcf04320477b9c24be662b3291ae--133ab730faea41ec9dfc556d014a4d1a
ef748554c8814b32ab564c321d0ee303
d1ebdcf04320477b9c24be662b3291ae--ef748554c8814b32ab564c321d0ee303
ef748554c8814b32ab564c321d0ee303--f5933d000c3f4a18b30f9e95bb76f240
36d5b0b3824244b9a0c2ca72d08d55c1
bbb760250165489799df45e5bcd12efb
6f687fa998444334b8784d414fb856d4--bbb760250165489799df45e5bcd12efb
a5172aa8d34a498fa8d34b12c01730de
bbb760250165489799df45e5bcd12efb--a5172aa8d34a498fa8d34b12c01730de
f06e4fe8847440ad9cd824251f691921
PHASE(0.5)
a5172aa8d34a498fa8d34b12c01730de--f06e4fe8847440ad9cd824251f691921
f06e4fe8847440ad9cd824251f691921--ab74f87fb1664bf6909070781b40e434
f06e4fe8847440ad9cd824251f691921--36d5b0b3824244b9a0c2ca72d08d55c1
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