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
c93876ec87d94984bafe5ec3cc96a055
0
365c2ef257aa42d08b08b26a8e5d1624
X
c93876ec87d94984bafe5ec3cc96a055--365c2ef257aa42d08b08b26a8e5d1624
d7d166d6d5fb4dfab348117a0c563437
1
a379fd271d854e35956a4d4b618d6697
365c2ef257aa42d08b08b26a8e5d1624--a379fd271d854e35956a4d4b618d6697
0ee91ccc3f7c4ebe87e02a7f958e7d56
ccfb78769c7746388245253fbc80747c
Y
d7d166d6d5fb4dfab348117a0c563437--ccfb78769c7746388245253fbc80747c
ccfb78769c7746388245253fbc80747c--0ee91ccc3f7c4ebe87e02a7f958e7d56
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
1858ef711e074dd78d3d2378c8a8e317
0
9817fce134ce4fdc9c0101675c3c9f13
X
1858ef711e074dd78d3d2378c8a8e317--9817fce134ce4fdc9c0101675c3c9f13
91e950ab454941c49978fbf51744a000
Y
9817fce134ce4fdc9c0101675c3c9f13--91e950ab454941c49978fbf51744a000
5d6cb808798248b790a22acb1a6b7a38
91e950ab454941c49978fbf51744a000--5d6cb808798248b790a22acb1a6b7a38
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
4fe856aed9544dcc93d0455eef2317c8
0
8e88a943d4344d7291276c2b70b9d7a6
X
4fe856aed9544dcc93d0455eef2317c8--8e88a943d4344d7291276c2b70b9d7a6
c69911ee8270496fb6520d40010d5521
1
ff745264554f44d383451c6c8bb120af
8e88a943d4344d7291276c2b70b9d7a6--ff745264554f44d383451c6c8bb120af
c0d16262a13e46dd9a95145c181bb2c9
ff745264554f44d383451c6c8bb120af--c0d16262a13e46dd9a95145c181bb2c9
cb752dd27471486b8939199932eae047
0b078394371142629bfd2ab3f7bfa721
c69911ee8270496fb6520d40010d5521--0b078394371142629bfd2ab3f7bfa721
9058be523b8c4391ba8a81560ae57e3e
Y
0b078394371142629bfd2ab3f7bfa721--9058be523b8c4391ba8a81560ae57e3e
9058be523b8c4391ba8a81560ae57e3e--cb752dd27471486b8939199932eae047
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_d0d4194434a942edbb3d067290157e8e
5185fb40eeb145c8b36c6e6339f2c795
0
27482e6a3e6148dcbbe68d64468550a0
5185fb40eeb145c8b36c6e6339f2c795--27482e6a3e6148dcbbe68d64468550a0
ff0017072a634de5af19f272099039fc
1
7ca29d12e8a24e0781171ec41ac36e5e
27482e6a3e6148dcbbe68d64468550a0--7ca29d12e8a24e0781171ec41ac36e5e
a60d3712d4544932ac82aaf6e7ac8f82
40e05fed4d594a8597dbaa3d153c8f5b
AddBlock
ff0017072a634de5af19f272099039fc--40e05fed4d594a8597dbaa3d153c8f5b
9a24cafa42f941038799426d475f15ef
2
40e05fed4d594a8597dbaa3d153c8f5b--a60d3712d4544932ac82aaf6e7ac8f82
7e3c17859c954de0b091512c573fb6e0
4673bdd52d664d73bddb9b127965ff69
9a24cafa42f941038799426d475f15ef--4673bdd52d664d73bddb9b127965ff69
4673bdd52d664d73bddb9b127965ff69--7e3c17859c954de0b091512c573fb6e0
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_5668308275664d0a8b4c058b5fa583b8
cluster_7b5af4aac89242398ca7f5285bd8710d
rx
67da2c7c6f5e4cf1b16ae80446e2b693
0
4c12364902844ade8219c26afd027e39
X
67da2c7c6f5e4cf1b16ae80446e2b693--4c12364902844ade8219c26afd027e39
e04a16c023cc493d80a3cbaefae454d6
1
625dc741bebd42db9f091bc68926fdb5
4c12364902844ade8219c26afd027e39--625dc741bebd42db9f091bc68926fdb5
a47f22afb2154fe3b1b30f954ea1a4c0
625dc741bebd42db9f091bc68926fdb5--a47f22afb2154fe3b1b30f954ea1a4c0
bd7cbf9f206a480d864a519bcda3696f
a47f22afb2154fe3b1b30f954ea1a4c0--bd7cbf9f206a480d864a519bcda3696f
1c3e0260fb3e41259aa0997b9ecd564d
1cf088881da64eecbd1758e03c072b55
Y
e04a16c023cc493d80a3cbaefae454d6--1cf088881da64eecbd1758e03c072b55
9e75b56b7e044ae3998db941f70228bf
2
47a1f0b32e22447496aa798ae85e9376
1cf088881da64eecbd1758e03c072b55--47a1f0b32e22447496aa798ae85e9376
8ae6019992304a1cb0de32adf97b05d8
HamEvo
47a1f0b32e22447496aa798ae85e9376--8ae6019992304a1cb0de32adf97b05d8
8ae6019992304a1cb0de32adf97b05d8--1c3e0260fb3e41259aa0997b9ecd564d
f0ba0fbc011f4ebf9b14a4f871915129
94522cf0f33045338ac8d1b9927d8d3c
RX(x)
9e75b56b7e044ae3998db941f70228bf--94522cf0f33045338ac8d1b9927d8d3c
97d3424254834fc7bf22c55243f9dabb
3
62b164a4f9db458da44a61b68de0fb94
94522cf0f33045338ac8d1b9927d8d3c--62b164a4f9db458da44a61b68de0fb94
d314de5583664211b4a2b826c4d5c383
t = 10
62b164a4f9db458da44a61b68de0fb94--d314de5583664211b4a2b826c4d5c383
d314de5583664211b4a2b826c4d5c383--f0ba0fbc011f4ebf9b14a4f871915129
99a29fcbe29a4f1fab39dc1d4bc42c2a
61311dd28ef2411e88776aa27deedca6
RX(0.5)
97d3424254834fc7bf22c55243f9dabb--61311dd28ef2411e88776aa27deedca6
e265300c4e06418cb8afc23cea4b9394
X
61311dd28ef2411e88776aa27deedca6--e265300c4e06418cb8afc23cea4b9394
e265300c4e06418cb8afc23cea4b9394--62b164a4f9db458da44a61b68de0fb94
88c898f865084a5db6e121805247531f
e265300c4e06418cb8afc23cea4b9394--88c898f865084a5db6e121805247531f
88c898f865084a5db6e121805247531f--99a29fcbe29a4f1fab39dc1d4bc42c2a
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_4f10dcc079814126b59742f83fdf54e0
HEA
cluster_744435f2bde84cc198f38491ef619351
Tower Fourier FM
70368b7320714abbb035666838afbf7d
0
c368053fdaa64906b95a96e9225214de
RX(1.0*phi)
70368b7320714abbb035666838afbf7d--c368053fdaa64906b95a96e9225214de
074593fae06343659350dd33d81cdc48
1
93ca467e125c47acba23e44054f5f3ef
RX(theta₀)
c368053fdaa64906b95a96e9225214de--93ca467e125c47acba23e44054f5f3ef
5dc534906e7e4bc5bd8b2b3ae733123b
RY(theta₄)
93ca467e125c47acba23e44054f5f3ef--5dc534906e7e4bc5bd8b2b3ae733123b
90dc0390cc3944ce899497a7f0c04b9c
RX(theta₈)
5dc534906e7e4bc5bd8b2b3ae733123b--90dc0390cc3944ce899497a7f0c04b9c
4b1f8e6ca2f444d6bd5d338286279898
90dc0390cc3944ce899497a7f0c04b9c--4b1f8e6ca2f444d6bd5d338286279898
05eb7f671ae34dc6a1f1a3e9dfb31c6b
4b1f8e6ca2f444d6bd5d338286279898--05eb7f671ae34dc6a1f1a3e9dfb31c6b
15df98469f7647778dcdc4d82c6c2981
RX(theta₁₂)
05eb7f671ae34dc6a1f1a3e9dfb31c6b--15df98469f7647778dcdc4d82c6c2981
0f976439c07c41cf9bb3f29e332ed4fe
RY(theta₁₆)
15df98469f7647778dcdc4d82c6c2981--0f976439c07c41cf9bb3f29e332ed4fe
595ba237eb78413689e50323c65e3cfa
RX(theta₂₀)
0f976439c07c41cf9bb3f29e332ed4fe--595ba237eb78413689e50323c65e3cfa
f610da10a7864765bfeb947501fc6185
595ba237eb78413689e50323c65e3cfa--f610da10a7864765bfeb947501fc6185
6e50fdf9d07746f3a300d5a5b6d3e4a0
f610da10a7864765bfeb947501fc6185--6e50fdf9d07746f3a300d5a5b6d3e4a0
85d8e64d438047d39fd3d9d2be7bc78b
6e50fdf9d07746f3a300d5a5b6d3e4a0--85d8e64d438047d39fd3d9d2be7bc78b
39e3b1a2d1334601865ac8aa0c8336f4
582d2bef3a544d168089362a75970b2b
RX(2.0*phi)
074593fae06343659350dd33d81cdc48--582d2bef3a544d168089362a75970b2b
cc6c1059b980443193f757109f5e4de2
2
bb63c9da719f4ecca31a0eaefc55aaa9
RX(theta₁)
582d2bef3a544d168089362a75970b2b--bb63c9da719f4ecca31a0eaefc55aaa9
f1fd0d41917e428dad5be08966f13c89
RY(theta₅)
bb63c9da719f4ecca31a0eaefc55aaa9--f1fd0d41917e428dad5be08966f13c89
b20ac303c18c4e7da3eff86abe8962b9
RX(theta₉)
f1fd0d41917e428dad5be08966f13c89--b20ac303c18c4e7da3eff86abe8962b9
cf39a4b11e8f45f8af1d864834dae3ed
X
b20ac303c18c4e7da3eff86abe8962b9--cf39a4b11e8f45f8af1d864834dae3ed
cf39a4b11e8f45f8af1d864834dae3ed--4b1f8e6ca2f444d6bd5d338286279898
d898ac6d77db4d74b130050a2a9a42ba
cf39a4b11e8f45f8af1d864834dae3ed--d898ac6d77db4d74b130050a2a9a42ba
276b933af3b1437b81c103ab316878f5
RX(theta₁₃)
d898ac6d77db4d74b130050a2a9a42ba--276b933af3b1437b81c103ab316878f5
3fed8cb00cc747009a00fd42aee4d1ee
RY(theta₁₇)
276b933af3b1437b81c103ab316878f5--3fed8cb00cc747009a00fd42aee4d1ee
806c054d3cb24d9cb22a04899620f97f
RX(theta₂₁)
3fed8cb00cc747009a00fd42aee4d1ee--806c054d3cb24d9cb22a04899620f97f
55a79291603149a992b169de128b3e5a
X
806c054d3cb24d9cb22a04899620f97f--55a79291603149a992b169de128b3e5a
55a79291603149a992b169de128b3e5a--f610da10a7864765bfeb947501fc6185
398c7a3ffce1475080f2537e145d1715
55a79291603149a992b169de128b3e5a--398c7a3ffce1475080f2537e145d1715
398c7a3ffce1475080f2537e145d1715--39e3b1a2d1334601865ac8aa0c8336f4
05921120d4a34465af5d77d9ee19dd6b
1aeb8fcc270d4070845f445f11265b6c
RX(3.0*phi)
cc6c1059b980443193f757109f5e4de2--1aeb8fcc270d4070845f445f11265b6c
9515094370104c3ab476ada819381428
3
8671edbafd3546ff881f9e521512b392
RX(theta₂)
1aeb8fcc270d4070845f445f11265b6c--8671edbafd3546ff881f9e521512b392
9ae5cf9abd6c4e51ba07ccbc32d80f08
RY(theta₆)
8671edbafd3546ff881f9e521512b392--9ae5cf9abd6c4e51ba07ccbc32d80f08
332ddb509092401fb8165f46ab202d13
RX(theta₁₀)
9ae5cf9abd6c4e51ba07ccbc32d80f08--332ddb509092401fb8165f46ab202d13
9b780566c9754c63883a615f623dcc88
332ddb509092401fb8165f46ab202d13--9b780566c9754c63883a615f623dcc88
d8eab49fcd6441e2be6bbdf233aca203
X
9b780566c9754c63883a615f623dcc88--d8eab49fcd6441e2be6bbdf233aca203
d8eab49fcd6441e2be6bbdf233aca203--d898ac6d77db4d74b130050a2a9a42ba
958388da51524847b41b85fc8a906ed5
RX(theta₁₄)
d8eab49fcd6441e2be6bbdf233aca203--958388da51524847b41b85fc8a906ed5
f1c39882d9bf4b06a35b2473299a2e0b
RY(theta₁₈)
958388da51524847b41b85fc8a906ed5--f1c39882d9bf4b06a35b2473299a2e0b
5025a4781c74464d897ea5db8d900ea7
RX(theta₂₂)
f1c39882d9bf4b06a35b2473299a2e0b--5025a4781c74464d897ea5db8d900ea7
53a62d4f27b74caabadbe7cf725b8f28
5025a4781c74464d897ea5db8d900ea7--53a62d4f27b74caabadbe7cf725b8f28
fe63cd10dff74ece9b140c21ec1e0ffb
X
53a62d4f27b74caabadbe7cf725b8f28--fe63cd10dff74ece9b140c21ec1e0ffb
fe63cd10dff74ece9b140c21ec1e0ffb--398c7a3ffce1475080f2537e145d1715
fe63cd10dff74ece9b140c21ec1e0ffb--05921120d4a34465af5d77d9ee19dd6b
d78b4affcff94ba694234a489a4fbf16
e3bb7f8a88474e6fba99025c132f40a6
RX(4.0*phi)
9515094370104c3ab476ada819381428--e3bb7f8a88474e6fba99025c132f40a6
bf1baf07714a4658bca376a37967a441
RX(theta₃)
e3bb7f8a88474e6fba99025c132f40a6--bf1baf07714a4658bca376a37967a441
164a4f11b3154ca6865e281c4485c02b
RY(theta₇)
bf1baf07714a4658bca376a37967a441--164a4f11b3154ca6865e281c4485c02b
5fa4c93a5f5846c192153215e0e39c05
RX(theta₁₁)
164a4f11b3154ca6865e281c4485c02b--5fa4c93a5f5846c192153215e0e39c05
b5bbd4de06f34661aaf77fee968c719a
X
5fa4c93a5f5846c192153215e0e39c05--b5bbd4de06f34661aaf77fee968c719a
b5bbd4de06f34661aaf77fee968c719a--9b780566c9754c63883a615f623dcc88
5d3b3564e13042feba9cd4cc1a0bb238
b5bbd4de06f34661aaf77fee968c719a--5d3b3564e13042feba9cd4cc1a0bb238
533bbfd2920e4b1db8d3f344c5d305c9
RX(theta₁₅)
5d3b3564e13042feba9cd4cc1a0bb238--533bbfd2920e4b1db8d3f344c5d305c9
32d2ca71f7c34fed93900e08c83f826a
RY(theta₁₉)
533bbfd2920e4b1db8d3f344c5d305c9--32d2ca71f7c34fed93900e08c83f826a
16891dcd73e34221b90e05954532ae1b
RX(theta₂₃)
32d2ca71f7c34fed93900e08c83f826a--16891dcd73e34221b90e05954532ae1b
ba976ae6cfe54e5b929766a8bcb6aad0
X
16891dcd73e34221b90e05954532ae1b--ba976ae6cfe54e5b929766a8bcb6aad0
ba976ae6cfe54e5b929766a8bcb6aad0--53a62d4f27b74caabadbe7cf725b8f28
17f4a43082c648cc95d42a39dcad017c
ba976ae6cfe54e5b929766a8bcb6aad0--17f4a43082c648cc95d42a39dcad017c
17f4a43082c648cc95d42a39dcad017c--d78b4affcff94ba694234a489a4fbf16
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_55afc44db53d4cb68617418878076766
Obs.
cluster_1742bdade07a462fbb463cc40a3bab60
cluster_b22a8292d0dd414890ebf008bda12ab1
HEA
e0b6919dbb984c879bb9c8fbae65bba7
0
63a7aaa51b3f4369bc292a306420b7e7
RX(theta₀)
e0b6919dbb984c879bb9c8fbae65bba7--63a7aaa51b3f4369bc292a306420b7e7
11be69dbe54e43b681f45a393f185172
1
bc08aba2fa144ba4a1a54b2c5c2b9c5b
RY(theta₃)
63a7aaa51b3f4369bc292a306420b7e7--bc08aba2fa144ba4a1a54b2c5c2b9c5b
0c925e97cffe4139af2d083f9743b1e3
RX(theta₆)
bc08aba2fa144ba4a1a54b2c5c2b9c5b--0c925e97cffe4139af2d083f9743b1e3
4bdd642f348541fe8900ee52543fc5a9
0c925e97cffe4139af2d083f9743b1e3--4bdd642f348541fe8900ee52543fc5a9
1e751b86f8c74e6e8b4346e3e76884d3
4bdd642f348541fe8900ee52543fc5a9--1e751b86f8c74e6e8b4346e3e76884d3
edd7a55dab234746a01f9313ce44062d
RX(theta₉)
1e751b86f8c74e6e8b4346e3e76884d3--edd7a55dab234746a01f9313ce44062d
1a65cc988a26407788a317dcff6fd044
RY(theta₁₂)
edd7a55dab234746a01f9313ce44062d--1a65cc988a26407788a317dcff6fd044
84597a7febd143d982507411c1d4ecdf
RX(theta₁₅)
1a65cc988a26407788a317dcff6fd044--84597a7febd143d982507411c1d4ecdf
3f9449ec74324513ba951cf381316d2c
84597a7febd143d982507411c1d4ecdf--3f9449ec74324513ba951cf381316d2c
be94a1ff532b4ab7b16925f14b86e7bb
3f9449ec74324513ba951cf381316d2c--be94a1ff532b4ab7b16925f14b86e7bb
a07470e54bc143138d53095cd780a5d9
be94a1ff532b4ab7b16925f14b86e7bb--a07470e54bc143138d53095cd780a5d9
32b5130f8ac640e8b17ab6e3c67fbd90
a07470e54bc143138d53095cd780a5d9--32b5130f8ac640e8b17ab6e3c67fbd90
f2e0f549bca14e2096bdce93e264e991
a123bfe69c394b7eb89c8338ace9b131
RX(theta₁)
11be69dbe54e43b681f45a393f185172--a123bfe69c394b7eb89c8338ace9b131
4281addfebd54dac8c26404346148265
2
7b7c7364c1594d01a25632174e67ac46
RY(theta₄)
a123bfe69c394b7eb89c8338ace9b131--7b7c7364c1594d01a25632174e67ac46
16a15e695b4743c3a8212d479302bea7
RX(theta₇)
7b7c7364c1594d01a25632174e67ac46--16a15e695b4743c3a8212d479302bea7
b6e259c913264f1e8964ee416e4bb9af
X
16a15e695b4743c3a8212d479302bea7--b6e259c913264f1e8964ee416e4bb9af
b6e259c913264f1e8964ee416e4bb9af--4bdd642f348541fe8900ee52543fc5a9
519a5ceaa31249f585e9efa08e18a5d2
b6e259c913264f1e8964ee416e4bb9af--519a5ceaa31249f585e9efa08e18a5d2
eb127045773248f3946499920dc3f1be
RX(theta₁₀)
519a5ceaa31249f585e9efa08e18a5d2--eb127045773248f3946499920dc3f1be
fbb676dd2bbe47449950c544ca37d85e
RY(theta₁₃)
eb127045773248f3946499920dc3f1be--fbb676dd2bbe47449950c544ca37d85e
6a760cb0f5664613bdfbce30bac16b2a
RX(theta₁₆)
fbb676dd2bbe47449950c544ca37d85e--6a760cb0f5664613bdfbce30bac16b2a
b1e8237a7cd544b5b5e44c57d9b3be4d
X
6a760cb0f5664613bdfbce30bac16b2a--b1e8237a7cd544b5b5e44c57d9b3be4d
b1e8237a7cd544b5b5e44c57d9b3be4d--3f9449ec74324513ba951cf381316d2c
0789ce1059a84a72a80cdada499c9922
b1e8237a7cd544b5b5e44c57d9b3be4d--0789ce1059a84a72a80cdada499c9922
2f276a0e08b241cabfb126f9d61372e0
AddBlock
0789ce1059a84a72a80cdada499c9922--2f276a0e08b241cabfb126f9d61372e0
2f276a0e08b241cabfb126f9d61372e0--f2e0f549bca14e2096bdce93e264e991
f73bdc39bce54673b284002da557f5ba
da1cca91720549d4a5d2928b3279be7b
RX(theta₂)
4281addfebd54dac8c26404346148265--da1cca91720549d4a5d2928b3279be7b
baac607f7bbd41d2982ab92dfe8bb6bb
RY(theta₅)
da1cca91720549d4a5d2928b3279be7b--baac607f7bbd41d2982ab92dfe8bb6bb
0c35e25ef65140f8a548f266252f4279
RX(theta₈)
baac607f7bbd41d2982ab92dfe8bb6bb--0c35e25ef65140f8a548f266252f4279
336c900eb27549d68e8e99a547c7a8dc
0c35e25ef65140f8a548f266252f4279--336c900eb27549d68e8e99a547c7a8dc
21fb4da97a3b484383a16faa04d57962
X
336c900eb27549d68e8e99a547c7a8dc--21fb4da97a3b484383a16faa04d57962
21fb4da97a3b484383a16faa04d57962--519a5ceaa31249f585e9efa08e18a5d2
9fd330ed9c7d45a3b6536075ebce8489
RX(theta₁₁)
21fb4da97a3b484383a16faa04d57962--9fd330ed9c7d45a3b6536075ebce8489
3e623cc99f034b069ebbf0d349ebe8af
RY(theta₁₄)
9fd330ed9c7d45a3b6536075ebce8489--3e623cc99f034b069ebbf0d349ebe8af
b874d23bacf2416496d7f86fadcb43a1
RX(theta₁₇)
3e623cc99f034b069ebbf0d349ebe8af--b874d23bacf2416496d7f86fadcb43a1
dd52b74a96be46b69e93fb3df1d051d4
b874d23bacf2416496d7f86fadcb43a1--dd52b74a96be46b69e93fb3df1d051d4
733fa8a29bbd4b2ebe5355421af42fec
X
dd52b74a96be46b69e93fb3df1d051d4--733fa8a29bbd4b2ebe5355421af42fec
733fa8a29bbd4b2ebe5355421af42fec--0789ce1059a84a72a80cdada499c9922
37424ce9dfba45b2a6111dcab4fba040
733fa8a29bbd4b2ebe5355421af42fec--37424ce9dfba45b2a6111dcab4fba040
37424ce9dfba45b2a6111dcab4fba040--f73bdc39bce54673b284002da557f5ba
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
aefe77f8b20d48ec84ca93ee58d0bc80
0
3d71a28085fc4c03a938357825743203
aefe77f8b20d48ec84ca93ee58d0bc80--3d71a28085fc4c03a938357825743203
134810b174604cfcbcdb044734962717
1
c4f244ea942a4d528d3b45884ed5d8ae
5db7679e641b48d296ec19691cc77c84
3d71a28085fc4c03a938357825743203--5db7679e641b48d296ec19691cc77c84
49fef1acfe1d4b07ac64aaaa53365de0
c4f244ea942a4d528d3b45884ed5d8ae--49fef1acfe1d4b07ac64aaaa53365de0
4b0771c9a67d4ada8054a0b29d3c42df
37e22e19afe34e079a43c3b762d353c0
49fef1acfe1d4b07ac64aaaa53365de0--37e22e19afe34e079a43c3b762d353c0
6db05ecb07f84fcdaf2ea994848d3927
4b0771c9a67d4ada8054a0b29d3c42df--6db05ecb07f84fcdaf2ea994848d3927
0f13609784d041829a60dd9b9b47384f
ca570a1f2c3f4da6835e1555ab5942de
134810b174604cfcbcdb044734962717--ca570a1f2c3f4da6835e1555ab5942de
96c1d87255884b549120204c112737f6
2
ca570a1f2c3f4da6835e1555ab5942de--c4f244ea942a4d528d3b45884ed5d8ae
2b68ce2469044d4780e286d5bb54100a
5db7679e641b48d296ec19691cc77c84--2b68ce2469044d4780e286d5bb54100a
4f073491ba6c4337b932d0c387232c11
2b68ce2469044d4780e286d5bb54100a--4f073491ba6c4337b932d0c387232c11
4f073491ba6c4337b932d0c387232c11--0f13609784d041829a60dd9b9b47384f
5ea8c5d18e24440da729bdb5aa1e0acb
12134014d52846d98a35237d08ef6095
96c1d87255884b549120204c112737f6--12134014d52846d98a35237d08ef6095
93c302cc6fb5481aa2d2fc77864213f0
3
c444a6e1cdb4415c883d21b2b466d1db
12134014d52846d98a35237d08ef6095--c444a6e1cdb4415c883d21b2b466d1db
8e1844eecf3646c7b3549406670ddd55
c444a6e1cdb4415c883d21b2b466d1db--8e1844eecf3646c7b3549406670ddd55
d8f1e4ed87cf4e968b3f2ee0e0cd2c46
8e1844eecf3646c7b3549406670ddd55--d8f1e4ed87cf4e968b3f2ee0e0cd2c46
d8f1e4ed87cf4e968b3f2ee0e0cd2c46--5ea8c5d18e24440da729bdb5aa1e0acb
3e58195d61df49dca63a46df7f22af55
bde545d5a25242e9b2081342cec51538
93c302cc6fb5481aa2d2fc77864213f0--bde545d5a25242e9b2081342cec51538
eaaa690134f44b34a94bf69846da5f6e
bde545d5a25242e9b2081342cec51538--eaaa690134f44b34a94bf69846da5f6e
fd0a2c5c89c64d9aba5df35c912826e5
eaaa690134f44b34a94bf69846da5f6e--fd0a2c5c89c64d9aba5df35c912826e5
fd0a2c5c89c64d9aba5df35c912826e5--4b0771c9a67d4ada8054a0b29d3c42df
37e22e19afe34e079a43c3b762d353c0--3e58195d61df49dca63a46df7f22af55
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
d62e4dadbe7f400e94553ef7ed4c341a
0
162cb0d7b4d344f483528377ea8f14e5
d62e4dadbe7f400e94553ef7ed4c341a--162cb0d7b4d344f483528377ea8f14e5
c40b313394e74b0c9a71cd0013544c51
1
823ecf7f6bb048039f4022d7a6609319
162cb0d7b4d344f483528377ea8f14e5--823ecf7f6bb048039f4022d7a6609319
68159acccfd44aa8b2ca0a1fff825ee7
823ecf7f6bb048039f4022d7a6609319--68159acccfd44aa8b2ca0a1fff825ee7
cdb01d8e675347a1bb6a3e682f71fa6d
68159acccfd44aa8b2ca0a1fff825ee7--cdb01d8e675347a1bb6a3e682f71fa6d
a027042f98624bf4a1f90c106afb4d9b
1786ec8c3d884afbb81e8043ec07b4b3
PHASE(0.5)
c40b313394e74b0c9a71cd0013544c51--1786ec8c3d884afbb81e8043ec07b4b3
b6361e62e0fb4d9ab2adf6f4cdda9233
2
1786ec8c3d884afbb81e8043ec07b4b3--162cb0d7b4d344f483528377ea8f14e5
34fb9e7f73964ed1bedac1ffc46ed695
1786ec8c3d884afbb81e8043ec07b4b3--34fb9e7f73964ed1bedac1ffc46ed695
9680b586a1b04d4eae02943861096eb9
34fb9e7f73964ed1bedac1ffc46ed695--9680b586a1b04d4eae02943861096eb9
9680b586a1b04d4eae02943861096eb9--a027042f98624bf4a1f90c106afb4d9b
d162396233f241cabc9c1732e60cab01
d46aa1f2ec454e1894c56cc452111b8f
b6361e62e0fb4d9ab2adf6f4cdda9233--d46aa1f2ec454e1894c56cc452111b8f
b02b6945fde7471fb8f07b4a7c66c38e
3
216e03f766cb4405a91ca80d29c3da83
PHASE(0.5)
d46aa1f2ec454e1894c56cc452111b8f--216e03f766cb4405a91ca80d29c3da83
216e03f766cb4405a91ca80d29c3da83--823ecf7f6bb048039f4022d7a6609319
7fbd63ae9142441db82d3add4644534d
216e03f766cb4405a91ca80d29c3da83--7fbd63ae9142441db82d3add4644534d
7fbd63ae9142441db82d3add4644534d--d162396233f241cabc9c1732e60cab01
4bb3f76c492f41109df6ad7c80ae4f3f
a3c69e2e50a141f59da8cb72d5075913
b02b6945fde7471fb8f07b4a7c66c38e--a3c69e2e50a141f59da8cb72d5075913
264e33b1a7614fca8e3ac5e29f3a61bf
a3c69e2e50a141f59da8cb72d5075913--264e33b1a7614fca8e3ac5e29f3a61bf
d7d7e7f835ff4facb68bc4f37184fc12
PHASE(0.5)
264e33b1a7614fca8e3ac5e29f3a61bf--d7d7e7f835ff4facb68bc4f37184fc12
d7d7e7f835ff4facb68bc4f37184fc12--68159acccfd44aa8b2ca0a1fff825ee7
d7d7e7f835ff4facb68bc4f37184fc12--4bb3f76c492f41109df6ad7c80ae4f3f
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