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
ba8c9e9e9b304eeea98615be593a0cf3
0
22e9132b7176414c8a05f947a37fa1d6
X
ba8c9e9e9b304eeea98615be593a0cf3--22e9132b7176414c8a05f947a37fa1d6
c1760d3e88684e80acf755e51e04b665
1
5384ed69d59b42ee9cd05d82ad58eff1
22e9132b7176414c8a05f947a37fa1d6--5384ed69d59b42ee9cd05d82ad58eff1
03882abf6965441285d4e1d2b7ee6498
99f7244aebed48288316022386cc859d
Y
c1760d3e88684e80acf755e51e04b665--99f7244aebed48288316022386cc859d
99f7244aebed48288316022386cc859d--03882abf6965441285d4e1d2b7ee6498
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
3afb5811dcff4fd9bdfd9c2c0957dd3e
0
498e68d7af664ae1ac41610bef478090
X
3afb5811dcff4fd9bdfd9c2c0957dd3e--498e68d7af664ae1ac41610bef478090
058591cc8bd544bc8db722aa5bfd0b8c
Y
498e68d7af664ae1ac41610bef478090--058591cc8bd544bc8db722aa5bfd0b8c
466679780f43473fa66edbe261c58762
058591cc8bd544bc8db722aa5bfd0b8c--466679780f43473fa66edbe261c58762
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
61a272104bbc42d3bfcedd45654ba905
0
d84df934bb4f47bfbc1af88b5e40468d
X
61a272104bbc42d3bfcedd45654ba905--d84df934bb4f47bfbc1af88b5e40468d
5ccf31e27cc14f94af61f7db25143c42
1
75c168ff77be44e5af7c591256ee1862
d84df934bb4f47bfbc1af88b5e40468d--75c168ff77be44e5af7c591256ee1862
bb1840989439417caa81033446d5f165
75c168ff77be44e5af7c591256ee1862--bb1840989439417caa81033446d5f165
8f8caf2dd3354befbeea0585b8730bb9
aba44802fbc048e08d4d933d3f2b8731
5ccf31e27cc14f94af61f7db25143c42--aba44802fbc048e08d4d933d3f2b8731
3114b45a377a495fae41ef33cbf4b2c5
Y
aba44802fbc048e08d4d933d3f2b8731--3114b45a377a495fae41ef33cbf4b2c5
3114b45a377a495fae41ef33cbf4b2c5--8f8caf2dd3354befbeea0585b8730bb9
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_3fd6aced336a4b5b9a92c1ab5a7d3ebc
39343b237cef4c7f8599463248a411c2
0
3607cfb4328c4f57a98805fe0186b6e5
39343b237cef4c7f8599463248a411c2--3607cfb4328c4f57a98805fe0186b6e5
8b275aa962d5408ab6e06ac7cb06d61f
1
f35f9066b10d4bd1b277861d16abde7f
3607cfb4328c4f57a98805fe0186b6e5--f35f9066b10d4bd1b277861d16abde7f
593a5344818a4b40b0220c4008c6fb28
dfa6af22f118461b921e8791bc74ca57
AddBlock
8b275aa962d5408ab6e06ac7cb06d61f--dfa6af22f118461b921e8791bc74ca57
a34beee6bafd4508922ea4376ac67be5
2
dfa6af22f118461b921e8791bc74ca57--593a5344818a4b40b0220c4008c6fb28
994e83e7dc1a4a0c8b94136aefa4364b
bfc55ed3e12846108e2442306f7a662f
a34beee6bafd4508922ea4376ac67be5--bfc55ed3e12846108e2442306f7a662f
bfc55ed3e12846108e2442306f7a662f--994e83e7dc1a4a0c8b94136aefa4364b
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_167dd15c1896462b93f2775d36cbbb26
cluster_ac8fb995e1bb4f89a33e4a90438fe4bf
rx
d61bdea1971f44c3a8df4a1ff552c568
0
9235729a0ff24e4e9545eb5c6062b704
X
d61bdea1971f44c3a8df4a1ff552c568--9235729a0ff24e4e9545eb5c6062b704
6e95f7e4992d4a65bf026525e65e02a0
1
992bed1953dd4035a930e30a65bf4638
9235729a0ff24e4e9545eb5c6062b704--992bed1953dd4035a930e30a65bf4638
a8fa119457d54f6c94217a0480a365b0
992bed1953dd4035a930e30a65bf4638--a8fa119457d54f6c94217a0480a365b0
8fbdc9c7fa0f48bab99f04b0c41d20bc
a8fa119457d54f6c94217a0480a365b0--8fbdc9c7fa0f48bab99f04b0c41d20bc
74c40788d9084c188fe7eb5e0e3e7019
2ca3c9a5e2164b70a3749abdc1c7af06
Y
6e95f7e4992d4a65bf026525e65e02a0--2ca3c9a5e2164b70a3749abdc1c7af06
3681bec2317b4299b5f9da3042ec1856
2
47a6337120764126a9706e4e605ceffc
2ca3c9a5e2164b70a3749abdc1c7af06--47a6337120764126a9706e4e605ceffc
d69e8145f7ff4a59a730d004850c2394
HamEvo
47a6337120764126a9706e4e605ceffc--d69e8145f7ff4a59a730d004850c2394
d69e8145f7ff4a59a730d004850c2394--74c40788d9084c188fe7eb5e0e3e7019
1d8ad8cf035a4c8f9f4178bfe00229eb
cf2b96d70adb42ccb58519dafd36dd1a
RX(x)
3681bec2317b4299b5f9da3042ec1856--cf2b96d70adb42ccb58519dafd36dd1a
45d8022a8ebe42f8a0aedba400bf6412
3
4ccdfcd814d846188fbc6099681fd87b
cf2b96d70adb42ccb58519dafd36dd1a--4ccdfcd814d846188fbc6099681fd87b
3345219a6e494ef3a26ddca28d129496
t = 10
4ccdfcd814d846188fbc6099681fd87b--3345219a6e494ef3a26ddca28d129496
3345219a6e494ef3a26ddca28d129496--1d8ad8cf035a4c8f9f4178bfe00229eb
b7399478eb3f4cbfabd52a9b263eb36a
5a047ea5f9294a3fbe586ae98395d311
RX(0.5)
45d8022a8ebe42f8a0aedba400bf6412--5a047ea5f9294a3fbe586ae98395d311
b20f7c7738b14fcb953c2949c9ef0d15
X
5a047ea5f9294a3fbe586ae98395d311--b20f7c7738b14fcb953c2949c9ef0d15
b20f7c7738b14fcb953c2949c9ef0d15--4ccdfcd814d846188fbc6099681fd87b
3fc2b94a4a1f40fa93a485d959f5a4dc
b20f7c7738b14fcb953c2949c9ef0d15--3fc2b94a4a1f40fa93a485d959f5a4dc
3fc2b94a4a1f40fa93a485d959f5a4dc--b7399478eb3f4cbfabd52a9b263eb36a
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_e851226b55454f8091e69738cc5f53bb
HEA
cluster_4b69cef6de2f4bc493d7722abd465207
Tower Fourier FM
eec0e26cf9ac4b79b77550ab4f72f67d
0
44873bc822d14c18bb7b10e0758bffff
RX(1.0*phi)
eec0e26cf9ac4b79b77550ab4f72f67d--44873bc822d14c18bb7b10e0758bffff
554b3775e1574476bd3b5f6f196d10f9
1
79754e34c01f47aca37e7f8399c9b42b
RX(theta₀)
44873bc822d14c18bb7b10e0758bffff--79754e34c01f47aca37e7f8399c9b42b
a302a37a6ef94541b8557b46834fa116
RY(theta₄)
79754e34c01f47aca37e7f8399c9b42b--a302a37a6ef94541b8557b46834fa116
933a61985a7e445f8943593cde380ba5
RX(theta₈)
a302a37a6ef94541b8557b46834fa116--933a61985a7e445f8943593cde380ba5
5c37d3f654d240ac856d3fd76ad09a0a
933a61985a7e445f8943593cde380ba5--5c37d3f654d240ac856d3fd76ad09a0a
beabbd1a84ea46d0852e7a864e9d72b4
5c37d3f654d240ac856d3fd76ad09a0a--beabbd1a84ea46d0852e7a864e9d72b4
45d723772e46403e97991911bf61bb17
RX(theta₁₂)
beabbd1a84ea46d0852e7a864e9d72b4--45d723772e46403e97991911bf61bb17
1b630617d6b84ff78256df82374865fa
RY(theta₁₆)
45d723772e46403e97991911bf61bb17--1b630617d6b84ff78256df82374865fa
695cf3bd2c514c7f8f4000af4f1ef1a4
RX(theta₂₀)
1b630617d6b84ff78256df82374865fa--695cf3bd2c514c7f8f4000af4f1ef1a4
e8b9d1cb429049c4a5d8840a8d0302d9
695cf3bd2c514c7f8f4000af4f1ef1a4--e8b9d1cb429049c4a5d8840a8d0302d9
843791828bb34b60858a835afd51b7a3
e8b9d1cb429049c4a5d8840a8d0302d9--843791828bb34b60858a835afd51b7a3
0a97ef68283c4095ab717911a5a3ee2b
843791828bb34b60858a835afd51b7a3--0a97ef68283c4095ab717911a5a3ee2b
56cf3a21352841d783d37b14dcdf6518
6daf50d19a3a4988b6814c90e20196f4
RX(2.0*phi)
554b3775e1574476bd3b5f6f196d10f9--6daf50d19a3a4988b6814c90e20196f4
cf5e575adf6649d6a400fe6d1413a982
2
ceaaf4b1615a4bbeaa0e84b98cc95fdd
RX(theta₁)
6daf50d19a3a4988b6814c90e20196f4--ceaaf4b1615a4bbeaa0e84b98cc95fdd
3ae79cbb215c49ef92b4601d095c1327
RY(theta₅)
ceaaf4b1615a4bbeaa0e84b98cc95fdd--3ae79cbb215c49ef92b4601d095c1327
1901b3a797fb4080b2f07ebc436f0530
RX(theta₉)
3ae79cbb215c49ef92b4601d095c1327--1901b3a797fb4080b2f07ebc436f0530
f7817c2397114d45865f69928c6e5476
X
1901b3a797fb4080b2f07ebc436f0530--f7817c2397114d45865f69928c6e5476
f7817c2397114d45865f69928c6e5476--5c37d3f654d240ac856d3fd76ad09a0a
7ad81dd45304454c8ef65a3f1c2725bf
f7817c2397114d45865f69928c6e5476--7ad81dd45304454c8ef65a3f1c2725bf
290a89afdda4468ea003f2a093938f0e
RX(theta₁₃)
7ad81dd45304454c8ef65a3f1c2725bf--290a89afdda4468ea003f2a093938f0e
e4c3c3f229c649a6a20344f98527f350
RY(theta₁₇)
290a89afdda4468ea003f2a093938f0e--e4c3c3f229c649a6a20344f98527f350
003905bb675548f5bbd076aa896e6ffb
RX(theta₂₁)
e4c3c3f229c649a6a20344f98527f350--003905bb675548f5bbd076aa896e6ffb
95fcc00c367e49b9b5bd96df7a8dc99a
X
003905bb675548f5bbd076aa896e6ffb--95fcc00c367e49b9b5bd96df7a8dc99a
95fcc00c367e49b9b5bd96df7a8dc99a--e8b9d1cb429049c4a5d8840a8d0302d9
d024be2bf17a4c51ab165524979ba11a
95fcc00c367e49b9b5bd96df7a8dc99a--d024be2bf17a4c51ab165524979ba11a
d024be2bf17a4c51ab165524979ba11a--56cf3a21352841d783d37b14dcdf6518
f95cc9bffe754ae4afaa033d2392595c
ce7d9736d23d4fcca0b734cbc9f657f6
RX(3.0*phi)
cf5e575adf6649d6a400fe6d1413a982--ce7d9736d23d4fcca0b734cbc9f657f6
2699085219aa461a9eadf8d49f367a55
3
08f469a6198d438a8670c8a4162aa025
RX(theta₂)
ce7d9736d23d4fcca0b734cbc9f657f6--08f469a6198d438a8670c8a4162aa025
8f42d007eb244aeaafe130a6275f5bfc
RY(theta₆)
08f469a6198d438a8670c8a4162aa025--8f42d007eb244aeaafe130a6275f5bfc
7b675896924843b6b41f2af20798907e
RX(theta₁₀)
8f42d007eb244aeaafe130a6275f5bfc--7b675896924843b6b41f2af20798907e
3734db71883e4902bbaece18413b4f09
7b675896924843b6b41f2af20798907e--3734db71883e4902bbaece18413b4f09
dae556c540d64da69438a3c28692fcae
X
3734db71883e4902bbaece18413b4f09--dae556c540d64da69438a3c28692fcae
dae556c540d64da69438a3c28692fcae--7ad81dd45304454c8ef65a3f1c2725bf
0a88adece9d54eae84ed238b6b79c405
RX(theta₁₄)
dae556c540d64da69438a3c28692fcae--0a88adece9d54eae84ed238b6b79c405
6f55497b5be84cdca2f0cab306a93031
RY(theta₁₈)
0a88adece9d54eae84ed238b6b79c405--6f55497b5be84cdca2f0cab306a93031
4c7e4d3864ea4c54a44c4d4e7fae4740
RX(theta₂₂)
6f55497b5be84cdca2f0cab306a93031--4c7e4d3864ea4c54a44c4d4e7fae4740
756a8c1285f54bbfac00ff9e7454e172
4c7e4d3864ea4c54a44c4d4e7fae4740--756a8c1285f54bbfac00ff9e7454e172
1e9a005efb3840f28ad091afcecf2e8f
X
756a8c1285f54bbfac00ff9e7454e172--1e9a005efb3840f28ad091afcecf2e8f
1e9a005efb3840f28ad091afcecf2e8f--d024be2bf17a4c51ab165524979ba11a
1e9a005efb3840f28ad091afcecf2e8f--f95cc9bffe754ae4afaa033d2392595c
f00313b4e3cb4e56af2a38ba6179785a
3f743f59c0874f5e8c70306261d3b0d3
RX(4.0*phi)
2699085219aa461a9eadf8d49f367a55--3f743f59c0874f5e8c70306261d3b0d3
b239b1611832434fafa7d81b823c20fa
RX(theta₃)
3f743f59c0874f5e8c70306261d3b0d3--b239b1611832434fafa7d81b823c20fa
da1d4d327afe480598080fa467479caa
RY(theta₇)
b239b1611832434fafa7d81b823c20fa--da1d4d327afe480598080fa467479caa
a48563c5ec3e4a928f554cc1bd828f69
RX(theta₁₁)
da1d4d327afe480598080fa467479caa--a48563c5ec3e4a928f554cc1bd828f69
7fdfa8fc083c4e94bf744cee8fe014d8
X
a48563c5ec3e4a928f554cc1bd828f69--7fdfa8fc083c4e94bf744cee8fe014d8
7fdfa8fc083c4e94bf744cee8fe014d8--3734db71883e4902bbaece18413b4f09
1a3a7ad6dc754e6485192bfefb8404e6
7fdfa8fc083c4e94bf744cee8fe014d8--1a3a7ad6dc754e6485192bfefb8404e6
a8b00aad1a4e47b193cbaf5c36ef9906
RX(theta₁₅)
1a3a7ad6dc754e6485192bfefb8404e6--a8b00aad1a4e47b193cbaf5c36ef9906
aa2106ad25d74a63a00c369d642656e6
RY(theta₁₉)
a8b00aad1a4e47b193cbaf5c36ef9906--aa2106ad25d74a63a00c369d642656e6
57e7b133197241048d2c8a97d09c86e0
RX(theta₂₃)
aa2106ad25d74a63a00c369d642656e6--57e7b133197241048d2c8a97d09c86e0
8943396161334737a90e7458d547ce93
X
57e7b133197241048d2c8a97d09c86e0--8943396161334737a90e7458d547ce93
8943396161334737a90e7458d547ce93--756a8c1285f54bbfac00ff9e7454e172
6df92e44a2444c9687d7de93ffe2fd07
8943396161334737a90e7458d547ce93--6df92e44a2444c9687d7de93ffe2fd07
6df92e44a2444c9687d7de93ffe2fd07--f00313b4e3cb4e56af2a38ba6179785a
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_1f2e64d452df4f4685b5264a41542ece
Obs.
cluster_6ecb97dd336b429a9b2642ac3f9b3c5f
cluster_3de192d14bd9448b8e4a17a29d4a070e
HEA
d08dec7bc7e641d9bb4410a963ddad97
0
6362823bfc0c431cbafa88629d373c6c
RX(theta₀)
d08dec7bc7e641d9bb4410a963ddad97--6362823bfc0c431cbafa88629d373c6c
e22d7fe87de747cb80310c9dd70f3c07
1
a11ca3434be3409d8bee106ffaf9fc77
RY(theta₃)
6362823bfc0c431cbafa88629d373c6c--a11ca3434be3409d8bee106ffaf9fc77
65679b3ba542416983c18b02c86da0a4
RX(theta₆)
a11ca3434be3409d8bee106ffaf9fc77--65679b3ba542416983c18b02c86da0a4
e1e2a645cc4c4e588da28c9f454115db
65679b3ba542416983c18b02c86da0a4--e1e2a645cc4c4e588da28c9f454115db
3802dd6f7f7b4422ba53a48249b8c05f
e1e2a645cc4c4e588da28c9f454115db--3802dd6f7f7b4422ba53a48249b8c05f
fcbf89a953e447e997a00c46d2c4789b
RX(theta₉)
3802dd6f7f7b4422ba53a48249b8c05f--fcbf89a953e447e997a00c46d2c4789b
0866aaa6b2e74457ab1ad2b2a22343a8
RY(theta₁₂)
fcbf89a953e447e997a00c46d2c4789b--0866aaa6b2e74457ab1ad2b2a22343a8
3aa614a9a5d54d62ba1160763ea32ac3
RX(theta₁₅)
0866aaa6b2e74457ab1ad2b2a22343a8--3aa614a9a5d54d62ba1160763ea32ac3
f117f7fcec974d889050216ca5e2202f
3aa614a9a5d54d62ba1160763ea32ac3--f117f7fcec974d889050216ca5e2202f
da01574b5cb4431f9f1c3c585ffaeac7
f117f7fcec974d889050216ca5e2202f--da01574b5cb4431f9f1c3c585ffaeac7
f6ff5edd72fe4decb945b5a506be07a6
da01574b5cb4431f9f1c3c585ffaeac7--f6ff5edd72fe4decb945b5a506be07a6
d72d07afc2f74f26861803152c350f49
f6ff5edd72fe4decb945b5a506be07a6--d72d07afc2f74f26861803152c350f49
04348084acf04dd2ae8ece36ede69109
d2b455cecda54e6d9c96318dd1833209
RX(theta₁)
e22d7fe87de747cb80310c9dd70f3c07--d2b455cecda54e6d9c96318dd1833209
acb617c980b34b3ab5d0ab73b3eed746
2
2dab2c9c972d4fef988bb39000ed7667
RY(theta₄)
d2b455cecda54e6d9c96318dd1833209--2dab2c9c972d4fef988bb39000ed7667
894923cadc904cc88fbd6cd05e637b50
RX(theta₇)
2dab2c9c972d4fef988bb39000ed7667--894923cadc904cc88fbd6cd05e637b50
89b3fbb084d647eda2e9b5623cd53b4e
X
894923cadc904cc88fbd6cd05e637b50--89b3fbb084d647eda2e9b5623cd53b4e
89b3fbb084d647eda2e9b5623cd53b4e--e1e2a645cc4c4e588da28c9f454115db
50bd348fb3f74dcb82dd06b8bbc990b7
89b3fbb084d647eda2e9b5623cd53b4e--50bd348fb3f74dcb82dd06b8bbc990b7
31c36ba7468948c192e589e919274bef
RX(theta₁₀)
50bd348fb3f74dcb82dd06b8bbc990b7--31c36ba7468948c192e589e919274bef
b66e7d15bbd1474788a48a7060b2c14a
RY(theta₁₃)
31c36ba7468948c192e589e919274bef--b66e7d15bbd1474788a48a7060b2c14a
68d1a96b9c014c40b9684d65c8f6ebe2
RX(theta₁₆)
b66e7d15bbd1474788a48a7060b2c14a--68d1a96b9c014c40b9684d65c8f6ebe2
40bfa95beb4745f9a9b8a4b21cd18d8e
X
68d1a96b9c014c40b9684d65c8f6ebe2--40bfa95beb4745f9a9b8a4b21cd18d8e
40bfa95beb4745f9a9b8a4b21cd18d8e--f117f7fcec974d889050216ca5e2202f
5f6d96c7750e47fdac3c2b04a78f16b9
40bfa95beb4745f9a9b8a4b21cd18d8e--5f6d96c7750e47fdac3c2b04a78f16b9
724f92dbb4004f4db592b62d4c68d219
AddBlock
5f6d96c7750e47fdac3c2b04a78f16b9--724f92dbb4004f4db592b62d4c68d219
724f92dbb4004f4db592b62d4c68d219--04348084acf04dd2ae8ece36ede69109
48656ee100024cc299666d587631d454
435b4125c9a242a39d9625ab980961a0
RX(theta₂)
acb617c980b34b3ab5d0ab73b3eed746--435b4125c9a242a39d9625ab980961a0
02c2d2d09a3a437985fbfa1831a4eb66
RY(theta₅)
435b4125c9a242a39d9625ab980961a0--02c2d2d09a3a437985fbfa1831a4eb66
5e40c5421e0e48e0ad11aa913fa0237f
RX(theta₈)
02c2d2d09a3a437985fbfa1831a4eb66--5e40c5421e0e48e0ad11aa913fa0237f
30d74566871946048a0ab281143161a3
5e40c5421e0e48e0ad11aa913fa0237f--30d74566871946048a0ab281143161a3
58669962b08e4bab8b44c73e8be998ee
X
30d74566871946048a0ab281143161a3--58669962b08e4bab8b44c73e8be998ee
58669962b08e4bab8b44c73e8be998ee--50bd348fb3f74dcb82dd06b8bbc990b7
469309d52d864e998889829cb15c0034
RX(theta₁₁)
58669962b08e4bab8b44c73e8be998ee--469309d52d864e998889829cb15c0034
5be51dbdb287480f8a688e1dceee08bc
RY(theta₁₄)
469309d52d864e998889829cb15c0034--5be51dbdb287480f8a688e1dceee08bc
2c21996ca2524f12a5ad28a4e9ecdf0a
RX(theta₁₇)
5be51dbdb287480f8a688e1dceee08bc--2c21996ca2524f12a5ad28a4e9ecdf0a
203f66f79c9b48d68901fbfb0d3395dc
2c21996ca2524f12a5ad28a4e9ecdf0a--203f66f79c9b48d68901fbfb0d3395dc
c50e427a61b1406bbfc6a1300225b047
X
203f66f79c9b48d68901fbfb0d3395dc--c50e427a61b1406bbfc6a1300225b047
c50e427a61b1406bbfc6a1300225b047--5f6d96c7750e47fdac3c2b04a78f16b9
4bd8b839556f497592e85be7cdcf714e
c50e427a61b1406bbfc6a1300225b047--4bd8b839556f497592e85be7cdcf714e
4bd8b839556f497592e85be7cdcf714e--48656ee100024cc299666d587631d454
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
b6ea8a86bae245e9b55ff86e372e5076
0
f572e90184ac451aab79dcb761bea0a3
b6ea8a86bae245e9b55ff86e372e5076--f572e90184ac451aab79dcb761bea0a3
cc563b03ae104d2cb7e0105c1676e5ce
1
158c9f0d67af4212b89778814fe8fce4
cd612778277f4fe8a350b264bbc7ad35
f572e90184ac451aab79dcb761bea0a3--cd612778277f4fe8a350b264bbc7ad35
fa7a2435eb63476d9c05c54a3d6fcc9f
158c9f0d67af4212b89778814fe8fce4--fa7a2435eb63476d9c05c54a3d6fcc9f
51ea6dbd93484158a2bf96bb8c370f4e
a25f85f2c0154c9a843f5748dd67c410
fa7a2435eb63476d9c05c54a3d6fcc9f--a25f85f2c0154c9a843f5748dd67c410
56a7c943f01f4ce5ac1b841ffdc6cf7a
51ea6dbd93484158a2bf96bb8c370f4e--56a7c943f01f4ce5ac1b841ffdc6cf7a
271b851e69f44986b7e697523ed53729
65d109788c064c02a51d8a0e6d1a7f82
cc563b03ae104d2cb7e0105c1676e5ce--65d109788c064c02a51d8a0e6d1a7f82
998a55f974e543f9ae3ac30269ed0c69
2
65d109788c064c02a51d8a0e6d1a7f82--158c9f0d67af4212b89778814fe8fce4
23729789557f40b1be4b7794282b0a9d
cd612778277f4fe8a350b264bbc7ad35--23729789557f40b1be4b7794282b0a9d
bb3d54bb0edb48f88e83a3fdfcef66a7
23729789557f40b1be4b7794282b0a9d--bb3d54bb0edb48f88e83a3fdfcef66a7
bb3d54bb0edb48f88e83a3fdfcef66a7--271b851e69f44986b7e697523ed53729
7243d49a57fa469f96a3b9606c58b2fd
5a3c759db20c4c9d8a4918d3e83db756
998a55f974e543f9ae3ac30269ed0c69--5a3c759db20c4c9d8a4918d3e83db756
c9b127d85e934403b136b5be7520c43b
3
a7429a3a0cc74394bd9b2c7bc0a8e275
5a3c759db20c4c9d8a4918d3e83db756--a7429a3a0cc74394bd9b2c7bc0a8e275
fdeeb7b58d79440890a2e5d0f9267b9b
a7429a3a0cc74394bd9b2c7bc0a8e275--fdeeb7b58d79440890a2e5d0f9267b9b
b902aa135bcb42e48770ee7fa6006b47
fdeeb7b58d79440890a2e5d0f9267b9b--b902aa135bcb42e48770ee7fa6006b47
b902aa135bcb42e48770ee7fa6006b47--7243d49a57fa469f96a3b9606c58b2fd
590c9b2957cc422aaedd205f683d0fcd
dfc19db35e3c46a1b463a230f462eb77
c9b127d85e934403b136b5be7520c43b--dfc19db35e3c46a1b463a230f462eb77
dc5329fdb79841c98543d49967d6ea2d
dfc19db35e3c46a1b463a230f462eb77--dc5329fdb79841c98543d49967d6ea2d
72acef8e1f1f40bf98ef7722cbf5c3ac
dc5329fdb79841c98543d49967d6ea2d--72acef8e1f1f40bf98ef7722cbf5c3ac
72acef8e1f1f40bf98ef7722cbf5c3ac--51ea6dbd93484158a2bf96bb8c370f4e
a25f85f2c0154c9a843f5748dd67c410--590c9b2957cc422aaedd205f683d0fcd
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
9ed2b425edf2451397a3a303a9122763
0
b3a61a76d03e4fe7bdaa2a1d20ac70c4
9ed2b425edf2451397a3a303a9122763--b3a61a76d03e4fe7bdaa2a1d20ac70c4
21a816877fa24a3b91bbf30e3c0d639b
1
69ce70317e5e4ab7b7941b58047cedd4
b3a61a76d03e4fe7bdaa2a1d20ac70c4--69ce70317e5e4ab7b7941b58047cedd4
c6e9a2583d00462eb91f4fdcc4e0659a
69ce70317e5e4ab7b7941b58047cedd4--c6e9a2583d00462eb91f4fdcc4e0659a
72be0461deef463898bbd3f77b7bc596
c6e9a2583d00462eb91f4fdcc4e0659a--72be0461deef463898bbd3f77b7bc596
943c1fccbeb844539f4974a9b7f4130f
9f4cc71f00844b8c943ceacd7617af07
PHASE(0.5)
21a816877fa24a3b91bbf30e3c0d639b--9f4cc71f00844b8c943ceacd7617af07
ff9e8363ebc34a94a9c897389989122f
2
9f4cc71f00844b8c943ceacd7617af07--b3a61a76d03e4fe7bdaa2a1d20ac70c4
415a6b38c25e4fff97339ab34227000b
9f4cc71f00844b8c943ceacd7617af07--415a6b38c25e4fff97339ab34227000b
90b83476b403401d97c532d9fcd202a8
415a6b38c25e4fff97339ab34227000b--90b83476b403401d97c532d9fcd202a8
90b83476b403401d97c532d9fcd202a8--943c1fccbeb844539f4974a9b7f4130f
3302778de17d47af94413bbdc4066257
7de4bacd606b45199260859eb04fa1ac
ff9e8363ebc34a94a9c897389989122f--7de4bacd606b45199260859eb04fa1ac
61390a1f32f94248a8de858ad82217db
3
5a98443088d84d14a4c4fb21ab9a33aa
PHASE(0.5)
7de4bacd606b45199260859eb04fa1ac--5a98443088d84d14a4c4fb21ab9a33aa
5a98443088d84d14a4c4fb21ab9a33aa--69ce70317e5e4ab7b7941b58047cedd4
9039a5e3b4554b8bb93f9174b5bc78df
5a98443088d84d14a4c4fb21ab9a33aa--9039a5e3b4554b8bb93f9174b5bc78df
9039a5e3b4554b8bb93f9174b5bc78df--3302778de17d47af94413bbdc4066257
883b6a10eac04d3bb8aa796464222687
863da0eee0f54b1da7d7693e0d8058b8
61390a1f32f94248a8de858ad82217db--863da0eee0f54b1da7d7693e0d8058b8
8a2ae533f9364825b3ff260043ab4398
863da0eee0f54b1da7d7693e0d8058b8--8a2ae533f9364825b3ff260043ab4398
38901dfd97e74c11b2b30cecd660e15e
PHASE(0.5)
8a2ae533f9364825b3ff260043ab4398--38901dfd97e74c11b2b30cecd660e15e
38901dfd97e74c11b2b30cecd660e15e--c6e9a2583d00462eb91f4fdcc4e0659a
38901dfd97e74c11b2b30cecd660e15e--883b6a10eac04d3bb8aa796464222687
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