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
0f985066561f43289b27b20d1f347610
0
89b5dab7f33f4ec59b7a7afd453e7747
X
0f985066561f43289b27b20d1f347610--89b5dab7f33f4ec59b7a7afd453e7747
5fca571199b34ea5b07aa6c0e593ba19
1
eb8746f4848246b08e5ed49562cd4c69
89b5dab7f33f4ec59b7a7afd453e7747--eb8746f4848246b08e5ed49562cd4c69
0ea649cf208a40baac1da4a3ca06351c
aea06944a92a405496a9610fcd999b4f
Y
5fca571199b34ea5b07aa6c0e593ba19--aea06944a92a405496a9610fcd999b4f
aea06944a92a405496a9610fcd999b4f--0ea649cf208a40baac1da4a3ca06351c
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
b791f011a76e4085af4dbcdbd0c65458
0
9318355879614cf0a3ab36477cc51b43
X
b791f011a76e4085af4dbcdbd0c65458--9318355879614cf0a3ab36477cc51b43
c236454f4878467b83130f7eda3ae060
Y
9318355879614cf0a3ab36477cc51b43--c236454f4878467b83130f7eda3ae060
c6d7e5cd3d8049b38f11aa60bdbd3a56
c236454f4878467b83130f7eda3ae060--c6d7e5cd3d8049b38f11aa60bdbd3a56
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
44c3696076714c9da04bb62fb455e777
0
034e3bae76734a9e997a0e2f38660169
X
44c3696076714c9da04bb62fb455e777--034e3bae76734a9e997a0e2f38660169
f6be07c094c541b89629e48b7b0cc2d1
1
01c984f9163e46dfab9e3c6e14f5e54a
034e3bae76734a9e997a0e2f38660169--01c984f9163e46dfab9e3c6e14f5e54a
f5ba07e411b045bdba1ad8bfabec3243
01c984f9163e46dfab9e3c6e14f5e54a--f5ba07e411b045bdba1ad8bfabec3243
c5c508f74b4646daa00d2689353b58b1
f57cf67ba3b045049d157f46b8279dce
f6be07c094c541b89629e48b7b0cc2d1--f57cf67ba3b045049d157f46b8279dce
64c4fb6ea1e04c05a4ef937fefbf6057
Y
f57cf67ba3b045049d157f46b8279dce--64c4fb6ea1e04c05a4ef937fefbf6057
64c4fb6ea1e04c05a4ef937fefbf6057--c5c508f74b4646daa00d2689353b58b1
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_1d7af96499ae4f76abcb66e10d551bd0
ce519cebe8114e44951096d072e6ed63
0
9955f73a9fbb408eb9996f4e8649e61e
ce519cebe8114e44951096d072e6ed63--9955f73a9fbb408eb9996f4e8649e61e
e250108b1e9b4c32bf0afc437359a424
1
1bdd05ad086e463ebd87ff7f38803716
9955f73a9fbb408eb9996f4e8649e61e--1bdd05ad086e463ebd87ff7f38803716
b27ffe92ddae4385a35ad960cbb5568f
706956d452ee47768866077ab6017084
AddBlock
e250108b1e9b4c32bf0afc437359a424--706956d452ee47768866077ab6017084
b419bbebe1d2434681c338093c88d211
2
706956d452ee47768866077ab6017084--b27ffe92ddae4385a35ad960cbb5568f
7ba57305f95c4ddebb96e5a68b981bfb
99fc3257d35d464ca882930263847d0e
b419bbebe1d2434681c338093c88d211--99fc3257d35d464ca882930263847d0e
99fc3257d35d464ca882930263847d0e--7ba57305f95c4ddebb96e5a68b981bfb
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_5461e5fe55074e119b42d14a07183d38
cluster_f937245e35aa42938b55d942cdd7df4e
rx
145110803dad4b759bb46ec3d0821582
0
a75a1719a14241cab0004e4ae29eb834
X
145110803dad4b759bb46ec3d0821582--a75a1719a14241cab0004e4ae29eb834
78746e663e5f449f9411cdf90f678f93
1
767e84d7ba5d4e21b578ea8854ae285f
a75a1719a14241cab0004e4ae29eb834--767e84d7ba5d4e21b578ea8854ae285f
523d148d92f849c3b5503a1bacf64709
767e84d7ba5d4e21b578ea8854ae285f--523d148d92f849c3b5503a1bacf64709
1454c4b003f94c2f9176a275b4fc9c36
523d148d92f849c3b5503a1bacf64709--1454c4b003f94c2f9176a275b4fc9c36
fdc3ba62621143b09d63abcd2d611d6c
7a21fd6ca96440b8a22b5d0156994a2f
Y
78746e663e5f449f9411cdf90f678f93--7a21fd6ca96440b8a22b5d0156994a2f
aa2dbf00a92246919bc0f8667a066833
2
6286ba4497cd45afacb1e563b60cd330
7a21fd6ca96440b8a22b5d0156994a2f--6286ba4497cd45afacb1e563b60cd330
3b5d359f09a9480cbf8b18a787e2dbdf
HamEvo
6286ba4497cd45afacb1e563b60cd330--3b5d359f09a9480cbf8b18a787e2dbdf
3b5d359f09a9480cbf8b18a787e2dbdf--fdc3ba62621143b09d63abcd2d611d6c
44df5274898e474280d762b6ec7b4ece
2f8dbdff62d54ff7a228ccccfc750426
RX(x)
aa2dbf00a92246919bc0f8667a066833--2f8dbdff62d54ff7a228ccccfc750426
25239e06293b459d928586a2366acae7
3
b186236aa8e147bb8380da1e387f357e
2f8dbdff62d54ff7a228ccccfc750426--b186236aa8e147bb8380da1e387f357e
7a8e743a51cb4690950e55b20dbb2392
t = 10
b186236aa8e147bb8380da1e387f357e--7a8e743a51cb4690950e55b20dbb2392
7a8e743a51cb4690950e55b20dbb2392--44df5274898e474280d762b6ec7b4ece
8f722010c5c74c2f955bc333848dd97f
009ba00ff207448ba20728df73fb1df0
RX(0.5)
25239e06293b459d928586a2366acae7--009ba00ff207448ba20728df73fb1df0
6b828b4f50d94bee99148ff67a503c7d
X
009ba00ff207448ba20728df73fb1df0--6b828b4f50d94bee99148ff67a503c7d
6b828b4f50d94bee99148ff67a503c7d--b186236aa8e147bb8380da1e387f357e
6376a265226747ddb2cf8b6e2494498b
6b828b4f50d94bee99148ff67a503c7d--6376a265226747ddb2cf8b6e2494498b
6376a265226747ddb2cf8b6e2494498b--8f722010c5c74c2f955bc333848dd97f
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_5efad37a8f114dafaf3b6ca689fd1759
HEA
cluster_1c3fb2a7e77c47c28a4b812c4c7eeb8f
Tower Fourier FM
bcc3b077a49f4aabaeadb9141788bc80
0
16b87521288343cb8e2105f26e13e056
RX(1.0*phi)
bcc3b077a49f4aabaeadb9141788bc80--16b87521288343cb8e2105f26e13e056
96e2dce3ed7b463386e5a08d6d1df92e
1
c2aa6aebb2b14dfab7cc92420335d392
RX(theta₀)
16b87521288343cb8e2105f26e13e056--c2aa6aebb2b14dfab7cc92420335d392
2c7b3521bcf54faaad36666cf0bea26e
RY(theta₄)
c2aa6aebb2b14dfab7cc92420335d392--2c7b3521bcf54faaad36666cf0bea26e
54ae1da71fbd43da8ac55c4ca5cba58c
RX(theta₈)
2c7b3521bcf54faaad36666cf0bea26e--54ae1da71fbd43da8ac55c4ca5cba58c
cab912a0c9d345bcba6935fea338c090
54ae1da71fbd43da8ac55c4ca5cba58c--cab912a0c9d345bcba6935fea338c090
f0a062f46eec4fdf93e351d357ba1f65
cab912a0c9d345bcba6935fea338c090--f0a062f46eec4fdf93e351d357ba1f65
e08544ac462749f497d810bb7fe4fc75
RX(theta₁₂)
f0a062f46eec4fdf93e351d357ba1f65--e08544ac462749f497d810bb7fe4fc75
52286ab27aa34d09afce773c595bd01a
RY(theta₁₆)
e08544ac462749f497d810bb7fe4fc75--52286ab27aa34d09afce773c595bd01a
66b4bc78bb194898959ab461f73e68f7
RX(theta₂₀)
52286ab27aa34d09afce773c595bd01a--66b4bc78bb194898959ab461f73e68f7
0461816a0beb472f9ece4023776bc773
66b4bc78bb194898959ab461f73e68f7--0461816a0beb472f9ece4023776bc773
9158108739ab41fa96db888a2ba420c8
0461816a0beb472f9ece4023776bc773--9158108739ab41fa96db888a2ba420c8
b497a93817324c6aa7436f6e2ed1a18f
9158108739ab41fa96db888a2ba420c8--b497a93817324c6aa7436f6e2ed1a18f
2c09a74c611743158c08fe324015283d
d609a7a3ba834e12afd8efdfa061692c
RX(2.0*phi)
96e2dce3ed7b463386e5a08d6d1df92e--d609a7a3ba834e12afd8efdfa061692c
15947be51ee742f5a9261ebb5d8f3504
2
ff2ede35fe9b4945812aff57116598ba
RX(theta₁)
d609a7a3ba834e12afd8efdfa061692c--ff2ede35fe9b4945812aff57116598ba
689595c985b9418e9cb9143637a41b72
RY(theta₅)
ff2ede35fe9b4945812aff57116598ba--689595c985b9418e9cb9143637a41b72
277835ca4fba48139d250b3a861f74bf
RX(theta₉)
689595c985b9418e9cb9143637a41b72--277835ca4fba48139d250b3a861f74bf
db52a66a024d475aab97b303880e0165
X
277835ca4fba48139d250b3a861f74bf--db52a66a024d475aab97b303880e0165
db52a66a024d475aab97b303880e0165--cab912a0c9d345bcba6935fea338c090
d5a4a1e6274541ada3f086fbb3e62395
db52a66a024d475aab97b303880e0165--d5a4a1e6274541ada3f086fbb3e62395
d0b5da6ea2c94d18bc78281b6fc0b504
RX(theta₁₃)
d5a4a1e6274541ada3f086fbb3e62395--d0b5da6ea2c94d18bc78281b6fc0b504
dee6c6b0f92c4a579c7633e9dd401d5e
RY(theta₁₇)
d0b5da6ea2c94d18bc78281b6fc0b504--dee6c6b0f92c4a579c7633e9dd401d5e
29face3172d1474c82ee2178c77cc06d
RX(theta₂₁)
dee6c6b0f92c4a579c7633e9dd401d5e--29face3172d1474c82ee2178c77cc06d
8e0cc42d58164a799be834280cc91d5f
X
29face3172d1474c82ee2178c77cc06d--8e0cc42d58164a799be834280cc91d5f
8e0cc42d58164a799be834280cc91d5f--0461816a0beb472f9ece4023776bc773
89576f3cc4c04d53ae02a03dc2906a89
8e0cc42d58164a799be834280cc91d5f--89576f3cc4c04d53ae02a03dc2906a89
89576f3cc4c04d53ae02a03dc2906a89--2c09a74c611743158c08fe324015283d
f3a7eb5ceca04d9cb32042cb2b8a2f60
de57af4d1a604deeac26c5877403e97c
RX(3.0*phi)
15947be51ee742f5a9261ebb5d8f3504--de57af4d1a604deeac26c5877403e97c
03a47ac20eb94fefb47a0bf1b2c2d151
3
82713002d6884bf0a07d1422bd5b5045
RX(theta₂)
de57af4d1a604deeac26c5877403e97c--82713002d6884bf0a07d1422bd5b5045
9a91a75b47a343f48b2a5d82e8ec91a3
RY(theta₆)
82713002d6884bf0a07d1422bd5b5045--9a91a75b47a343f48b2a5d82e8ec91a3
67b610168e5643df9e1436e2ced5acc4
RX(theta₁₀)
9a91a75b47a343f48b2a5d82e8ec91a3--67b610168e5643df9e1436e2ced5acc4
37be3d2797f144d3bf06266368757be4
67b610168e5643df9e1436e2ced5acc4--37be3d2797f144d3bf06266368757be4
3c433290fd0544d9a23077d02dd2c4bf
X
37be3d2797f144d3bf06266368757be4--3c433290fd0544d9a23077d02dd2c4bf
3c433290fd0544d9a23077d02dd2c4bf--d5a4a1e6274541ada3f086fbb3e62395
928eabddc60d4b1ab664ee0383bfb0b2
RX(theta₁₄)
3c433290fd0544d9a23077d02dd2c4bf--928eabddc60d4b1ab664ee0383bfb0b2
0158d84df25d4a4f84b00fdb1cb15042
RY(theta₁₈)
928eabddc60d4b1ab664ee0383bfb0b2--0158d84df25d4a4f84b00fdb1cb15042
d22024e791784a8ba6176b4c6fa26bbf
RX(theta₂₂)
0158d84df25d4a4f84b00fdb1cb15042--d22024e791784a8ba6176b4c6fa26bbf
6902b34c84c0433b9b7592961903f4d6
d22024e791784a8ba6176b4c6fa26bbf--6902b34c84c0433b9b7592961903f4d6
c92804c0552e4078bfc852ec63a3674e
X
6902b34c84c0433b9b7592961903f4d6--c92804c0552e4078bfc852ec63a3674e
c92804c0552e4078bfc852ec63a3674e--89576f3cc4c04d53ae02a03dc2906a89
c92804c0552e4078bfc852ec63a3674e--f3a7eb5ceca04d9cb32042cb2b8a2f60
2908ff6d577148789656662e77110cf3
38f9d445a3654439b1d0f2b7d329f5f9
RX(4.0*phi)
03a47ac20eb94fefb47a0bf1b2c2d151--38f9d445a3654439b1d0f2b7d329f5f9
abeb7bcdbe9f45b58c739adadff67c77
RX(theta₃)
38f9d445a3654439b1d0f2b7d329f5f9--abeb7bcdbe9f45b58c739adadff67c77
66ed7ea34ac44cba9d84a94b31e731df
RY(theta₇)
abeb7bcdbe9f45b58c739adadff67c77--66ed7ea34ac44cba9d84a94b31e731df
662cf91fe39048cb9efac6833baa5512
RX(theta₁₁)
66ed7ea34ac44cba9d84a94b31e731df--662cf91fe39048cb9efac6833baa5512
34885334693840ba800c97f01a8c7a15
X
662cf91fe39048cb9efac6833baa5512--34885334693840ba800c97f01a8c7a15
34885334693840ba800c97f01a8c7a15--37be3d2797f144d3bf06266368757be4
98a045e813a84828b5b6184cfaadbb51
34885334693840ba800c97f01a8c7a15--98a045e813a84828b5b6184cfaadbb51
e69f6c9d5e474796b9368b3aa05c5723
RX(theta₁₅)
98a045e813a84828b5b6184cfaadbb51--e69f6c9d5e474796b9368b3aa05c5723
a67e60edc2694321bcaf87ec61670de6
RY(theta₁₉)
e69f6c9d5e474796b9368b3aa05c5723--a67e60edc2694321bcaf87ec61670de6
f018830e1d7c44858eeb59c88c5be8c8
RX(theta₂₃)
a67e60edc2694321bcaf87ec61670de6--f018830e1d7c44858eeb59c88c5be8c8
2a4b2adb0789434aa3bfd2b606b3f14b
X
f018830e1d7c44858eeb59c88c5be8c8--2a4b2adb0789434aa3bfd2b606b3f14b
2a4b2adb0789434aa3bfd2b606b3f14b--6902b34c84c0433b9b7592961903f4d6
3cd76861b889410aa8528b2737e20c61
2a4b2adb0789434aa3bfd2b606b3f14b--3cd76861b889410aa8528b2737e20c61
3cd76861b889410aa8528b2737e20c61--2908ff6d577148789656662e77110cf3
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_2d5ad19cf8784211ae5b27c613cf7b9f
Obs.
cluster_ff68cce0e2194640b884dbdd6169a4cc
cluster_67f8ed83fa064be9b8c437e0032de920
HEA
771ecdcb1fb9476c9bec55d5bf5e2a12
0
94699c45168843a9bc5ce30aa56bf329
RX(theta₀)
771ecdcb1fb9476c9bec55d5bf5e2a12--94699c45168843a9bc5ce30aa56bf329
6b5f53f431c3452d81723ac15497b65a
1
6f7d168c863e40ec88f937ef2d1d5213
RY(theta₃)
94699c45168843a9bc5ce30aa56bf329--6f7d168c863e40ec88f937ef2d1d5213
3c97611b3e6a45158802e9e660bf6669
RX(theta₆)
6f7d168c863e40ec88f937ef2d1d5213--3c97611b3e6a45158802e9e660bf6669
9d413e57baf9422aa7a948a31e30250c
3c97611b3e6a45158802e9e660bf6669--9d413e57baf9422aa7a948a31e30250c
8d295d34c0a64f7cb21057cb7a64ae9a
9d413e57baf9422aa7a948a31e30250c--8d295d34c0a64f7cb21057cb7a64ae9a
f9617ccae08c4ed8b082f40a0c1c47ea
RX(theta₉)
8d295d34c0a64f7cb21057cb7a64ae9a--f9617ccae08c4ed8b082f40a0c1c47ea
8c0bd92a9e244a63a0eda4aa406f9026
RY(theta₁₂)
f9617ccae08c4ed8b082f40a0c1c47ea--8c0bd92a9e244a63a0eda4aa406f9026
2b7e84532cad4983a2fba85abd72d0c0
RX(theta₁₅)
8c0bd92a9e244a63a0eda4aa406f9026--2b7e84532cad4983a2fba85abd72d0c0
6850064d019b47c6855c8bd9046615bc
2b7e84532cad4983a2fba85abd72d0c0--6850064d019b47c6855c8bd9046615bc
1181f8f285974adf822a0089068d05a4
6850064d019b47c6855c8bd9046615bc--1181f8f285974adf822a0089068d05a4
8227aec187eb4e90bec81e551b26fe54
1181f8f285974adf822a0089068d05a4--8227aec187eb4e90bec81e551b26fe54
aeb675fd874949fdb638c64677d15564
8227aec187eb4e90bec81e551b26fe54--aeb675fd874949fdb638c64677d15564
88d28d7f0e7d4f1abca04ccb42014b08
7be1df487f2644bd989239bf857539e1
RX(theta₁)
6b5f53f431c3452d81723ac15497b65a--7be1df487f2644bd989239bf857539e1
5b3a4b19cb0b4e939ab1f53fcd317c6f
2
d9dee2bd28914ea1be61e4bdb4255b71
RY(theta₄)
7be1df487f2644bd989239bf857539e1--d9dee2bd28914ea1be61e4bdb4255b71
44a027ee6eb8443f9948893302440cbd
RX(theta₇)
d9dee2bd28914ea1be61e4bdb4255b71--44a027ee6eb8443f9948893302440cbd
ff2b31fdf2c0492aa9efccaeded4ece1
X
44a027ee6eb8443f9948893302440cbd--ff2b31fdf2c0492aa9efccaeded4ece1
ff2b31fdf2c0492aa9efccaeded4ece1--9d413e57baf9422aa7a948a31e30250c
40ffab57211340979583bad5807bfe2f
ff2b31fdf2c0492aa9efccaeded4ece1--40ffab57211340979583bad5807bfe2f
169d243fd1014ad0bec2404d666703b3
RX(theta₁₀)
40ffab57211340979583bad5807bfe2f--169d243fd1014ad0bec2404d666703b3
34afdbc15c3d477c9504f2eacc788816
RY(theta₁₃)
169d243fd1014ad0bec2404d666703b3--34afdbc15c3d477c9504f2eacc788816
17bab37b87804fbdb6fe3e19e22dc061
RX(theta₁₆)
34afdbc15c3d477c9504f2eacc788816--17bab37b87804fbdb6fe3e19e22dc061
c1f07f24e4b34c15a8f30864c986b6fa
X
17bab37b87804fbdb6fe3e19e22dc061--c1f07f24e4b34c15a8f30864c986b6fa
c1f07f24e4b34c15a8f30864c986b6fa--6850064d019b47c6855c8bd9046615bc
86216aef7c5f4b4f8fe5eca3006f65a2
c1f07f24e4b34c15a8f30864c986b6fa--86216aef7c5f4b4f8fe5eca3006f65a2
b9d308f58535404fa5f5fa7da9ac771a
AddBlock
86216aef7c5f4b4f8fe5eca3006f65a2--b9d308f58535404fa5f5fa7da9ac771a
b9d308f58535404fa5f5fa7da9ac771a--88d28d7f0e7d4f1abca04ccb42014b08
31241182d7f045fe9f3eedf0991c8b47
27074f634103443eaa588ff30d18c1a1
RX(theta₂)
5b3a4b19cb0b4e939ab1f53fcd317c6f--27074f634103443eaa588ff30d18c1a1
35dde30c55fc4e028b2d14dc0c741f2e
RY(theta₅)
27074f634103443eaa588ff30d18c1a1--35dde30c55fc4e028b2d14dc0c741f2e
008d4945f60f4045b54e3965d9734dd0
RX(theta₈)
35dde30c55fc4e028b2d14dc0c741f2e--008d4945f60f4045b54e3965d9734dd0
f6efe1d7334f4df6894c4a484160c31f
008d4945f60f4045b54e3965d9734dd0--f6efe1d7334f4df6894c4a484160c31f
d7f82f7238ec42368e591a583ec58601
X
f6efe1d7334f4df6894c4a484160c31f--d7f82f7238ec42368e591a583ec58601
d7f82f7238ec42368e591a583ec58601--40ffab57211340979583bad5807bfe2f
9dd57690cbd34c54be02f74ca852bd8f
RX(theta₁₁)
d7f82f7238ec42368e591a583ec58601--9dd57690cbd34c54be02f74ca852bd8f
5c75b48fc56a4153bff72e8fdba31136
RY(theta₁₄)
9dd57690cbd34c54be02f74ca852bd8f--5c75b48fc56a4153bff72e8fdba31136
ae4dc147b4f44265b46b359dfe8c28a4
RX(theta₁₇)
5c75b48fc56a4153bff72e8fdba31136--ae4dc147b4f44265b46b359dfe8c28a4
cfcf86e95fbd4f3f8cb90ee746093e2b
ae4dc147b4f44265b46b359dfe8c28a4--cfcf86e95fbd4f3f8cb90ee746093e2b
940fdc57b12d43fe87f73478e6a5c89e
X
cfcf86e95fbd4f3f8cb90ee746093e2b--940fdc57b12d43fe87f73478e6a5c89e
940fdc57b12d43fe87f73478e6a5c89e--86216aef7c5f4b4f8fe5eca3006f65a2
b500889547384596b69628cc356dafdd
940fdc57b12d43fe87f73478e6a5c89e--b500889547384596b69628cc356dafdd
b500889547384596b69628cc356dafdd--31241182d7f045fe9f3eedf0991c8b47
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
99cb0f8cb0104ca295efd821022dad94
0
47e9e1e4f2ce4f89b4a0dff70503050e
99cb0f8cb0104ca295efd821022dad94--47e9e1e4f2ce4f89b4a0dff70503050e
10ec06d9888e4b1e8c02dcf83df5f98c
1
ed2702daccf94c3ba8c2fdafa0cb4e11
0446e8614060455297d0c3d7b5941f87
47e9e1e4f2ce4f89b4a0dff70503050e--0446e8614060455297d0c3d7b5941f87
4b909f7ada92472b9a19a884b9e73e44
ed2702daccf94c3ba8c2fdafa0cb4e11--4b909f7ada92472b9a19a884b9e73e44
59e6c6ff80d043a1bc53dcc977947168
5bd84cfa109c43649c8ca43c53cc28f8
4b909f7ada92472b9a19a884b9e73e44--5bd84cfa109c43649c8ca43c53cc28f8
094ddac59ab24078843f1d35024df5a2
59e6c6ff80d043a1bc53dcc977947168--094ddac59ab24078843f1d35024df5a2
8eab7729c3d243c1a655da4e53b0ab4c
d7b3a133300e4df5a54ffdc856d587b3
10ec06d9888e4b1e8c02dcf83df5f98c--d7b3a133300e4df5a54ffdc856d587b3
95dd4ac2ff1f4520947532567e84a644
2
d7b3a133300e4df5a54ffdc856d587b3--ed2702daccf94c3ba8c2fdafa0cb4e11
122d3b1f13024c98bab4dabed4afd73f
0446e8614060455297d0c3d7b5941f87--122d3b1f13024c98bab4dabed4afd73f
fc4b01845ac740519379ac77a84a1762
122d3b1f13024c98bab4dabed4afd73f--fc4b01845ac740519379ac77a84a1762
fc4b01845ac740519379ac77a84a1762--8eab7729c3d243c1a655da4e53b0ab4c
8827a0fc719241b8bd6161a075a4dfb3
8680f84e122a4025a6d2167f8a6a3981
95dd4ac2ff1f4520947532567e84a644--8680f84e122a4025a6d2167f8a6a3981
115aeaed902249d3a869cfd7abf880d1
3
0b7d295ea44540aca7be27453495109e
8680f84e122a4025a6d2167f8a6a3981--0b7d295ea44540aca7be27453495109e
3949118c27f243b19e04066a2a7e876d
0b7d295ea44540aca7be27453495109e--3949118c27f243b19e04066a2a7e876d
90b61f867e4740f8a82700c6e49a4f33
3949118c27f243b19e04066a2a7e876d--90b61f867e4740f8a82700c6e49a4f33
90b61f867e4740f8a82700c6e49a4f33--8827a0fc719241b8bd6161a075a4dfb3
e1bd0a44b8bc498bbba11413b7bfefe5
cdc32e9cbff24b30b0a2512b7ee8085d
115aeaed902249d3a869cfd7abf880d1--cdc32e9cbff24b30b0a2512b7ee8085d
a84cd3b192a743ff890a3a51de9f1cc5
cdc32e9cbff24b30b0a2512b7ee8085d--a84cd3b192a743ff890a3a51de9f1cc5
02d1f8fa0d654f98a7c9ca6e325826a9
a84cd3b192a743ff890a3a51de9f1cc5--02d1f8fa0d654f98a7c9ca6e325826a9
02d1f8fa0d654f98a7c9ca6e325826a9--59e6c6ff80d043a1bc53dcc977947168
5bd84cfa109c43649c8ca43c53cc28f8--e1bd0a44b8bc498bbba11413b7bfefe5
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
70526a7a02f04715aae4e615ddf9426a
0
69621b554559434ca08047bcfe44d2b6
70526a7a02f04715aae4e615ddf9426a--69621b554559434ca08047bcfe44d2b6
979a17bb5ca24af28fe1c144c134116e
1
c41caf9442974e799201a8ba19637273
69621b554559434ca08047bcfe44d2b6--c41caf9442974e799201a8ba19637273
d0ffd086875744b699700ded66c05abb
c41caf9442974e799201a8ba19637273--d0ffd086875744b699700ded66c05abb
02de47381fb240b38d89b3bdf7d702b2
d0ffd086875744b699700ded66c05abb--02de47381fb240b38d89b3bdf7d702b2
d6180c88e44c41809427c7aec3ccfe55
cbc83b6408bf4cf28ec05f37de4cee14
PHASE(0.5)
979a17bb5ca24af28fe1c144c134116e--cbc83b6408bf4cf28ec05f37de4cee14
39dca53b66ce41b3a3c4602155981a10
2
cbc83b6408bf4cf28ec05f37de4cee14--69621b554559434ca08047bcfe44d2b6
bb46a79cd2de40acb7c1f77d36913679
cbc83b6408bf4cf28ec05f37de4cee14--bb46a79cd2de40acb7c1f77d36913679
69e820b84f824a69b05364921119dfc5
bb46a79cd2de40acb7c1f77d36913679--69e820b84f824a69b05364921119dfc5
69e820b84f824a69b05364921119dfc5--d6180c88e44c41809427c7aec3ccfe55
d5d31bcb5c27483f8069ef300ecb12f0
16d5b82d42374eefa0e4fbae8ac5e939
39dca53b66ce41b3a3c4602155981a10--16d5b82d42374eefa0e4fbae8ac5e939
eaef0e76ebdc49b186aebb5f6ebcc8ca
3
967d60cd9091464e869bef94f7a36e3d
PHASE(0.5)
16d5b82d42374eefa0e4fbae8ac5e939--967d60cd9091464e869bef94f7a36e3d
967d60cd9091464e869bef94f7a36e3d--c41caf9442974e799201a8ba19637273
b7fe0de363284640b32afae267cefe79
967d60cd9091464e869bef94f7a36e3d--b7fe0de363284640b32afae267cefe79
b7fe0de363284640b32afae267cefe79--d5d31bcb5c27483f8069ef300ecb12f0
1367d8a26eef4eed9f4ed794598066ef
074f8f62e23f4232be7e6cebab834004
eaef0e76ebdc49b186aebb5f6ebcc8ca--074f8f62e23f4232be7e6cebab834004
0de83e23a0404ca18639724ccb5f5179
074f8f62e23f4232be7e6cebab834004--0de83e23a0404ca18639724ccb5f5179
b6693b3698c748dca2057c45403149d2
PHASE(0.5)
0de83e23a0404ca18639724ccb5f5179--b6693b3698c748dca2057c45403149d2
b6693b3698c748dca2057c45403149d2--d0ffd086875744b699700ded66c05abb
b6693b3698c748dca2057c45403149d2--1367d8a26eef4eed9f4ed794598066ef
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