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
7c82cace8b5f46f09a717e65ee3d8532
0
bcb3611f41e442bd9a008ec8adc9ef14
X
7c82cace8b5f46f09a717e65ee3d8532--bcb3611f41e442bd9a008ec8adc9ef14
c983a1a3bf55429492049e2045dde38d
1
05ae07f236e54c5da727bde7a37a1cc7
bcb3611f41e442bd9a008ec8adc9ef14--05ae07f236e54c5da727bde7a37a1cc7
1bc208ee1ab74d23ba06a64452aae497
895a3b54b7b24cc58baf99a5a9573fa0
Y
c983a1a3bf55429492049e2045dde38d--895a3b54b7b24cc58baf99a5a9573fa0
895a3b54b7b24cc58baf99a5a9573fa0--1bc208ee1ab74d23ba06a64452aae497
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
a1cdec8ad0aa43ed9dc85412dd4ce2cc
0
7d4c4d2c2ef54cfa8cfb7b24a1fbb05e
X
a1cdec8ad0aa43ed9dc85412dd4ce2cc--7d4c4d2c2ef54cfa8cfb7b24a1fbb05e
d912d23145e54df3b06f30893f931291
Y
7d4c4d2c2ef54cfa8cfb7b24a1fbb05e--d912d23145e54df3b06f30893f931291
4e5a4478cedc473f8f9f218ac23ef545
d912d23145e54df3b06f30893f931291--4e5a4478cedc473f8f9f218ac23ef545
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
36a492ee7fa2469ebe7b92742de0b3fd
0
7c569f4b9a594e07a590935ff4d0070f
X
36a492ee7fa2469ebe7b92742de0b3fd--7c569f4b9a594e07a590935ff4d0070f
73d497b233bf4676a3e6179697d58161
1
bf18c582798e47268497dfc4a0c150fa
7c569f4b9a594e07a590935ff4d0070f--bf18c582798e47268497dfc4a0c150fa
1d6a573e2ede44ddbb027e1af8844102
bf18c582798e47268497dfc4a0c150fa--1d6a573e2ede44ddbb027e1af8844102
b67b4447b25c48c899685bcb1c5de88d
49494cd8868f4f7a92bdc67bb3c29f55
73d497b233bf4676a3e6179697d58161--49494cd8868f4f7a92bdc67bb3c29f55
650a70eb4a2d415aadedd3a246b6d222
Y
49494cd8868f4f7a92bdc67bb3c29f55--650a70eb4a2d415aadedd3a246b6d222
650a70eb4a2d415aadedd3a246b6d222--b67b4447b25c48c899685bcb1c5de88d
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_d125fd24373d445aa1c4e9bef07e880c
295aa34a55e541a08fa3fe4d5df2adaf
0
cf714a1c2ab44058845cf6230b203b48
295aa34a55e541a08fa3fe4d5df2adaf--cf714a1c2ab44058845cf6230b203b48
c23a246a8e1a47b084aa2d876b88d017
1
94b66da1050d43eda5fcd6a5a4739049
cf714a1c2ab44058845cf6230b203b48--94b66da1050d43eda5fcd6a5a4739049
d0d70c00e207484583b377b96a2f2550
4752d66d9b354f198252aaaa22530bf2
AddBlock
c23a246a8e1a47b084aa2d876b88d017--4752d66d9b354f198252aaaa22530bf2
51879c2448b04572abd7902ba136f290
2
4752d66d9b354f198252aaaa22530bf2--d0d70c00e207484583b377b96a2f2550
47c39441cd9d4992b7eb7425fb9fed1d
ded7b6725eca431da4ad74c8867b78e8
51879c2448b04572abd7902ba136f290--ded7b6725eca431da4ad74c8867b78e8
ded7b6725eca431da4ad74c8867b78e8--47c39441cd9d4992b7eb7425fb9fed1d
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_0e383a51a84b456ea4626d6324ed1774
cluster_eed8a2df62354fa5a895357e877916f4
rx
58a6333a4fb5413c9231d26dd461494f
0
8afa6448e5e04377846b8aeb9a05b61e
X
58a6333a4fb5413c9231d26dd461494f--8afa6448e5e04377846b8aeb9a05b61e
77d32856bf2448ea88d37684b50e66f4
1
c0cd4a9c2e0a4732a9a47ed91982459d
8afa6448e5e04377846b8aeb9a05b61e--c0cd4a9c2e0a4732a9a47ed91982459d
91036a8244c04662a2de439be0a320f8
c0cd4a9c2e0a4732a9a47ed91982459d--91036a8244c04662a2de439be0a320f8
1f08df871af34be49374f68ba818544e
91036a8244c04662a2de439be0a320f8--1f08df871af34be49374f68ba818544e
960a74126a0e4061b6ab1a78994f78de
d420d8418a7444e1858ff1aee482f381
Y
77d32856bf2448ea88d37684b50e66f4--d420d8418a7444e1858ff1aee482f381
558302b020844b2ea3c5e39db07e0084
2
0b0866061af44a9290805320e6630bae
d420d8418a7444e1858ff1aee482f381--0b0866061af44a9290805320e6630bae
16015d2364404f43aa40a251882ea699
HamEvo
0b0866061af44a9290805320e6630bae--16015d2364404f43aa40a251882ea699
16015d2364404f43aa40a251882ea699--960a74126a0e4061b6ab1a78994f78de
74df4bd8171149f1b5c860dac4bf1ef5
e04396be33a54c858be6c8819cad66e6
RX(x)
558302b020844b2ea3c5e39db07e0084--e04396be33a54c858be6c8819cad66e6
36fa671262fb49baacdcfba2e73b68ec
3
bc225134575b447bb85af611c53277f1
e04396be33a54c858be6c8819cad66e6--bc225134575b447bb85af611c53277f1
82c6de83927847cbb13e68e5baa98359
t = 10
bc225134575b447bb85af611c53277f1--82c6de83927847cbb13e68e5baa98359
82c6de83927847cbb13e68e5baa98359--74df4bd8171149f1b5c860dac4bf1ef5
7e5b4d5c5a2b4216a90c1dbd119d5648
9e97d30f30d34860b97e2d9a3a6a67e0
RX(0.5)
36fa671262fb49baacdcfba2e73b68ec--9e97d30f30d34860b97e2d9a3a6a67e0
89ec632dded547b0b398d5473923bd6d
X
9e97d30f30d34860b97e2d9a3a6a67e0--89ec632dded547b0b398d5473923bd6d
89ec632dded547b0b398d5473923bd6d--bc225134575b447bb85af611c53277f1
273033f7508a4881b9727791ef1600eb
89ec632dded547b0b398d5473923bd6d--273033f7508a4881b9727791ef1600eb
273033f7508a4881b9727791ef1600eb--7e5b4d5c5a2b4216a90c1dbd119d5648
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_15f3332d4e5243f4971145f629289971
HEA
cluster_a8f465b422ce4373beb3d12982d12c2d
Tower Fourier FM
4c90a0c8f775429b9f256705bbdccae0
0
38f1e3723567428fb7d26529bb8d8c38
RX(1.0*phi)
4c90a0c8f775429b9f256705bbdccae0--38f1e3723567428fb7d26529bb8d8c38
f225518b0caf4751ac6ee308e78c7003
1
e7c2d271ec57457680564b1ca8ed9a15
RX(theta₀)
38f1e3723567428fb7d26529bb8d8c38--e7c2d271ec57457680564b1ca8ed9a15
bc78da93f62f4f9b87ec0bc7d0d3f1ef
RY(theta₄)
e7c2d271ec57457680564b1ca8ed9a15--bc78da93f62f4f9b87ec0bc7d0d3f1ef
054e5594d3204ee69bf2dca63615a34d
RX(theta₈)
bc78da93f62f4f9b87ec0bc7d0d3f1ef--054e5594d3204ee69bf2dca63615a34d
9a5b4adb29844b14b0b91ed3a46230e0
054e5594d3204ee69bf2dca63615a34d--9a5b4adb29844b14b0b91ed3a46230e0
5d61c095684c4d48b1c11e7ffec1043b
9a5b4adb29844b14b0b91ed3a46230e0--5d61c095684c4d48b1c11e7ffec1043b
1f9d02f3b0d6413abad101bfe017ee99
RX(theta₁₂)
5d61c095684c4d48b1c11e7ffec1043b--1f9d02f3b0d6413abad101bfe017ee99
0b36e817bb574068853aaab43701e096
RY(theta₁₆)
1f9d02f3b0d6413abad101bfe017ee99--0b36e817bb574068853aaab43701e096
58af6156c6fd4fc68caf7c73481fad90
RX(theta₂₀)
0b36e817bb574068853aaab43701e096--58af6156c6fd4fc68caf7c73481fad90
c253e348898c4193ab56014c1fc264f8
58af6156c6fd4fc68caf7c73481fad90--c253e348898c4193ab56014c1fc264f8
c1b8789ce0a84794b430ec2a29001f72
c253e348898c4193ab56014c1fc264f8--c1b8789ce0a84794b430ec2a29001f72
81eb8ca32e9549dba9853770f0777829
c1b8789ce0a84794b430ec2a29001f72--81eb8ca32e9549dba9853770f0777829
a92db5de5505491788a9759cd4bdd33a
610f88cf207242929c523f9e4c417f52
RX(2.0*phi)
f225518b0caf4751ac6ee308e78c7003--610f88cf207242929c523f9e4c417f52
99878b3d90f845498a22ba41076630bb
2
dc5e1d7e790c473a82632640aaf91476
RX(theta₁)
610f88cf207242929c523f9e4c417f52--dc5e1d7e790c473a82632640aaf91476
c78dced16cb443fcba67c1938a9d7e94
RY(theta₅)
dc5e1d7e790c473a82632640aaf91476--c78dced16cb443fcba67c1938a9d7e94
499de9e0800a48a38292e7bfa5a77e2b
RX(theta₉)
c78dced16cb443fcba67c1938a9d7e94--499de9e0800a48a38292e7bfa5a77e2b
a932b5fdd8cd4bda97669bf9bb83c072
X
499de9e0800a48a38292e7bfa5a77e2b--a932b5fdd8cd4bda97669bf9bb83c072
a932b5fdd8cd4bda97669bf9bb83c072--9a5b4adb29844b14b0b91ed3a46230e0
3c26fb2df9874bbfb8d65dfe107b7814
a932b5fdd8cd4bda97669bf9bb83c072--3c26fb2df9874bbfb8d65dfe107b7814
ccdea9605a4f44fbb6348aecb63006ed
RX(theta₁₃)
3c26fb2df9874bbfb8d65dfe107b7814--ccdea9605a4f44fbb6348aecb63006ed
ad3284c01a2f4cc19458d452fba37132
RY(theta₁₇)
ccdea9605a4f44fbb6348aecb63006ed--ad3284c01a2f4cc19458d452fba37132
1a0c09f3018d4c63b19a164e52d6f32c
RX(theta₂₁)
ad3284c01a2f4cc19458d452fba37132--1a0c09f3018d4c63b19a164e52d6f32c
df47af678908420bb54dcd08d4934b23
X
1a0c09f3018d4c63b19a164e52d6f32c--df47af678908420bb54dcd08d4934b23
df47af678908420bb54dcd08d4934b23--c253e348898c4193ab56014c1fc264f8
a21df5b8041c4094871ff8069bb24598
df47af678908420bb54dcd08d4934b23--a21df5b8041c4094871ff8069bb24598
a21df5b8041c4094871ff8069bb24598--a92db5de5505491788a9759cd4bdd33a
997a3a415e9047beb9dd2efab2d6c993
41626f9f5a654ea684bdfe75528bcf52
RX(3.0*phi)
99878b3d90f845498a22ba41076630bb--41626f9f5a654ea684bdfe75528bcf52
1e7ff8629e804566ab417dcd7c5e487d
3
534b5d247b13416a9b50e9b6bab24d1b
RX(theta₂)
41626f9f5a654ea684bdfe75528bcf52--534b5d247b13416a9b50e9b6bab24d1b
da69f13c3ac441dfa2848484cb1372ed
RY(theta₆)
534b5d247b13416a9b50e9b6bab24d1b--da69f13c3ac441dfa2848484cb1372ed
de5abb9670ea4b11b2bc150365563553
RX(theta₁₀)
da69f13c3ac441dfa2848484cb1372ed--de5abb9670ea4b11b2bc150365563553
c773aa6528f74ddb86da86291dd43ff9
de5abb9670ea4b11b2bc150365563553--c773aa6528f74ddb86da86291dd43ff9
124bc4abbcc24310ba49ede6d8176c29
X
c773aa6528f74ddb86da86291dd43ff9--124bc4abbcc24310ba49ede6d8176c29
124bc4abbcc24310ba49ede6d8176c29--3c26fb2df9874bbfb8d65dfe107b7814
71346d5fbfad459fa2edb47d5f3794a9
RX(theta₁₄)
124bc4abbcc24310ba49ede6d8176c29--71346d5fbfad459fa2edb47d5f3794a9
73b92d905ba045b48e5013b3039e00df
RY(theta₁₈)
71346d5fbfad459fa2edb47d5f3794a9--73b92d905ba045b48e5013b3039e00df
b7bf27d0c93c4228beccc55caab07469
RX(theta₂₂)
73b92d905ba045b48e5013b3039e00df--b7bf27d0c93c4228beccc55caab07469
58f9f927b55544c2adf821f788ad377c
b7bf27d0c93c4228beccc55caab07469--58f9f927b55544c2adf821f788ad377c
4470388f18d74dee9ed1427ae3949092
X
58f9f927b55544c2adf821f788ad377c--4470388f18d74dee9ed1427ae3949092
4470388f18d74dee9ed1427ae3949092--a21df5b8041c4094871ff8069bb24598
4470388f18d74dee9ed1427ae3949092--997a3a415e9047beb9dd2efab2d6c993
776d3316d64d48d9bc17361b8494b71c
92513079b1584e1fb5008340d3065a0e
RX(4.0*phi)
1e7ff8629e804566ab417dcd7c5e487d--92513079b1584e1fb5008340d3065a0e
84fa4a1b07ec418fa183108ba106fda6
RX(theta₃)
92513079b1584e1fb5008340d3065a0e--84fa4a1b07ec418fa183108ba106fda6
a5fb3f9da94e4803aec311b7ec4f9e46
RY(theta₇)
84fa4a1b07ec418fa183108ba106fda6--a5fb3f9da94e4803aec311b7ec4f9e46
d98d97c9ad4d43719f54fe636f3975cc
RX(theta₁₁)
a5fb3f9da94e4803aec311b7ec4f9e46--d98d97c9ad4d43719f54fe636f3975cc
41ba6b4a0f5c44f78ba5839abdd6c5f1
X
d98d97c9ad4d43719f54fe636f3975cc--41ba6b4a0f5c44f78ba5839abdd6c5f1
41ba6b4a0f5c44f78ba5839abdd6c5f1--c773aa6528f74ddb86da86291dd43ff9
047482d14d2e4f13a835c9fa3ed9d747
41ba6b4a0f5c44f78ba5839abdd6c5f1--047482d14d2e4f13a835c9fa3ed9d747
bf7ff92da00f4424958a893c60a6e323
RX(theta₁₅)
047482d14d2e4f13a835c9fa3ed9d747--bf7ff92da00f4424958a893c60a6e323
ba8725008b6b49dfab65b47507f8597b
RY(theta₁₉)
bf7ff92da00f4424958a893c60a6e323--ba8725008b6b49dfab65b47507f8597b
b1c602a0daf942d5b3923021e94aff62
RX(theta₂₃)
ba8725008b6b49dfab65b47507f8597b--b1c602a0daf942d5b3923021e94aff62
0f127175929f42f783480a4e6b36ec23
X
b1c602a0daf942d5b3923021e94aff62--0f127175929f42f783480a4e6b36ec23
0f127175929f42f783480a4e6b36ec23--58f9f927b55544c2adf821f788ad377c
e31968a441e44c80ba6973ed65bc6388
0f127175929f42f783480a4e6b36ec23--e31968a441e44c80ba6973ed65bc6388
e31968a441e44c80ba6973ed65bc6388--776d3316d64d48d9bc17361b8494b71c
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_bdf835e503c944ab9903056f7edef161
Obs.
cluster_f8545b41173c478a9131e9e0149c11dd
cluster_4613c4e5e4c24b65b31ad87d2e95f655
HEA
9d3a18a0b8e84f72a918a907f71951f2
0
b166c6f0319f400ebaeff94e856f1bd1
RX(theta₀)
9d3a18a0b8e84f72a918a907f71951f2--b166c6f0319f400ebaeff94e856f1bd1
e807aafea8de456ebc5efc1461330596
1
64f8127dd77a4d41b89cfca0b61c3194
RY(theta₃)
b166c6f0319f400ebaeff94e856f1bd1--64f8127dd77a4d41b89cfca0b61c3194
381b57c03555445d974ffb661e721413
RX(theta₆)
64f8127dd77a4d41b89cfca0b61c3194--381b57c03555445d974ffb661e721413
945e8bc990a247a383a3519ffc171160
381b57c03555445d974ffb661e721413--945e8bc990a247a383a3519ffc171160
f8f6c13ffcd94b92ae6bc64b30509cf7
945e8bc990a247a383a3519ffc171160--f8f6c13ffcd94b92ae6bc64b30509cf7
2ef1c32d699d47ec98c37c3c780cc8af
RX(theta₉)
f8f6c13ffcd94b92ae6bc64b30509cf7--2ef1c32d699d47ec98c37c3c780cc8af
6b40b334a3274d1cbfd270de4a8c185b
RY(theta₁₂)
2ef1c32d699d47ec98c37c3c780cc8af--6b40b334a3274d1cbfd270de4a8c185b
1ca728341951466698740b747a04a979
RX(theta₁₅)
6b40b334a3274d1cbfd270de4a8c185b--1ca728341951466698740b747a04a979
8ac4ecbe60cd463094c28aca19c6dc12
1ca728341951466698740b747a04a979--8ac4ecbe60cd463094c28aca19c6dc12
b01fed85ce2645e6b2f5521c2be978f1
8ac4ecbe60cd463094c28aca19c6dc12--b01fed85ce2645e6b2f5521c2be978f1
0b94343bd7374752b67f463223d62357
b01fed85ce2645e6b2f5521c2be978f1--0b94343bd7374752b67f463223d62357
8dea2114846e4b5c8da35ce060742a2c
0b94343bd7374752b67f463223d62357--8dea2114846e4b5c8da35ce060742a2c
e4b39a9d647542b79124c2847054b081
fb7bc6a460e44fe292c7e9b7e04446a3
RX(theta₁)
e807aafea8de456ebc5efc1461330596--fb7bc6a460e44fe292c7e9b7e04446a3
25796e12d34041a292af5fd71d0e1c18
2
a2da9cffa17b46819b89eed82908cb1d
RY(theta₄)
fb7bc6a460e44fe292c7e9b7e04446a3--a2da9cffa17b46819b89eed82908cb1d
5ae037dce4674878ace72d2df73904db
RX(theta₇)
a2da9cffa17b46819b89eed82908cb1d--5ae037dce4674878ace72d2df73904db
40ae28ee45fe4980bd6870a0cf3467c2
X
5ae037dce4674878ace72d2df73904db--40ae28ee45fe4980bd6870a0cf3467c2
40ae28ee45fe4980bd6870a0cf3467c2--945e8bc990a247a383a3519ffc171160
e1ac7033903e431c89c33688f0ae859f
40ae28ee45fe4980bd6870a0cf3467c2--e1ac7033903e431c89c33688f0ae859f
4ee26b1eef41460ebd705a4b88b7e4fe
RX(theta₁₀)
e1ac7033903e431c89c33688f0ae859f--4ee26b1eef41460ebd705a4b88b7e4fe
11006ddecdff4f5684e052490539c2b7
RY(theta₁₃)
4ee26b1eef41460ebd705a4b88b7e4fe--11006ddecdff4f5684e052490539c2b7
63e9faa7bc844e66a01792bbb5cb8b19
RX(theta₁₆)
11006ddecdff4f5684e052490539c2b7--63e9faa7bc844e66a01792bbb5cb8b19
2dfcb4b450e7420b8a2f626a1aed18d1
X
63e9faa7bc844e66a01792bbb5cb8b19--2dfcb4b450e7420b8a2f626a1aed18d1
2dfcb4b450e7420b8a2f626a1aed18d1--8ac4ecbe60cd463094c28aca19c6dc12
a450c2ecabd1478582572c97d21bdaaf
2dfcb4b450e7420b8a2f626a1aed18d1--a450c2ecabd1478582572c97d21bdaaf
a939d3d3225846de9d909cf29c3b8735
AddBlock
a450c2ecabd1478582572c97d21bdaaf--a939d3d3225846de9d909cf29c3b8735
a939d3d3225846de9d909cf29c3b8735--e4b39a9d647542b79124c2847054b081
f6e0712749b54960b6cdf684da924889
6b86c7ad3b944e728d755a1a22ce181e
RX(theta₂)
25796e12d34041a292af5fd71d0e1c18--6b86c7ad3b944e728d755a1a22ce181e
1f20aa4a82ba4d639e77639bbdc5bb77
RY(theta₅)
6b86c7ad3b944e728d755a1a22ce181e--1f20aa4a82ba4d639e77639bbdc5bb77
142a65f470b749df88eb70c0f836ad76
RX(theta₈)
1f20aa4a82ba4d639e77639bbdc5bb77--142a65f470b749df88eb70c0f836ad76
98144da06fda4268ab7ceab1b4cd92f2
142a65f470b749df88eb70c0f836ad76--98144da06fda4268ab7ceab1b4cd92f2
7d40f5324d0d47b38e584cbb23d0c212
X
98144da06fda4268ab7ceab1b4cd92f2--7d40f5324d0d47b38e584cbb23d0c212
7d40f5324d0d47b38e584cbb23d0c212--e1ac7033903e431c89c33688f0ae859f
61eb8db4591f44bab696d8a11f0f06b2
RX(theta₁₁)
7d40f5324d0d47b38e584cbb23d0c212--61eb8db4591f44bab696d8a11f0f06b2
96470d5889984755aedaf1c8de1db5b6
RY(theta₁₄)
61eb8db4591f44bab696d8a11f0f06b2--96470d5889984755aedaf1c8de1db5b6
52ca29c665b24aea906d6e58fb1a0a10
RX(theta₁₇)
96470d5889984755aedaf1c8de1db5b6--52ca29c665b24aea906d6e58fb1a0a10
7ebf1116626f4567afb229047f43dc1a
52ca29c665b24aea906d6e58fb1a0a10--7ebf1116626f4567afb229047f43dc1a
6566e1dfa6bd4fc5bf311a266f669966
X
7ebf1116626f4567afb229047f43dc1a--6566e1dfa6bd4fc5bf311a266f669966
6566e1dfa6bd4fc5bf311a266f669966--a450c2ecabd1478582572c97d21bdaaf
a10c3a9ca6424ed6a17e6e35ab54eddb
6566e1dfa6bd4fc5bf311a266f669966--a10c3a9ca6424ed6a17e6e35ab54eddb
a10c3a9ca6424ed6a17e6e35ab54eddb--f6e0712749b54960b6cdf684da924889
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
b1939ffe3f2f43a7a35897e58fa77f74
0
d3e69855d06e4cd18e35fd287d5c918e
b1939ffe3f2f43a7a35897e58fa77f74--d3e69855d06e4cd18e35fd287d5c918e
fa03cfe59c4446f082891a0ad1e1fb70
1
d402a4a7505347818ecdbe80b0151b37
952bfbb568884a9ebe33aae6a6f5b5f6
d3e69855d06e4cd18e35fd287d5c918e--952bfbb568884a9ebe33aae6a6f5b5f6
ffd01ea0ea08459a93c7f4c59757d52d
d402a4a7505347818ecdbe80b0151b37--ffd01ea0ea08459a93c7f4c59757d52d
66bf8a0f9b7c4ad0af03790e769dba57
6533af14a5414d258bf0cb3985505cbf
ffd01ea0ea08459a93c7f4c59757d52d--6533af14a5414d258bf0cb3985505cbf
84122d87128e4d6096e580b1cb78464e
66bf8a0f9b7c4ad0af03790e769dba57--84122d87128e4d6096e580b1cb78464e
a461aa000075461d9fc34230c10583c3
4f7206e260b54ad7ad9e2f8a4e95cc15
fa03cfe59c4446f082891a0ad1e1fb70--4f7206e260b54ad7ad9e2f8a4e95cc15
39ec51a439884c829b3f56c56c69df02
2
4f7206e260b54ad7ad9e2f8a4e95cc15--d402a4a7505347818ecdbe80b0151b37
1e1783a2a3984a2b8f76132c8b9eea53
952bfbb568884a9ebe33aae6a6f5b5f6--1e1783a2a3984a2b8f76132c8b9eea53
387765e4949647d389b5c2d0aa451e82
1e1783a2a3984a2b8f76132c8b9eea53--387765e4949647d389b5c2d0aa451e82
387765e4949647d389b5c2d0aa451e82--a461aa000075461d9fc34230c10583c3
26c40da5c3334150bb51ae480656c082
559fa400e5dd4e218d0e6cdd6c4e8f13
39ec51a439884c829b3f56c56c69df02--559fa400e5dd4e218d0e6cdd6c4e8f13
2951f71204c94e098ead265f806efe01
3
0be503b9c64a4377a7140d9c19285ffe
559fa400e5dd4e218d0e6cdd6c4e8f13--0be503b9c64a4377a7140d9c19285ffe
001f9ef58be74ccdbbb043c97fe7c4bb
0be503b9c64a4377a7140d9c19285ffe--001f9ef58be74ccdbbb043c97fe7c4bb
5463240515d54cb8bf44e61e8bb16e2b
001f9ef58be74ccdbbb043c97fe7c4bb--5463240515d54cb8bf44e61e8bb16e2b
5463240515d54cb8bf44e61e8bb16e2b--26c40da5c3334150bb51ae480656c082
19f9aa147d644973aa627be78650174c
9ef0ce15d42243a6abae2c51ba76fe04
2951f71204c94e098ead265f806efe01--9ef0ce15d42243a6abae2c51ba76fe04
7f6789ca3de04b5681cea79a6df14997
9ef0ce15d42243a6abae2c51ba76fe04--7f6789ca3de04b5681cea79a6df14997
a8be4470a4094563838dd29fd07700fc
7f6789ca3de04b5681cea79a6df14997--a8be4470a4094563838dd29fd07700fc
a8be4470a4094563838dd29fd07700fc--66bf8a0f9b7c4ad0af03790e769dba57
6533af14a5414d258bf0cb3985505cbf--19f9aa147d644973aa627be78650174c
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
747b17655c554d928b6b62755945b3db
0
85a93937e5e34d0cb3de207998a8379f
747b17655c554d928b6b62755945b3db--85a93937e5e34d0cb3de207998a8379f
187c8eb241304c67b3b10c0d1a1369c3
1
3704ab5649e747efa9252cecef852d62
85a93937e5e34d0cb3de207998a8379f--3704ab5649e747efa9252cecef852d62
45cc448ab4e64d4d90a8df24c7438adf
3704ab5649e747efa9252cecef852d62--45cc448ab4e64d4d90a8df24c7438adf
a7da37e0249b4c0d82f07711eda76782
45cc448ab4e64d4d90a8df24c7438adf--a7da37e0249b4c0d82f07711eda76782
fb8e451f3d9e4a13a1c7bcd318d44eae
580d87d6f58943d383975121d3c2dec0
PHASE(0.5)
187c8eb241304c67b3b10c0d1a1369c3--580d87d6f58943d383975121d3c2dec0
cb108741e0934ab88d682bef0a56bdd9
2
580d87d6f58943d383975121d3c2dec0--85a93937e5e34d0cb3de207998a8379f
6cd4ffcb6f3c428cb4963684e6d9b9fb
580d87d6f58943d383975121d3c2dec0--6cd4ffcb6f3c428cb4963684e6d9b9fb
c5b48f6982154539a3b2ef9495a7afdb
6cd4ffcb6f3c428cb4963684e6d9b9fb--c5b48f6982154539a3b2ef9495a7afdb
c5b48f6982154539a3b2ef9495a7afdb--fb8e451f3d9e4a13a1c7bcd318d44eae
1c7a0d77e7804c6b8aaaf06ec7c59464
5adaa680dad640b9b6ead080b172261e
cb108741e0934ab88d682bef0a56bdd9--5adaa680dad640b9b6ead080b172261e
590adeb5031e44f896f3fad1f033fbdd
3
d613eaa8f1ba4c189b87cf77848a9d8f
PHASE(0.5)
5adaa680dad640b9b6ead080b172261e--d613eaa8f1ba4c189b87cf77848a9d8f
d613eaa8f1ba4c189b87cf77848a9d8f--3704ab5649e747efa9252cecef852d62
cd1c053cb6ea4561aefa8cc13beecd2c
d613eaa8f1ba4c189b87cf77848a9d8f--cd1c053cb6ea4561aefa8cc13beecd2c
cd1c053cb6ea4561aefa8cc13beecd2c--1c7a0d77e7804c6b8aaaf06ec7c59464
9e9cdad862664960a8d1980179ac0eec
e9a39e0ebe1f483caa054fe953ac1195
590adeb5031e44f896f3fad1f033fbdd--e9a39e0ebe1f483caa054fe953ac1195
f437533bdc8a4f7c9e3a75297a60d8d2
e9a39e0ebe1f483caa054fe953ac1195--f437533bdc8a4f7c9e3a75297a60d8d2
d66fdc40ed1946c5be46c368b80df519
PHASE(0.5)
f437533bdc8a4f7c9e3a75297a60d8d2--d66fdc40ed1946c5be46c368b80df519
d66fdc40ed1946c5be46c368b80df519--45cc448ab4e64d4d90a8df24c7438adf
d66fdc40ed1946c5be46c368b80df519--9e9cdad862664960a8d1980179ac0eec
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