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
68f370566b4c490a893722cb523192b2
0
fe94e5dd8dbd41a9a48820054aa3c36c
X
68f370566b4c490a893722cb523192b2--fe94e5dd8dbd41a9a48820054aa3c36c
6619308e19194b32a719904bdbc414f4
1
ed0723ae8f21463280a20a838c53bdfb
fe94e5dd8dbd41a9a48820054aa3c36c--ed0723ae8f21463280a20a838c53bdfb
f4a8ed812a5a4759b9a6b18c1fe1b696
01c317bd9b8d4c3ba7071898819aae10
Y
6619308e19194b32a719904bdbc414f4--01c317bd9b8d4c3ba7071898819aae10
01c317bd9b8d4c3ba7071898819aae10--f4a8ed812a5a4759b9a6b18c1fe1b696
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
489056bef3bf4681ab8551dbfda495fc
0
3f6d8de769ab4ea486f4b92f0b7c7b9e
X
489056bef3bf4681ab8551dbfda495fc--3f6d8de769ab4ea486f4b92f0b7c7b9e
2057772181e843239676b2ae4a1f4985
Y
3f6d8de769ab4ea486f4b92f0b7c7b9e--2057772181e843239676b2ae4a1f4985
152c079650be4c02b97b4d4d5ad5c536
2057772181e843239676b2ae4a1f4985--152c079650be4c02b97b4d4d5ad5c536
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
93939726c7924dac98f50745aa7aeee1
0
4dfc58e908914b058195a43e896d942d
X
93939726c7924dac98f50745aa7aeee1--4dfc58e908914b058195a43e896d942d
e2bf61d3add949b18de4139bf856edae
1
47f7a983a2a64d1895c029a65cd20445
4dfc58e908914b058195a43e896d942d--47f7a983a2a64d1895c029a65cd20445
79981a73306b4f5d953f1392fbb5b37a
47f7a983a2a64d1895c029a65cd20445--79981a73306b4f5d953f1392fbb5b37a
4cc5ceec66ee4beaa5f6fac60908cfae
2d37c34df354433dbfaa6d23118b8c97
e2bf61d3add949b18de4139bf856edae--2d37c34df354433dbfaa6d23118b8c97
a300a294d65641858b6a2aa471b1ee28
Y
2d37c34df354433dbfaa6d23118b8c97--a300a294d65641858b6a2aa471b1ee28
a300a294d65641858b6a2aa471b1ee28--4cc5ceec66ee4beaa5f6fac60908cfae
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_ad6291b0ae764eb09c45b059ac1af9e0
fc76767a392d4909b2b2291d75c100d4
0
25255f0076b04d1a8c58bc68546b83cf
fc76767a392d4909b2b2291d75c100d4--25255f0076b04d1a8c58bc68546b83cf
4eeeaf871bf441fbb945ab9871789d72
1
35b89f40b8a04b5789074ac075973912
25255f0076b04d1a8c58bc68546b83cf--35b89f40b8a04b5789074ac075973912
653c668669ce4742912dd3b6aacafe30
6eb77884b7fe451a887742b885aae586
AddBlock
4eeeaf871bf441fbb945ab9871789d72--6eb77884b7fe451a887742b885aae586
1fdce31ce4914673ab118bfef444ebe3
2
6eb77884b7fe451a887742b885aae586--653c668669ce4742912dd3b6aacafe30
a97cb0d769324195bfab32e434864f55
c5e5bce0818a4f9fbd816a99dc123b0c
1fdce31ce4914673ab118bfef444ebe3--c5e5bce0818a4f9fbd816a99dc123b0c
c5e5bce0818a4f9fbd816a99dc123b0c--a97cb0d769324195bfab32e434864f55
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_a46aa8129ad94ccc9930fb591dde4a91
cluster_089b6cb06e614c348f8bf7739f1bb3bc
rx
e7cd28d3621441a5955043f988737fca
0
c614d161690e47a299bf13d6b9b4c5c2
X
e7cd28d3621441a5955043f988737fca--c614d161690e47a299bf13d6b9b4c5c2
8cefa599b3b444899a798bebf5645812
1
8cd3ef9050634e9c8ac6b0906878fe2e
c614d161690e47a299bf13d6b9b4c5c2--8cd3ef9050634e9c8ac6b0906878fe2e
fcf2e461f57b47978b213bece6b343f9
8cd3ef9050634e9c8ac6b0906878fe2e--fcf2e461f57b47978b213bece6b343f9
21a4d2c32a004c84bf9e3c7fd8060e6e
fcf2e461f57b47978b213bece6b343f9--21a4d2c32a004c84bf9e3c7fd8060e6e
7a78255222da4b59bf0dfbf9af67986b
e063c6caafbc4c1bb0d8b3d81c85a20c
Y
8cefa599b3b444899a798bebf5645812--e063c6caafbc4c1bb0d8b3d81c85a20c
f81dc7ca252b4f09bcb91e51d01915ad
2
3b19daebd9754e0294d2cb12e55d03e2
e063c6caafbc4c1bb0d8b3d81c85a20c--3b19daebd9754e0294d2cb12e55d03e2
232dea56e70f4489a37775aa2964bf85
HamEvo
3b19daebd9754e0294d2cb12e55d03e2--232dea56e70f4489a37775aa2964bf85
232dea56e70f4489a37775aa2964bf85--7a78255222da4b59bf0dfbf9af67986b
735fdd21175444de9e9b29aab45c3b4c
d2d2e0c2ffbf48f3a8f87bdfb3747fe0
RX(x)
f81dc7ca252b4f09bcb91e51d01915ad--d2d2e0c2ffbf48f3a8f87bdfb3747fe0
a5c108c1df694a9bbf2c2567dc2a14fa
3
7b63ef1f4e76430ab4447ff0a40a54e9
d2d2e0c2ffbf48f3a8f87bdfb3747fe0--7b63ef1f4e76430ab4447ff0a40a54e9
8c142bc1556c40afa42b98cdaa380313
t = 10
7b63ef1f4e76430ab4447ff0a40a54e9--8c142bc1556c40afa42b98cdaa380313
8c142bc1556c40afa42b98cdaa380313--735fdd21175444de9e9b29aab45c3b4c
7814e1799db946f3820235c83f986325
8bbd14e9be164cb9a6d59d546559ab30
RX(0.5)
a5c108c1df694a9bbf2c2567dc2a14fa--8bbd14e9be164cb9a6d59d546559ab30
d83b322b02d842edbdd6a814442e45f0
X
8bbd14e9be164cb9a6d59d546559ab30--d83b322b02d842edbdd6a814442e45f0
d83b322b02d842edbdd6a814442e45f0--7b63ef1f4e76430ab4447ff0a40a54e9
43d1ccde943d424bafd4ad4a1e642aaf
d83b322b02d842edbdd6a814442e45f0--43d1ccde943d424bafd4ad4a1e642aaf
43d1ccde943d424bafd4ad4a1e642aaf--7814e1799db946f3820235c83f986325
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_d968e2437d264f99917e88e76160d7ba
HEA
cluster_1b00b4d783dd428ab9e3f6f04fc2b90b
Tower Fourier FM
2c1f8b401dbd41a785a66278913d9afa
0
7760854647614dfb9a4d1bb8f54a502d
RX(1.0*phi)
2c1f8b401dbd41a785a66278913d9afa--7760854647614dfb9a4d1bb8f54a502d
78b98b8eba63464db075873496797a4d
1
e644884dc7d04cb7bb67c19b4a73a07e
RX(theta₀)
7760854647614dfb9a4d1bb8f54a502d--e644884dc7d04cb7bb67c19b4a73a07e
917057315424451bb889e879def0ba9d
RY(theta₄)
e644884dc7d04cb7bb67c19b4a73a07e--917057315424451bb889e879def0ba9d
d7385e200d78443e949d5fdf0b253664
RX(theta₈)
917057315424451bb889e879def0ba9d--d7385e200d78443e949d5fdf0b253664
37ec96b1adc4495886e8cf2527fd4397
d7385e200d78443e949d5fdf0b253664--37ec96b1adc4495886e8cf2527fd4397
5a1f532be6fc46a2b6e53c95c29b50f5
37ec96b1adc4495886e8cf2527fd4397--5a1f532be6fc46a2b6e53c95c29b50f5
fd8397a572bb44cb9523fa99abaa29fc
RX(theta₁₂)
5a1f532be6fc46a2b6e53c95c29b50f5--fd8397a572bb44cb9523fa99abaa29fc
132c98bd31044f0a8b35bc8c38519b96
RY(theta₁₆)
fd8397a572bb44cb9523fa99abaa29fc--132c98bd31044f0a8b35bc8c38519b96
676a7e87224445788566a36243001141
RX(theta₂₀)
132c98bd31044f0a8b35bc8c38519b96--676a7e87224445788566a36243001141
8ad7338b94f6477eb3d934f55fcaca63
676a7e87224445788566a36243001141--8ad7338b94f6477eb3d934f55fcaca63
90faf17d99d143699a4b543f79b7c202
8ad7338b94f6477eb3d934f55fcaca63--90faf17d99d143699a4b543f79b7c202
27fd3ecfc32245c7b9a7137dda352943
90faf17d99d143699a4b543f79b7c202--27fd3ecfc32245c7b9a7137dda352943
9227feee3cc1445bacb081565c7d0606
2ef98442082a4f4ba08213237072a0ac
RX(2.0*phi)
78b98b8eba63464db075873496797a4d--2ef98442082a4f4ba08213237072a0ac
c1dac2ab6eac44a2b735b9a5cbaee3c3
2
fa0e80f105c24871b82131c8e32e91f6
RX(theta₁)
2ef98442082a4f4ba08213237072a0ac--fa0e80f105c24871b82131c8e32e91f6
09bee8dafdac4bc5bb05d91c8ff2fcc6
RY(theta₅)
fa0e80f105c24871b82131c8e32e91f6--09bee8dafdac4bc5bb05d91c8ff2fcc6
293435205ea94f2da566a6630ca42a2a
RX(theta₉)
09bee8dafdac4bc5bb05d91c8ff2fcc6--293435205ea94f2da566a6630ca42a2a
57a01fd1734e43d0b10835d253732a8d
X
293435205ea94f2da566a6630ca42a2a--57a01fd1734e43d0b10835d253732a8d
57a01fd1734e43d0b10835d253732a8d--37ec96b1adc4495886e8cf2527fd4397
df2be4cec77c475291280caf300c6351
57a01fd1734e43d0b10835d253732a8d--df2be4cec77c475291280caf300c6351
a98413ab83d64ae782688c6162afc79a
RX(theta₁₃)
df2be4cec77c475291280caf300c6351--a98413ab83d64ae782688c6162afc79a
a99c7c2b9bcd4eccbe378b2f3bb4bbe2
RY(theta₁₇)
a98413ab83d64ae782688c6162afc79a--a99c7c2b9bcd4eccbe378b2f3bb4bbe2
13755d49c68b4c7e961f176296cfa79e
RX(theta₂₁)
a99c7c2b9bcd4eccbe378b2f3bb4bbe2--13755d49c68b4c7e961f176296cfa79e
75b1ceee46474fe9801c4f58186bdb58
X
13755d49c68b4c7e961f176296cfa79e--75b1ceee46474fe9801c4f58186bdb58
75b1ceee46474fe9801c4f58186bdb58--8ad7338b94f6477eb3d934f55fcaca63
57b15d9ddb434faf81a1f5ed880ad5a3
75b1ceee46474fe9801c4f58186bdb58--57b15d9ddb434faf81a1f5ed880ad5a3
57b15d9ddb434faf81a1f5ed880ad5a3--9227feee3cc1445bacb081565c7d0606
51b0fb185749415ba7ce2648118ea17d
0a040a6758ae4e75b7188e101c00e147
RX(3.0*phi)
c1dac2ab6eac44a2b735b9a5cbaee3c3--0a040a6758ae4e75b7188e101c00e147
be2758fea45943fa9520715cce970f58
3
75445bab9c664f06b8623f3267393d74
RX(theta₂)
0a040a6758ae4e75b7188e101c00e147--75445bab9c664f06b8623f3267393d74
8dfe4f31b2b345ffbff355bf46f23c1e
RY(theta₆)
75445bab9c664f06b8623f3267393d74--8dfe4f31b2b345ffbff355bf46f23c1e
49c0c3af53dc46738f3467efc1969d0c
RX(theta₁₀)
8dfe4f31b2b345ffbff355bf46f23c1e--49c0c3af53dc46738f3467efc1969d0c
f289465ccc5b4142a5e45a5db80d783e
49c0c3af53dc46738f3467efc1969d0c--f289465ccc5b4142a5e45a5db80d783e
94db22b1b10245ac88d63149d0f8608e
X
f289465ccc5b4142a5e45a5db80d783e--94db22b1b10245ac88d63149d0f8608e
94db22b1b10245ac88d63149d0f8608e--df2be4cec77c475291280caf300c6351
0e4a3d672a244dc48479093fbfb81fc8
RX(theta₁₄)
94db22b1b10245ac88d63149d0f8608e--0e4a3d672a244dc48479093fbfb81fc8
e3ad3bb2ff2248ba903f6a3d0606aeea
RY(theta₁₈)
0e4a3d672a244dc48479093fbfb81fc8--e3ad3bb2ff2248ba903f6a3d0606aeea
4f06c561a0c94b9d87545054100b2de3
RX(theta₂₂)
e3ad3bb2ff2248ba903f6a3d0606aeea--4f06c561a0c94b9d87545054100b2de3
5830e7640724442db533530f1c3c3b61
4f06c561a0c94b9d87545054100b2de3--5830e7640724442db533530f1c3c3b61
36e0bd85d5fd43e896ab437ee32d52e6
X
5830e7640724442db533530f1c3c3b61--36e0bd85d5fd43e896ab437ee32d52e6
36e0bd85d5fd43e896ab437ee32d52e6--57b15d9ddb434faf81a1f5ed880ad5a3
36e0bd85d5fd43e896ab437ee32d52e6--51b0fb185749415ba7ce2648118ea17d
93c08589067a4ea8a2057f730f69dcfd
94928142201a45eeba96b57f5259d0be
RX(4.0*phi)
be2758fea45943fa9520715cce970f58--94928142201a45eeba96b57f5259d0be
4ae2e588f07249bd8c36ac20e42db041
RX(theta₃)
94928142201a45eeba96b57f5259d0be--4ae2e588f07249bd8c36ac20e42db041
8317c1cda89a4a9db3f2f0347daad2ae
RY(theta₇)
4ae2e588f07249bd8c36ac20e42db041--8317c1cda89a4a9db3f2f0347daad2ae
d522994319c24212b2ef324a96dcff5a
RX(theta₁₁)
8317c1cda89a4a9db3f2f0347daad2ae--d522994319c24212b2ef324a96dcff5a
ae494b3bb56d48319327082842b69ea1
X
d522994319c24212b2ef324a96dcff5a--ae494b3bb56d48319327082842b69ea1
ae494b3bb56d48319327082842b69ea1--f289465ccc5b4142a5e45a5db80d783e
9b690263f1014011bdab57b275ce33c2
ae494b3bb56d48319327082842b69ea1--9b690263f1014011bdab57b275ce33c2
12ee24e54f4440c2b3b6d8556e18ce2e
RX(theta₁₅)
9b690263f1014011bdab57b275ce33c2--12ee24e54f4440c2b3b6d8556e18ce2e
36709e2721bb4425bb914233ba607069
RY(theta₁₉)
12ee24e54f4440c2b3b6d8556e18ce2e--36709e2721bb4425bb914233ba607069
9c9a7aea562741edbfc25d3efa288c93
RX(theta₂₃)
36709e2721bb4425bb914233ba607069--9c9a7aea562741edbfc25d3efa288c93
1eee029940b84ca6bbe91115f80db290
X
9c9a7aea562741edbfc25d3efa288c93--1eee029940b84ca6bbe91115f80db290
1eee029940b84ca6bbe91115f80db290--5830e7640724442db533530f1c3c3b61
52086b27fcea46efb3d7ab914e6af4f6
1eee029940b84ca6bbe91115f80db290--52086b27fcea46efb3d7ab914e6af4f6
52086b27fcea46efb3d7ab914e6af4f6--93c08589067a4ea8a2057f730f69dcfd
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_fc0084cc8d644e5fae9e267ad36f550a
Obs.
cluster_cbbd968f0c6b47cabab4fb5d3421df91
cluster_d13333dc7be64e9895afe9483d9047a1
HEA
e053ba0eefdb4d4990b75c48192cc85a
0
888817be175246fd889acff496b33e65
RX(theta₀)
e053ba0eefdb4d4990b75c48192cc85a--888817be175246fd889acff496b33e65
131066024037451a97587f1d048510ba
1
83ca07f48e444f8a9434450c921da953
RY(theta₃)
888817be175246fd889acff496b33e65--83ca07f48e444f8a9434450c921da953
9fd3b70853c44ecfa1f212b95325a699
RX(theta₆)
83ca07f48e444f8a9434450c921da953--9fd3b70853c44ecfa1f212b95325a699
03553b69f165419c8075a5589abbc1f9
9fd3b70853c44ecfa1f212b95325a699--03553b69f165419c8075a5589abbc1f9
302376638c34455d9b479b832e13cbda
03553b69f165419c8075a5589abbc1f9--302376638c34455d9b479b832e13cbda
2449f806d4c64c7b8250c21eeca199e3
RX(theta₉)
302376638c34455d9b479b832e13cbda--2449f806d4c64c7b8250c21eeca199e3
6a5505a62bee47aeb8c8795b4af264f4
RY(theta₁₂)
2449f806d4c64c7b8250c21eeca199e3--6a5505a62bee47aeb8c8795b4af264f4
208b1c7d6bda466281500d867db576ce
RX(theta₁₅)
6a5505a62bee47aeb8c8795b4af264f4--208b1c7d6bda466281500d867db576ce
cae50bf7bece45f0a2b5592a3f18f978
208b1c7d6bda466281500d867db576ce--cae50bf7bece45f0a2b5592a3f18f978
25d362dd86f14161ae90d0ef0f2dd606
cae50bf7bece45f0a2b5592a3f18f978--25d362dd86f14161ae90d0ef0f2dd606
0ec94bb528f847318a193f4132c3621c
25d362dd86f14161ae90d0ef0f2dd606--0ec94bb528f847318a193f4132c3621c
8edf432be60a401a91491a7d411cc940
0ec94bb528f847318a193f4132c3621c--8edf432be60a401a91491a7d411cc940
c9f560357b9e46229e712cb633c296f3
1b665010f0e647cba214e6826d02427e
RX(theta₁)
131066024037451a97587f1d048510ba--1b665010f0e647cba214e6826d02427e
b5d238b5325a4053ab421c5a51edcb88
2
0b18a30e42ea45bfb65b428a9a39c839
RY(theta₄)
1b665010f0e647cba214e6826d02427e--0b18a30e42ea45bfb65b428a9a39c839
5cd90f58d9494337bbf13b97b9da0c4d
RX(theta₇)
0b18a30e42ea45bfb65b428a9a39c839--5cd90f58d9494337bbf13b97b9da0c4d
5db755ba8b434c2ba9229adff48e1154
X
5cd90f58d9494337bbf13b97b9da0c4d--5db755ba8b434c2ba9229adff48e1154
5db755ba8b434c2ba9229adff48e1154--03553b69f165419c8075a5589abbc1f9
9f2a7454563a4c2d8bde8a21247ea60a
5db755ba8b434c2ba9229adff48e1154--9f2a7454563a4c2d8bde8a21247ea60a
4c59f3eadeb847e0a4a90e11414288df
RX(theta₁₀)
9f2a7454563a4c2d8bde8a21247ea60a--4c59f3eadeb847e0a4a90e11414288df
0c5814ea07dc4c9cb8954557bc12643e
RY(theta₁₃)
4c59f3eadeb847e0a4a90e11414288df--0c5814ea07dc4c9cb8954557bc12643e
31b815d64b3b42f8960e06f84ec76ba9
RX(theta₁₆)
0c5814ea07dc4c9cb8954557bc12643e--31b815d64b3b42f8960e06f84ec76ba9
04537c190aa3477da445c16662558fa1
X
31b815d64b3b42f8960e06f84ec76ba9--04537c190aa3477da445c16662558fa1
04537c190aa3477da445c16662558fa1--cae50bf7bece45f0a2b5592a3f18f978
74afd131b29d48678ec07657dd5cf871
04537c190aa3477da445c16662558fa1--74afd131b29d48678ec07657dd5cf871
eb09ad3c13b54a6487597b4351240e28
AddBlock
74afd131b29d48678ec07657dd5cf871--eb09ad3c13b54a6487597b4351240e28
eb09ad3c13b54a6487597b4351240e28--c9f560357b9e46229e712cb633c296f3
ab75ca681b86434bbf5181e5779b28b6
059155ec96dd4deaa0969c2677e38dfe
RX(theta₂)
b5d238b5325a4053ab421c5a51edcb88--059155ec96dd4deaa0969c2677e38dfe
d4146b3190cd44fa98bca5dcab8dedf6
RY(theta₅)
059155ec96dd4deaa0969c2677e38dfe--d4146b3190cd44fa98bca5dcab8dedf6
314bf8b39e234a7c82a6afd7e4bc5fd1
RX(theta₈)
d4146b3190cd44fa98bca5dcab8dedf6--314bf8b39e234a7c82a6afd7e4bc5fd1
5ab478cc264c46d88c5dc9a8afa75c69
314bf8b39e234a7c82a6afd7e4bc5fd1--5ab478cc264c46d88c5dc9a8afa75c69
48c5a02c74c144de9424b1eccb1bbbda
X
5ab478cc264c46d88c5dc9a8afa75c69--48c5a02c74c144de9424b1eccb1bbbda
48c5a02c74c144de9424b1eccb1bbbda--9f2a7454563a4c2d8bde8a21247ea60a
fe6fb9df39164ee5b6f03b42c88b1310
RX(theta₁₁)
48c5a02c74c144de9424b1eccb1bbbda--fe6fb9df39164ee5b6f03b42c88b1310
0c0830360f9248389cc1733596d5ed38
RY(theta₁₄)
fe6fb9df39164ee5b6f03b42c88b1310--0c0830360f9248389cc1733596d5ed38
617cd76be1264b7a9781534cb622658e
RX(theta₁₇)
0c0830360f9248389cc1733596d5ed38--617cd76be1264b7a9781534cb622658e
228410a37a2543938607ad762abd7028
617cd76be1264b7a9781534cb622658e--228410a37a2543938607ad762abd7028
338c597628dc4330aa8b30f462031b76
X
228410a37a2543938607ad762abd7028--338c597628dc4330aa8b30f462031b76
338c597628dc4330aa8b30f462031b76--74afd131b29d48678ec07657dd5cf871
3eb699b0efd54ccdba03be66c72c6370
338c597628dc4330aa8b30f462031b76--3eb699b0efd54ccdba03be66c72c6370
3eb699b0efd54ccdba03be66c72c6370--ab75ca681b86434bbf5181e5779b28b6
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
184464d952e0427d998edc78782e3411
0
9226e5b60c1242b8b3568b8ca7d4cc01
184464d952e0427d998edc78782e3411--9226e5b60c1242b8b3568b8ca7d4cc01
757367d505a540d6a7baa6423defac59
1
90a3511236f94adf9366fb8ebb85531d
2b6b7fb9ab8744f9a4cbde45a8827106
9226e5b60c1242b8b3568b8ca7d4cc01--2b6b7fb9ab8744f9a4cbde45a8827106
3f9e8567b5a54aadb792e1ef765fb358
90a3511236f94adf9366fb8ebb85531d--3f9e8567b5a54aadb792e1ef765fb358
203e00c8fb274135858ff4eec802ddfd
a1f5b190a0fb407e9325748323e8b273
3f9e8567b5a54aadb792e1ef765fb358--a1f5b190a0fb407e9325748323e8b273
61efc7cb1d854bfc8d25178cc784faea
203e00c8fb274135858ff4eec802ddfd--61efc7cb1d854bfc8d25178cc784faea
64f4f1342d454b2eb3a9a02ad62badc8
4d30111391ff495e93562dc58fdcc5e1
757367d505a540d6a7baa6423defac59--4d30111391ff495e93562dc58fdcc5e1
da5c297e949e47cfbafa157192275de1
2
4d30111391ff495e93562dc58fdcc5e1--90a3511236f94adf9366fb8ebb85531d
a27c081ec00748d79ab155caa2761429
2b6b7fb9ab8744f9a4cbde45a8827106--a27c081ec00748d79ab155caa2761429
f5815bef23d54ee5b307e726adee59f4
a27c081ec00748d79ab155caa2761429--f5815bef23d54ee5b307e726adee59f4
f5815bef23d54ee5b307e726adee59f4--64f4f1342d454b2eb3a9a02ad62badc8
16c490ed633f4d1f8fccbcd4dc72953d
f3f40c683fd44819acdc1ecfcb8806ae
da5c297e949e47cfbafa157192275de1--f3f40c683fd44819acdc1ecfcb8806ae
b9d849fe0f9a431fb4acef7a08c8adde
3
3926c9d0b20e4d649522951bdac9e79f
f3f40c683fd44819acdc1ecfcb8806ae--3926c9d0b20e4d649522951bdac9e79f
06de7d90ca34439289d4ec5cce06dea5
3926c9d0b20e4d649522951bdac9e79f--06de7d90ca34439289d4ec5cce06dea5
61d2a7b11f7d45698571261dfde89dee
06de7d90ca34439289d4ec5cce06dea5--61d2a7b11f7d45698571261dfde89dee
61d2a7b11f7d45698571261dfde89dee--16c490ed633f4d1f8fccbcd4dc72953d
a90038af984b4f24b1dc27a0d6960bf8
81a96ee10fb442b9ae24d666cb6306bf
b9d849fe0f9a431fb4acef7a08c8adde--81a96ee10fb442b9ae24d666cb6306bf
88c1f818bc9740d5b94436dba9ae3057
81a96ee10fb442b9ae24d666cb6306bf--88c1f818bc9740d5b94436dba9ae3057
8d2f0bfef0b244ce95143210d9b2b44f
88c1f818bc9740d5b94436dba9ae3057--8d2f0bfef0b244ce95143210d9b2b44f
8d2f0bfef0b244ce95143210d9b2b44f--203e00c8fb274135858ff4eec802ddfd
a1f5b190a0fb407e9325748323e8b273--a90038af984b4f24b1dc27a0d6960bf8
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
66dedd74eaeb418ea71515f9b5c9b595
0
9ecbe1ca833d468793242901fa246ad6
66dedd74eaeb418ea71515f9b5c9b595--9ecbe1ca833d468793242901fa246ad6
89aa56e94a934450a39df8b9e2c1d10f
1
c88a50cb62294dd7ae37c61bdc550ea1
9ecbe1ca833d468793242901fa246ad6--c88a50cb62294dd7ae37c61bdc550ea1
d919d003af164214ac0d6e0e4fdf4af0
c88a50cb62294dd7ae37c61bdc550ea1--d919d003af164214ac0d6e0e4fdf4af0
52a46c0232c74132a1df73f4c18cf781
d919d003af164214ac0d6e0e4fdf4af0--52a46c0232c74132a1df73f4c18cf781
66fc0ed8e34d43f89eb3d40026550193
b0383139b5ab4f70bd4590df74ea1aab
PHASE(0.5)
89aa56e94a934450a39df8b9e2c1d10f--b0383139b5ab4f70bd4590df74ea1aab
51532e366436483e947f9ed2152202de
2
b0383139b5ab4f70bd4590df74ea1aab--9ecbe1ca833d468793242901fa246ad6
d203a8f3d9574a31bad933cfbb030534
b0383139b5ab4f70bd4590df74ea1aab--d203a8f3d9574a31bad933cfbb030534
d3568a52e42443ce8c3f554920909230
d203a8f3d9574a31bad933cfbb030534--d3568a52e42443ce8c3f554920909230
d3568a52e42443ce8c3f554920909230--66fc0ed8e34d43f89eb3d40026550193
d83b4c91e9a1455c83ff0bfd6f83c8cb
bcf08db757f142f0865964cc98ba8f50
51532e366436483e947f9ed2152202de--bcf08db757f142f0865964cc98ba8f50
137fbb6702354d70955ae056f9a3d4ff
3
c608763a99954ff886e013f3444f3d6e
PHASE(0.5)
bcf08db757f142f0865964cc98ba8f50--c608763a99954ff886e013f3444f3d6e
c608763a99954ff886e013f3444f3d6e--c88a50cb62294dd7ae37c61bdc550ea1
e4c79970338b4a529b4b20fa9bbd0724
c608763a99954ff886e013f3444f3d6e--e4c79970338b4a529b4b20fa9bbd0724
e4c79970338b4a529b4b20fa9bbd0724--d83b4c91e9a1455c83ff0bfd6f83c8cb
14ca49f95eae405a8ea15ac2cdbd4226
0fb5f77bf02f4c65a7d334811cceae7b
137fbb6702354d70955ae056f9a3d4ff--0fb5f77bf02f4c65a7d334811cceae7b
e4742dddc03a46e79c66f23036389f02
0fb5f77bf02f4c65a7d334811cceae7b--e4742dddc03a46e79c66f23036389f02
16c7ddbb098945a295a891dc150a19b0
PHASE(0.5)
e4742dddc03a46e79c66f23036389f02--16c7ddbb098945a295a891dc150a19b0
16c7ddbb098945a295a891dc150a19b0--d919d003af164214ac0d6e0e4fdf4af0
16c7ddbb098945a295a891dc150a19b0--14ca49f95eae405a8ea15ac2cdbd4226
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