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
145a71c0721b4db3b087ab9e0559d36e
0
7991a397c8fd45188e7e1d9a25a7b5c0
X
145a71c0721b4db3b087ab9e0559d36e--7991a397c8fd45188e7e1d9a25a7b5c0
877fd48927aa45969e8d31bc3a44c8df
1
604add50d34143aa98c1d1825281f910
7991a397c8fd45188e7e1d9a25a7b5c0--604add50d34143aa98c1d1825281f910
cb297aaccd60428bae07e15b48afe54c
a29fca709ca04353b33dbcf7fe608227
Y
877fd48927aa45969e8d31bc3a44c8df--a29fca709ca04353b33dbcf7fe608227
a29fca709ca04353b33dbcf7fe608227--cb297aaccd60428bae07e15b48afe54c
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
9b8139bfd0304c158cad5038d3fd6b68
0
070f463bd6f8429ab915df566b26caa9
X
9b8139bfd0304c158cad5038d3fd6b68--070f463bd6f8429ab915df566b26caa9
0ce4d4324fa543228b6ace005d5389b1
Y
070f463bd6f8429ab915df566b26caa9--0ce4d4324fa543228b6ace005d5389b1
900b76802fc9463abdb153f41faa0bee
0ce4d4324fa543228b6ace005d5389b1--900b76802fc9463abdb153f41faa0bee
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
92389abc1e3e4ade88037ca084135133
0
c445daeb758d44afb498c1cb189b28eb
X
92389abc1e3e4ade88037ca084135133--c445daeb758d44afb498c1cb189b28eb
4372e7974b65462aad476c0af54fa9b7
1
0ef0cc8848d84ae5b5ccca60b30688dc
c445daeb758d44afb498c1cb189b28eb--0ef0cc8848d84ae5b5ccca60b30688dc
e1c8f460ef4c4d06b2065774bdb3a5db
0ef0cc8848d84ae5b5ccca60b30688dc--e1c8f460ef4c4d06b2065774bdb3a5db
d1c9f75f9aac49d1b9ceaacd8373b26c
5f3402bdcde841b9bb8b67ed7111ecad
4372e7974b65462aad476c0af54fa9b7--5f3402bdcde841b9bb8b67ed7111ecad
e0d3ab0d0fd4443db90a7d88ec9c4a17
Y
5f3402bdcde841b9bb8b67ed7111ecad--e0d3ab0d0fd4443db90a7d88ec9c4a17
e0d3ab0d0fd4443db90a7d88ec9c4a17--d1c9f75f9aac49d1b9ceaacd8373b26c
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_11d1b9250df340ffb856b7afcf5eb32e
c06a3d63082948eaaad623080221565a
0
c8342862efc542949d069bffa140c63e
c06a3d63082948eaaad623080221565a--c8342862efc542949d069bffa140c63e
738c05eb7b0b4855adb3411ae6f70b1f
1
84edbe65c1114bae91963ee25c1f51ea
c8342862efc542949d069bffa140c63e--84edbe65c1114bae91963ee25c1f51ea
382ba8680cd347d080cd164b4066578b
b1be24426f4543e58a8f9a0a28110bd9
AddBlock
738c05eb7b0b4855adb3411ae6f70b1f--b1be24426f4543e58a8f9a0a28110bd9
52faeefa3a4c4fc7a5ff04913cfff090
2
b1be24426f4543e58a8f9a0a28110bd9--382ba8680cd347d080cd164b4066578b
c842f1b6ae9649a29b9077b850a5b029
78d295fa1fe146d4967f1602d62c4126
52faeefa3a4c4fc7a5ff04913cfff090--78d295fa1fe146d4967f1602d62c4126
78d295fa1fe146d4967f1602d62c4126--c842f1b6ae9649a29b9077b850a5b029
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_a4c352dd01354650b1fcc1359ce59e93
cluster_01b9bab2e7454840aaeaa4f2501f7d5c
rx
6234461e2d8f4e0db6dbfba535dd94cf
0
eaafde90f36147cbbaaa73105834bc19
X
6234461e2d8f4e0db6dbfba535dd94cf--eaafde90f36147cbbaaa73105834bc19
2f44a754af164a83856cb709c0458267
1
8710f4eeea544fc1b08cd9c3a9fb3a08
eaafde90f36147cbbaaa73105834bc19--8710f4eeea544fc1b08cd9c3a9fb3a08
d2fd32139daf498c87218bce1d6af8cd
8710f4eeea544fc1b08cd9c3a9fb3a08--d2fd32139daf498c87218bce1d6af8cd
d392bde3d3fd4dea80466618f530581a
d2fd32139daf498c87218bce1d6af8cd--d392bde3d3fd4dea80466618f530581a
b2e75bb7b4e24792bef189a2e548edfa
633367b6bca340c1bdd7e999b0bbc920
Y
2f44a754af164a83856cb709c0458267--633367b6bca340c1bdd7e999b0bbc920
92a3a55bf9a84856b00ff43feefb20d2
2
4ad72579d6be4dc4aac57c099c856ed7
633367b6bca340c1bdd7e999b0bbc920--4ad72579d6be4dc4aac57c099c856ed7
bfbd8feac0f940fbb2c77bd99e629d91
HamEvo
4ad72579d6be4dc4aac57c099c856ed7--bfbd8feac0f940fbb2c77bd99e629d91
bfbd8feac0f940fbb2c77bd99e629d91--b2e75bb7b4e24792bef189a2e548edfa
53eed243aae445c0afaf7f7e401a4cee
2574ead11eba49e5b4340c7b1c17ea31
RX(x)
92a3a55bf9a84856b00ff43feefb20d2--2574ead11eba49e5b4340c7b1c17ea31
e952570a48cd47b58651c0057bd7697a
3
2775462bf0374365bc13668238ed7bff
2574ead11eba49e5b4340c7b1c17ea31--2775462bf0374365bc13668238ed7bff
ea042cd565e6477b9ae736d4eaa1e660
t = 10
2775462bf0374365bc13668238ed7bff--ea042cd565e6477b9ae736d4eaa1e660
ea042cd565e6477b9ae736d4eaa1e660--53eed243aae445c0afaf7f7e401a4cee
3dcd0a6638d94d10be23e7e27c11e440
b1bb75cf927a4dcf8da00c6a0639d2eb
RX(0.5)
e952570a48cd47b58651c0057bd7697a--b1bb75cf927a4dcf8da00c6a0639d2eb
9d3ca271ff0a456b8fb9daa27ce613ec
X
b1bb75cf927a4dcf8da00c6a0639d2eb--9d3ca271ff0a456b8fb9daa27ce613ec
9d3ca271ff0a456b8fb9daa27ce613ec--2775462bf0374365bc13668238ed7bff
81b48a1416d8423b8981bddf326974ad
9d3ca271ff0a456b8fb9daa27ce613ec--81b48a1416d8423b8981bddf326974ad
81b48a1416d8423b8981bddf326974ad--3dcd0a6638d94d10be23e7e27c11e440
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_88e07a67cba74d9cab4da27c8ad0d7fa
HEA
cluster_f4a9e85dbdf24209ab116889f29667ae
Tower Fourier FM
20af8818a1e54f7e9d7a3d71a9be31a4
0
a45f7e8fd611427d94c98a236457a4d1
RX(1.0*phi)
20af8818a1e54f7e9d7a3d71a9be31a4--a45f7e8fd611427d94c98a236457a4d1
88542eb6fb3346c39a0a9a4ee7a68a4f
1
19509be7054647fdbb8ccee32bc01db8
RX(theta₀)
a45f7e8fd611427d94c98a236457a4d1--19509be7054647fdbb8ccee32bc01db8
c6274c8f0e51467e94a0beae36cb5e2b
RY(theta₄)
19509be7054647fdbb8ccee32bc01db8--c6274c8f0e51467e94a0beae36cb5e2b
31cf9dd21e1a4a88aa906487635d3eca
RX(theta₈)
c6274c8f0e51467e94a0beae36cb5e2b--31cf9dd21e1a4a88aa906487635d3eca
aee1d983a620463f969267cbf0e68cfa
31cf9dd21e1a4a88aa906487635d3eca--aee1d983a620463f969267cbf0e68cfa
781548b369444b6a8837c3e75b1db93e
aee1d983a620463f969267cbf0e68cfa--781548b369444b6a8837c3e75b1db93e
24aacb3e4a5a430c836ca879ef5088be
RX(theta₁₂)
781548b369444b6a8837c3e75b1db93e--24aacb3e4a5a430c836ca879ef5088be
227236a385284d58b7421ca7f5fb2953
RY(theta₁₆)
24aacb3e4a5a430c836ca879ef5088be--227236a385284d58b7421ca7f5fb2953
b715ccffb0d2438fa19b67c4d9af50d1
RX(theta₂₀)
227236a385284d58b7421ca7f5fb2953--b715ccffb0d2438fa19b67c4d9af50d1
51abf4dc1fb04fe5b7a4eae33f4ab296
b715ccffb0d2438fa19b67c4d9af50d1--51abf4dc1fb04fe5b7a4eae33f4ab296
814bc6d3f14c4fb9b0034f1d373391b1
51abf4dc1fb04fe5b7a4eae33f4ab296--814bc6d3f14c4fb9b0034f1d373391b1
e4129218b4f64fc19eff3137b32b5d9e
814bc6d3f14c4fb9b0034f1d373391b1--e4129218b4f64fc19eff3137b32b5d9e
85d648f9733040cc9ec63880d98745bf
cedd38cb3cc34ed8befbb81d1ce5d6e3
RX(2.0*phi)
88542eb6fb3346c39a0a9a4ee7a68a4f--cedd38cb3cc34ed8befbb81d1ce5d6e3
56d4e2c2048c40c0a5bf2faf1b9cc989
2
0f3756558d204925a8804feb672d28c1
RX(theta₁)
cedd38cb3cc34ed8befbb81d1ce5d6e3--0f3756558d204925a8804feb672d28c1
74cbc2f5ac7a41c4a0d128ef7836082d
RY(theta₅)
0f3756558d204925a8804feb672d28c1--74cbc2f5ac7a41c4a0d128ef7836082d
b1c11a6744264ede94a98253b3a84a6d
RX(theta₉)
74cbc2f5ac7a41c4a0d128ef7836082d--b1c11a6744264ede94a98253b3a84a6d
48faaa677c8b47419c75d77b89705d3c
X
b1c11a6744264ede94a98253b3a84a6d--48faaa677c8b47419c75d77b89705d3c
48faaa677c8b47419c75d77b89705d3c--aee1d983a620463f969267cbf0e68cfa
3ada91008c1f48dd88776ed625a42954
48faaa677c8b47419c75d77b89705d3c--3ada91008c1f48dd88776ed625a42954
d6359f20cdf54640b0b338bd4969238a
RX(theta₁₃)
3ada91008c1f48dd88776ed625a42954--d6359f20cdf54640b0b338bd4969238a
6995dd0d267042a5b39d8a209b1b8bbe
RY(theta₁₇)
d6359f20cdf54640b0b338bd4969238a--6995dd0d267042a5b39d8a209b1b8bbe
1308d43c61ad497db0d6e87f23fed496
RX(theta₂₁)
6995dd0d267042a5b39d8a209b1b8bbe--1308d43c61ad497db0d6e87f23fed496
a3cb246f5ae048878f00ee5f675f3956
X
1308d43c61ad497db0d6e87f23fed496--a3cb246f5ae048878f00ee5f675f3956
a3cb246f5ae048878f00ee5f675f3956--51abf4dc1fb04fe5b7a4eae33f4ab296
6694e04e95f34136954b7e431249d091
a3cb246f5ae048878f00ee5f675f3956--6694e04e95f34136954b7e431249d091
6694e04e95f34136954b7e431249d091--85d648f9733040cc9ec63880d98745bf
13a88493a8cd423e9ba210ed4113d544
fbc4d3e92d3e42d28631e3960feab4db
RX(3.0*phi)
56d4e2c2048c40c0a5bf2faf1b9cc989--fbc4d3e92d3e42d28631e3960feab4db
dca816bb06a741d69fb8a8a1a5a072ce
3
1215292872bb4e3889a378bd8b0dd1ee
RX(theta₂)
fbc4d3e92d3e42d28631e3960feab4db--1215292872bb4e3889a378bd8b0dd1ee
f841766e87cf4db7bc171a81b20b4fe2
RY(theta₆)
1215292872bb4e3889a378bd8b0dd1ee--f841766e87cf4db7bc171a81b20b4fe2
8dbc7b39d4674a3fbf78634370df62eb
RX(theta₁₀)
f841766e87cf4db7bc171a81b20b4fe2--8dbc7b39d4674a3fbf78634370df62eb
606bed406e0345409d9e19959cf94e47
8dbc7b39d4674a3fbf78634370df62eb--606bed406e0345409d9e19959cf94e47
7888b289872a4769b0a583efb49684df
X
606bed406e0345409d9e19959cf94e47--7888b289872a4769b0a583efb49684df
7888b289872a4769b0a583efb49684df--3ada91008c1f48dd88776ed625a42954
b393ea9b6e324a3894c132e7c916d3e4
RX(theta₁₄)
7888b289872a4769b0a583efb49684df--b393ea9b6e324a3894c132e7c916d3e4
f42a95bd7080498ba4382933f99f77a2
RY(theta₁₈)
b393ea9b6e324a3894c132e7c916d3e4--f42a95bd7080498ba4382933f99f77a2
bc30b10c7daf407c80c2b26bdb4ea1b2
RX(theta₂₂)
f42a95bd7080498ba4382933f99f77a2--bc30b10c7daf407c80c2b26bdb4ea1b2
222b030273394976833c4d090cd518d4
bc30b10c7daf407c80c2b26bdb4ea1b2--222b030273394976833c4d090cd518d4
3c577286b5604263a29cdadaada1495c
X
222b030273394976833c4d090cd518d4--3c577286b5604263a29cdadaada1495c
3c577286b5604263a29cdadaada1495c--6694e04e95f34136954b7e431249d091
3c577286b5604263a29cdadaada1495c--13a88493a8cd423e9ba210ed4113d544
8a90b89151884816893d6684b7b2429a
532aeedf9e2e4966bae36e38db37284b
RX(4.0*phi)
dca816bb06a741d69fb8a8a1a5a072ce--532aeedf9e2e4966bae36e38db37284b
bd99245d86004274882509058d1f3d77
RX(theta₃)
532aeedf9e2e4966bae36e38db37284b--bd99245d86004274882509058d1f3d77
f3433c29b46b422baefc22b9fa48ecef
RY(theta₇)
bd99245d86004274882509058d1f3d77--f3433c29b46b422baefc22b9fa48ecef
0c37d1c232914514a759e92b805972fa
RX(theta₁₁)
f3433c29b46b422baefc22b9fa48ecef--0c37d1c232914514a759e92b805972fa
b9aca8d0a806416d93ab5b90d1cc2669
X
0c37d1c232914514a759e92b805972fa--b9aca8d0a806416d93ab5b90d1cc2669
b9aca8d0a806416d93ab5b90d1cc2669--606bed406e0345409d9e19959cf94e47
245222e44d2442c99d9aa83bd5bc7c16
b9aca8d0a806416d93ab5b90d1cc2669--245222e44d2442c99d9aa83bd5bc7c16
84f10ead6c96484a9c526aabe2f20791
RX(theta₁₅)
245222e44d2442c99d9aa83bd5bc7c16--84f10ead6c96484a9c526aabe2f20791
4dcd0d4bf02547faa6e924ec90a9234c
RY(theta₁₉)
84f10ead6c96484a9c526aabe2f20791--4dcd0d4bf02547faa6e924ec90a9234c
8ea32630da074bb4801064b53a54bae5
RX(theta₂₃)
4dcd0d4bf02547faa6e924ec90a9234c--8ea32630da074bb4801064b53a54bae5
da7f92927a074a53aff1f455fe674997
X
8ea32630da074bb4801064b53a54bae5--da7f92927a074a53aff1f455fe674997
da7f92927a074a53aff1f455fe674997--222b030273394976833c4d090cd518d4
65a4249223c34b78bf03eaa7409d6937
da7f92927a074a53aff1f455fe674997--65a4249223c34b78bf03eaa7409d6937
65a4249223c34b78bf03eaa7409d6937--8a90b89151884816893d6684b7b2429a
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_8e73cd68481244adb15e3750ad8d00e6
Obs.
cluster_9bf0dbed515e4ad2b01477d0c63b7808
cluster_f1f6667098e14873a54fdac6de07b849
HEA
9b93fddf03f94e2eacf6b8cbf2b11e49
0
3fc31bc79f484cd68181b23687cc5a40
RX(theta₀)
9b93fddf03f94e2eacf6b8cbf2b11e49--3fc31bc79f484cd68181b23687cc5a40
98df4294c787465ca27c955354a0f2dd
1
bebe8d898bb349dc89f8549bca097c05
RY(theta₃)
3fc31bc79f484cd68181b23687cc5a40--bebe8d898bb349dc89f8549bca097c05
bac8b28494984c6ab162868daa6f26fa
RX(theta₆)
bebe8d898bb349dc89f8549bca097c05--bac8b28494984c6ab162868daa6f26fa
9d10c277ef8a4c10adaac5392b1ac778
bac8b28494984c6ab162868daa6f26fa--9d10c277ef8a4c10adaac5392b1ac778
9cba2bee01e84b85b070c6ea282fa8cd
9d10c277ef8a4c10adaac5392b1ac778--9cba2bee01e84b85b070c6ea282fa8cd
bbf5a3cb38254d1abc2cc76e2428b996
RX(theta₉)
9cba2bee01e84b85b070c6ea282fa8cd--bbf5a3cb38254d1abc2cc76e2428b996
319972bd0e1b497ea6fc051fec8250ed
RY(theta₁₂)
bbf5a3cb38254d1abc2cc76e2428b996--319972bd0e1b497ea6fc051fec8250ed
84928405e1844f05b73e084140476a06
RX(theta₁₅)
319972bd0e1b497ea6fc051fec8250ed--84928405e1844f05b73e084140476a06
c3a6f6d7eab94d8f8990c0f4d6d8e022
84928405e1844f05b73e084140476a06--c3a6f6d7eab94d8f8990c0f4d6d8e022
e0ef33a4a0cc40d9a510acfbf2e3ca6a
c3a6f6d7eab94d8f8990c0f4d6d8e022--e0ef33a4a0cc40d9a510acfbf2e3ca6a
3ccba28429b949f996260687c346fa2c
e0ef33a4a0cc40d9a510acfbf2e3ca6a--3ccba28429b949f996260687c346fa2c
97d73295190d452787532be24dd283d5
3ccba28429b949f996260687c346fa2c--97d73295190d452787532be24dd283d5
106dbc45b75e4053bd15d02ad6270113
c7ab547b549f407ea6f8825b8e3a61d9
RX(theta₁)
98df4294c787465ca27c955354a0f2dd--c7ab547b549f407ea6f8825b8e3a61d9
b806b92d24e24cfcbcb0564ffb13f3ae
2
14fa873d0d2b4db391f55a34f90cd683
RY(theta₄)
c7ab547b549f407ea6f8825b8e3a61d9--14fa873d0d2b4db391f55a34f90cd683
d67eba5e9cb74ec6ae282e3bf4d0f8d6
RX(theta₇)
14fa873d0d2b4db391f55a34f90cd683--d67eba5e9cb74ec6ae282e3bf4d0f8d6
d5774725cf004b2fa8fc1030c3eb0795
X
d67eba5e9cb74ec6ae282e3bf4d0f8d6--d5774725cf004b2fa8fc1030c3eb0795
d5774725cf004b2fa8fc1030c3eb0795--9d10c277ef8a4c10adaac5392b1ac778
dd9cb501be834f0fb075ceeb8416831d
d5774725cf004b2fa8fc1030c3eb0795--dd9cb501be834f0fb075ceeb8416831d
1c454918138048eab2f09e4e7e750bfe
RX(theta₁₀)
dd9cb501be834f0fb075ceeb8416831d--1c454918138048eab2f09e4e7e750bfe
159bf9ef32cb40529d518c92bba657c4
RY(theta₁₃)
1c454918138048eab2f09e4e7e750bfe--159bf9ef32cb40529d518c92bba657c4
b7ab46d58f034ed58ab33aaa282e3296
RX(theta₁₆)
159bf9ef32cb40529d518c92bba657c4--b7ab46d58f034ed58ab33aaa282e3296
d547c4ee1fd94e988d6c95c42fcafc14
X
b7ab46d58f034ed58ab33aaa282e3296--d547c4ee1fd94e988d6c95c42fcafc14
d547c4ee1fd94e988d6c95c42fcafc14--c3a6f6d7eab94d8f8990c0f4d6d8e022
142cf7c315ae4fa2af49c94f9de44241
d547c4ee1fd94e988d6c95c42fcafc14--142cf7c315ae4fa2af49c94f9de44241
ca326ed5286f4ec4b852d1012d724880
AddBlock
142cf7c315ae4fa2af49c94f9de44241--ca326ed5286f4ec4b852d1012d724880
ca326ed5286f4ec4b852d1012d724880--106dbc45b75e4053bd15d02ad6270113
15664f03ca2b4b3fa67cc84ea8ce4512
f1b28bb3d79e4de5a8b61109a855e13b
RX(theta₂)
b806b92d24e24cfcbcb0564ffb13f3ae--f1b28bb3d79e4de5a8b61109a855e13b
c566b4cc19ea4207aeedeba8170ac10b
RY(theta₅)
f1b28bb3d79e4de5a8b61109a855e13b--c566b4cc19ea4207aeedeba8170ac10b
0e2f929c18174aa69f5d7530500d9742
RX(theta₈)
c566b4cc19ea4207aeedeba8170ac10b--0e2f929c18174aa69f5d7530500d9742
5753973e59a940e2be661cd9bf1cc682
0e2f929c18174aa69f5d7530500d9742--5753973e59a940e2be661cd9bf1cc682
86bd5a681f5a4415b98d689255d6d707
X
5753973e59a940e2be661cd9bf1cc682--86bd5a681f5a4415b98d689255d6d707
86bd5a681f5a4415b98d689255d6d707--dd9cb501be834f0fb075ceeb8416831d
590b047e29d54b7eafc7df5b6ee41357
RX(theta₁₁)
86bd5a681f5a4415b98d689255d6d707--590b047e29d54b7eafc7df5b6ee41357
b7badd6494bd4a18a24b33f6531261fb
RY(theta₁₄)
590b047e29d54b7eafc7df5b6ee41357--b7badd6494bd4a18a24b33f6531261fb
9b5f2fa660854860a614103e27b103a7
RX(theta₁₇)
b7badd6494bd4a18a24b33f6531261fb--9b5f2fa660854860a614103e27b103a7
50b14256eafd47f9bbeb69e896a4b22f
9b5f2fa660854860a614103e27b103a7--50b14256eafd47f9bbeb69e896a4b22f
9c8622af56ff4ae0aa90181397dbed9b
X
50b14256eafd47f9bbeb69e896a4b22f--9c8622af56ff4ae0aa90181397dbed9b
9c8622af56ff4ae0aa90181397dbed9b--142cf7c315ae4fa2af49c94f9de44241
73c106f2a2c34ac9b3fc1c56c5e67801
9c8622af56ff4ae0aa90181397dbed9b--73c106f2a2c34ac9b3fc1c56c5e67801
73c106f2a2c34ac9b3fc1c56c5e67801--15664f03ca2b4b3fa67cc84ea8ce4512
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
42977d5ea4f64ceaaa32c3c21e44291a
0
f843fe86dc24404f9624225401a71607
42977d5ea4f64ceaaa32c3c21e44291a--f843fe86dc24404f9624225401a71607
7d1c3166f71640efb33eb58009c90a7a
1
52a15d1a27134f668603bebb6730b5f7
e74d093c33424c1b98c8ad9d0c90131d
f843fe86dc24404f9624225401a71607--e74d093c33424c1b98c8ad9d0c90131d
486f74fe7f1d4c51b96ba8d92925ff7b
52a15d1a27134f668603bebb6730b5f7--486f74fe7f1d4c51b96ba8d92925ff7b
705d3765c7de4c55ab5f865169f53c5c
dfd1fb46f61b4dc8b4f1f22b6a87af23
486f74fe7f1d4c51b96ba8d92925ff7b--dfd1fb46f61b4dc8b4f1f22b6a87af23
49da80e2fd824b4e90683c83fb8e31b6
705d3765c7de4c55ab5f865169f53c5c--49da80e2fd824b4e90683c83fb8e31b6
c45581bc292242d6b30db0d1650f4892
f3d33f94c4f147a199d8d30608010366
7d1c3166f71640efb33eb58009c90a7a--f3d33f94c4f147a199d8d30608010366
8374449032cd4d3499819e32c8181d12
2
f3d33f94c4f147a199d8d30608010366--52a15d1a27134f668603bebb6730b5f7
0a5d1825d95b45b5812ad8c43b3aac6b
e74d093c33424c1b98c8ad9d0c90131d--0a5d1825d95b45b5812ad8c43b3aac6b
a551359965894134b0954c86fe39178c
0a5d1825d95b45b5812ad8c43b3aac6b--a551359965894134b0954c86fe39178c
a551359965894134b0954c86fe39178c--c45581bc292242d6b30db0d1650f4892
35d8bb467000483d9ee95cc1d18dc14d
6c0e984d73754523adade9efd7f30ab3
8374449032cd4d3499819e32c8181d12--6c0e984d73754523adade9efd7f30ab3
ec7933d8228249c68ce3c798cc0f0d23
3
37e99aea8e054e82a58fcb8d98876e76
6c0e984d73754523adade9efd7f30ab3--37e99aea8e054e82a58fcb8d98876e76
e07c4a22dd174a93988dcbe0ac2fb550
37e99aea8e054e82a58fcb8d98876e76--e07c4a22dd174a93988dcbe0ac2fb550
9c85bf8f1095426abcff94c6480968e8
e07c4a22dd174a93988dcbe0ac2fb550--9c85bf8f1095426abcff94c6480968e8
9c85bf8f1095426abcff94c6480968e8--35d8bb467000483d9ee95cc1d18dc14d
fe8b964e596c4348b061ab3a411b34e8
dd08d604a93c450bb47e7499bc8f235a
ec7933d8228249c68ce3c798cc0f0d23--dd08d604a93c450bb47e7499bc8f235a
ae0af47cd8dc4abf879af29d97236d1c
dd08d604a93c450bb47e7499bc8f235a--ae0af47cd8dc4abf879af29d97236d1c
8a50e43f924c454d821bc5bbe13945bc
ae0af47cd8dc4abf879af29d97236d1c--8a50e43f924c454d821bc5bbe13945bc
8a50e43f924c454d821bc5bbe13945bc--705d3765c7de4c55ab5f865169f53c5c
dfd1fb46f61b4dc8b4f1f22b6a87af23--fe8b964e596c4348b061ab3a411b34e8
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
c7428ffe448141458565d48eb8ca85c5
0
b8ff104b24a44f44b53dccff7d32a1b7
c7428ffe448141458565d48eb8ca85c5--b8ff104b24a44f44b53dccff7d32a1b7
d5746e29cfca43b98caaea828eefddde
1
633cf2690db44cf483b626089aa00750
b8ff104b24a44f44b53dccff7d32a1b7--633cf2690db44cf483b626089aa00750
6e287e73cf4b49389a4b9260006fbefe
633cf2690db44cf483b626089aa00750--6e287e73cf4b49389a4b9260006fbefe
60799ec47bdd455f95b290c6bab24d89
6e287e73cf4b49389a4b9260006fbefe--60799ec47bdd455f95b290c6bab24d89
9eb2589e277e4d91b0ae0d8a06c2de68
78fca60eba734918807903c3f0f72de0
PHASE(0.5)
d5746e29cfca43b98caaea828eefddde--78fca60eba734918807903c3f0f72de0
33049d51a6db44198ab6049745e5900d
2
78fca60eba734918807903c3f0f72de0--b8ff104b24a44f44b53dccff7d32a1b7
474eeed070614437a9b02a3a3985f82a
78fca60eba734918807903c3f0f72de0--474eeed070614437a9b02a3a3985f82a
00ccc557fb854c77ae971fce4c1a28e3
474eeed070614437a9b02a3a3985f82a--00ccc557fb854c77ae971fce4c1a28e3
00ccc557fb854c77ae971fce4c1a28e3--9eb2589e277e4d91b0ae0d8a06c2de68
db2b9aee9edd41c48eb8206e937ac330
15151c9e88124355995243f4791c46f5
33049d51a6db44198ab6049745e5900d--15151c9e88124355995243f4791c46f5
d3baccf2db5242a0ac76a4300577b711
3
c3af084ea0da4dfda0f4ef90de6b1d41
PHASE(0.5)
15151c9e88124355995243f4791c46f5--c3af084ea0da4dfda0f4ef90de6b1d41
c3af084ea0da4dfda0f4ef90de6b1d41--633cf2690db44cf483b626089aa00750
2d416211a633404d9a9a3c48be9c5282
c3af084ea0da4dfda0f4ef90de6b1d41--2d416211a633404d9a9a3c48be9c5282
2d416211a633404d9a9a3c48be9c5282--db2b9aee9edd41c48eb8206e937ac330
1d100734b0344a58842ac2c70d1430a1
4a6c4cb83b3e4b84afd67704bb397723
d3baccf2db5242a0ac76a4300577b711--4a6c4cb83b3e4b84afd67704bb397723
5047a791987745b6a1ca513e7a194052
4a6c4cb83b3e4b84afd67704bb397723--5047a791987745b6a1ca513e7a194052
81dd0ead3fb74e398a7ae38d15435197
PHASE(0.5)
5047a791987745b6a1ca513e7a194052--81dd0ead3fb74e398a7ae38d15435197
81dd0ead3fb74e398a7ae38d15435197--6e287e73cf4b49389a4b9260006fbefe
81dd0ead3fb74e398a7ae38d15435197--1d100734b0344a58842ac2c70d1430a1
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