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
3b99d5bb496f494fbe0c03dc67538a17
0
62f4b403f1ce41e19cc683e66fab4fa2
X
3b99d5bb496f494fbe0c03dc67538a17--62f4b403f1ce41e19cc683e66fab4fa2
825f5cc9a28b4cb7b89a0ef9393d641a
1
e8fb68923fb145d5b67e7e0c094c4afb
62f4b403f1ce41e19cc683e66fab4fa2--e8fb68923fb145d5b67e7e0c094c4afb
28ff8b8fb5ac4c5b8ff7a6bd66fae014
46743cbac2a74eaea1ec7d298961d0b0
Y
825f5cc9a28b4cb7b89a0ef9393d641a--46743cbac2a74eaea1ec7d298961d0b0
46743cbac2a74eaea1ec7d298961d0b0--28ff8b8fb5ac4c5b8ff7a6bd66fae014
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
660d78c6434b4981b1b74ec50c673ce1
0
501c2de0efd748b2b15dd3a3f6c78614
X
660d78c6434b4981b1b74ec50c673ce1--501c2de0efd748b2b15dd3a3f6c78614
e8769d36930041359ea6ee5464ed962f
Y
501c2de0efd748b2b15dd3a3f6c78614--e8769d36930041359ea6ee5464ed962f
878b32f0e4184702bf810bb3b9ab2616
e8769d36930041359ea6ee5464ed962f--878b32f0e4184702bf810bb3b9ab2616
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
0634902b06144213bba85f9e28482a62
0
f5bd1724721447908490335b0f786898
X
0634902b06144213bba85f9e28482a62--f5bd1724721447908490335b0f786898
f4899a4bfcb540569a6bef639f4fa9e4
1
05706332c5be45dc9ec10914edb2abca
f5bd1724721447908490335b0f786898--05706332c5be45dc9ec10914edb2abca
0c77305aa1ee4804948e7e6bad619bed
05706332c5be45dc9ec10914edb2abca--0c77305aa1ee4804948e7e6bad619bed
30b44a87546e4e948e0420b340c14340
79915caf9d3544c99ef8757bf86ecaab
f4899a4bfcb540569a6bef639f4fa9e4--79915caf9d3544c99ef8757bf86ecaab
60309d966494462d9287790c1acb187c
Y
79915caf9d3544c99ef8757bf86ecaab--60309d966494462d9287790c1acb187c
60309d966494462d9287790c1acb187c--30b44a87546e4e948e0420b340c14340
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_0ad8ed58264e49cc969ce25665ee4a90
4308b51f79f54e26bc5615093cb4f91c
0
894211c1f0da488f82cc5e934639a1ed
4308b51f79f54e26bc5615093cb4f91c--894211c1f0da488f82cc5e934639a1ed
0fc189e21e7a40d89c019b2b345a0efb
1
f9469f9104cf4ecaa0eb65a3c8109eee
894211c1f0da488f82cc5e934639a1ed--f9469f9104cf4ecaa0eb65a3c8109eee
b3cd570a2c434a5cb2671557a1a4282e
d48d8196ab9c426ba6c7a26754c2f2ec
AddBlock
0fc189e21e7a40d89c019b2b345a0efb--d48d8196ab9c426ba6c7a26754c2f2ec
abe96aa9ec4c488f82ed24798c64d9fa
2
d48d8196ab9c426ba6c7a26754c2f2ec--b3cd570a2c434a5cb2671557a1a4282e
e7e92ce8098b4de6872d8a1ed3311bcf
0f175c3233354d829aca1c571dfc8ced
abe96aa9ec4c488f82ed24798c64d9fa--0f175c3233354d829aca1c571dfc8ced
0f175c3233354d829aca1c571dfc8ced--e7e92ce8098b4de6872d8a1ed3311bcf
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_b988e3a8bacf497eb35e39688a140640
cluster_0a8cb6d12705435482384d5426e218fb
rx
9097a59d51064ab4ad073ae00ea933cf
0
5fbbfcc7e8134ad78ee7f2d712bc9d93
X
9097a59d51064ab4ad073ae00ea933cf--5fbbfcc7e8134ad78ee7f2d712bc9d93
90d3b832282141beab0139b8dd05e5f2
1
0b87c7d799114960aecee9934e61ee91
5fbbfcc7e8134ad78ee7f2d712bc9d93--0b87c7d799114960aecee9934e61ee91
efb7427192a7420eb65958a500aef9f7
0b87c7d799114960aecee9934e61ee91--efb7427192a7420eb65958a500aef9f7
92fec464deda4d78914e2b76d282aab1
efb7427192a7420eb65958a500aef9f7--92fec464deda4d78914e2b76d282aab1
ed4f214bcde34130b7b0ea29833adfb8
7d5cc1d9b9cc46f4862525ee58e15dcc
Y
90d3b832282141beab0139b8dd05e5f2--7d5cc1d9b9cc46f4862525ee58e15dcc
8706fe6c31e14437b48a0aa387c63312
2
fbd8c8645c194f848acb15acd4796f17
7d5cc1d9b9cc46f4862525ee58e15dcc--fbd8c8645c194f848acb15acd4796f17
cc9011415c634967a514c033031aff6f
HamEvo
fbd8c8645c194f848acb15acd4796f17--cc9011415c634967a514c033031aff6f
cc9011415c634967a514c033031aff6f--ed4f214bcde34130b7b0ea29833adfb8
28522b77535744bdbd38b578ca9db5c6
7e4ece5bf66b4ad2bfab77e29d7a5a91
RX(x)
8706fe6c31e14437b48a0aa387c63312--7e4ece5bf66b4ad2bfab77e29d7a5a91
adbbbb648c9d458f96c1391dd9efbb23
3
f27102dc7cd84a839922304de4bcd9c2
7e4ece5bf66b4ad2bfab77e29d7a5a91--f27102dc7cd84a839922304de4bcd9c2
e6d861aecb1c4e0eaaac636300b000dc
t = 10
f27102dc7cd84a839922304de4bcd9c2--e6d861aecb1c4e0eaaac636300b000dc
e6d861aecb1c4e0eaaac636300b000dc--28522b77535744bdbd38b578ca9db5c6
4faedbd963c142fe93907bfd8aeebceb
b9f3704e3aa945688d97ddef06f0146b
RX(0.5)
adbbbb648c9d458f96c1391dd9efbb23--b9f3704e3aa945688d97ddef06f0146b
82b7d30661fc44e3b1a0a1e30ebddcd3
X
b9f3704e3aa945688d97ddef06f0146b--82b7d30661fc44e3b1a0a1e30ebddcd3
82b7d30661fc44e3b1a0a1e30ebddcd3--f27102dc7cd84a839922304de4bcd9c2
82d190d21d554319a91ab28aadbe642a
82b7d30661fc44e3b1a0a1e30ebddcd3--82d190d21d554319a91ab28aadbe642a
82d190d21d554319a91ab28aadbe642a--4faedbd963c142fe93907bfd8aeebceb
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_58456e9c90e447538956065dcd0a8e45
HEA
cluster_abe5f915a95a45b1b4dddd80a3c130ce
Tower Fourier FM
f14ae98fff4f42238bd55b41ba3901fa
0
f4b42bf9d13d4f21adb526f6c45346ac
RX(1.0*phi)
f14ae98fff4f42238bd55b41ba3901fa--f4b42bf9d13d4f21adb526f6c45346ac
71707fec2ddf4896b3f8bd98d8429d63
1
9ccf680cd6e74532b5188ee42c2a5c55
RX(theta₀)
f4b42bf9d13d4f21adb526f6c45346ac--9ccf680cd6e74532b5188ee42c2a5c55
f650cad047534e548a6020235bc1e7c5
RY(theta₄)
9ccf680cd6e74532b5188ee42c2a5c55--f650cad047534e548a6020235bc1e7c5
138259b037c24a7d9f274469416d1335
RX(theta₈)
f650cad047534e548a6020235bc1e7c5--138259b037c24a7d9f274469416d1335
4d03bb6ac9834513aedf9b8a690b6ece
138259b037c24a7d9f274469416d1335--4d03bb6ac9834513aedf9b8a690b6ece
a1aa6462cfe44e65866b1e29db1cd028
4d03bb6ac9834513aedf9b8a690b6ece--a1aa6462cfe44e65866b1e29db1cd028
04ccca67a1ad4538b858c027942e8453
RX(theta₁₂)
a1aa6462cfe44e65866b1e29db1cd028--04ccca67a1ad4538b858c027942e8453
aad1161e4b2e4901979ee6be12710eed
RY(theta₁₆)
04ccca67a1ad4538b858c027942e8453--aad1161e4b2e4901979ee6be12710eed
5f6340eb67644d839ba8b5637dd72be9
RX(theta₂₀)
aad1161e4b2e4901979ee6be12710eed--5f6340eb67644d839ba8b5637dd72be9
53ecff364f024a1dbf69860e966bb14c
5f6340eb67644d839ba8b5637dd72be9--53ecff364f024a1dbf69860e966bb14c
b8d804be5d974e169373377b4fcb20d1
53ecff364f024a1dbf69860e966bb14c--b8d804be5d974e169373377b4fcb20d1
2919a80bcdbc4052ae29e2031bbd8ac7
b8d804be5d974e169373377b4fcb20d1--2919a80bcdbc4052ae29e2031bbd8ac7
6b21854931124a08b7781f75fdecd877
c171cc644c47427681743581e8e5e941
RX(2.0*phi)
71707fec2ddf4896b3f8bd98d8429d63--c171cc644c47427681743581e8e5e941
eb0eadf5deb043ba88222633d7f4779f
2
85a964f18d6349ad97352ddd5d2051e5
RX(theta₁)
c171cc644c47427681743581e8e5e941--85a964f18d6349ad97352ddd5d2051e5
fc30c04ebf8640f8a93c58d7891e5863
RY(theta₅)
85a964f18d6349ad97352ddd5d2051e5--fc30c04ebf8640f8a93c58d7891e5863
2a508359b6c846e8ae5eb4dc8c0ce3d7
RX(theta₉)
fc30c04ebf8640f8a93c58d7891e5863--2a508359b6c846e8ae5eb4dc8c0ce3d7
4086000f67024bde85bc7d80848db3d5
X
2a508359b6c846e8ae5eb4dc8c0ce3d7--4086000f67024bde85bc7d80848db3d5
4086000f67024bde85bc7d80848db3d5--4d03bb6ac9834513aedf9b8a690b6ece
65d9687b57d2450387331d57218ea23d
4086000f67024bde85bc7d80848db3d5--65d9687b57d2450387331d57218ea23d
52301731906e4671b0fe2dc01b903587
RX(theta₁₃)
65d9687b57d2450387331d57218ea23d--52301731906e4671b0fe2dc01b903587
0dc7f6f76578499085bfe71f250fefc6
RY(theta₁₇)
52301731906e4671b0fe2dc01b903587--0dc7f6f76578499085bfe71f250fefc6
76637c65372f4a3aae038fccd3e34b28
RX(theta₂₁)
0dc7f6f76578499085bfe71f250fefc6--76637c65372f4a3aae038fccd3e34b28
11a98434e9d2447799873ce47c013009
X
76637c65372f4a3aae038fccd3e34b28--11a98434e9d2447799873ce47c013009
11a98434e9d2447799873ce47c013009--53ecff364f024a1dbf69860e966bb14c
18a23c982ece4ee6921652e72df9c5e1
11a98434e9d2447799873ce47c013009--18a23c982ece4ee6921652e72df9c5e1
18a23c982ece4ee6921652e72df9c5e1--6b21854931124a08b7781f75fdecd877
0eb86c02b5cc49619d341c47f73db444
c414450a41b24bb5b3e22f205e28d26d
RX(3.0*phi)
eb0eadf5deb043ba88222633d7f4779f--c414450a41b24bb5b3e22f205e28d26d
47f88c12efca419b9fdcd4e1eb024bd9
3
3a0ddc802d2e46fd94eeeda60584698c
RX(theta₂)
c414450a41b24bb5b3e22f205e28d26d--3a0ddc802d2e46fd94eeeda60584698c
6759fc6b28fd4ada83d938ec8a102477
RY(theta₆)
3a0ddc802d2e46fd94eeeda60584698c--6759fc6b28fd4ada83d938ec8a102477
712f8d2327234be38847dc20c772ae04
RX(theta₁₀)
6759fc6b28fd4ada83d938ec8a102477--712f8d2327234be38847dc20c772ae04
d9f62d15c6164143ac70f31279c0902d
712f8d2327234be38847dc20c772ae04--d9f62d15c6164143ac70f31279c0902d
c3c010755267486f85cd707854dc6def
X
d9f62d15c6164143ac70f31279c0902d--c3c010755267486f85cd707854dc6def
c3c010755267486f85cd707854dc6def--65d9687b57d2450387331d57218ea23d
e24a3fa895ca45a1a28cb3f1f9ae1cdc
RX(theta₁₄)
c3c010755267486f85cd707854dc6def--e24a3fa895ca45a1a28cb3f1f9ae1cdc
410e1a7a016944b98321c08a9bae2b4d
RY(theta₁₈)
e24a3fa895ca45a1a28cb3f1f9ae1cdc--410e1a7a016944b98321c08a9bae2b4d
560b15cd40704a16975085cc986a0bce
RX(theta₂₂)
410e1a7a016944b98321c08a9bae2b4d--560b15cd40704a16975085cc986a0bce
c3e7d331293249a5b07c03fa8dbb29a4
560b15cd40704a16975085cc986a0bce--c3e7d331293249a5b07c03fa8dbb29a4
936bc6c04d0e4a1a9c1a622f41ee5c60
X
c3e7d331293249a5b07c03fa8dbb29a4--936bc6c04d0e4a1a9c1a622f41ee5c60
936bc6c04d0e4a1a9c1a622f41ee5c60--18a23c982ece4ee6921652e72df9c5e1
936bc6c04d0e4a1a9c1a622f41ee5c60--0eb86c02b5cc49619d341c47f73db444
984c4e829fb8490690d2c6c041a58026
a041af93d17f41c99fca2231581efe93
RX(4.0*phi)
47f88c12efca419b9fdcd4e1eb024bd9--a041af93d17f41c99fca2231581efe93
7261789466534fd1a8de9323c3f95296
RX(theta₃)
a041af93d17f41c99fca2231581efe93--7261789466534fd1a8de9323c3f95296
f7e87bc836764edf9c27e00e9994bf92
RY(theta₇)
7261789466534fd1a8de9323c3f95296--f7e87bc836764edf9c27e00e9994bf92
68367b776ca44cf395c7f2be67c08cb8
RX(theta₁₁)
f7e87bc836764edf9c27e00e9994bf92--68367b776ca44cf395c7f2be67c08cb8
dffdfcd459c845f08537b292246120e8
X
68367b776ca44cf395c7f2be67c08cb8--dffdfcd459c845f08537b292246120e8
dffdfcd459c845f08537b292246120e8--d9f62d15c6164143ac70f31279c0902d
bdcc8c6f0f2b4fd9aef9abe29437279c
dffdfcd459c845f08537b292246120e8--bdcc8c6f0f2b4fd9aef9abe29437279c
7845005f5eb44fbd855adfc5f4620f82
RX(theta₁₅)
bdcc8c6f0f2b4fd9aef9abe29437279c--7845005f5eb44fbd855adfc5f4620f82
1a5771dadba74e7e9820f292b149be41
RY(theta₁₉)
7845005f5eb44fbd855adfc5f4620f82--1a5771dadba74e7e9820f292b149be41
f202ac2c5a61435c8d7cc1045aef1704
RX(theta₂₃)
1a5771dadba74e7e9820f292b149be41--f202ac2c5a61435c8d7cc1045aef1704
19ef56816378443aa564d10a228fdd84
X
f202ac2c5a61435c8d7cc1045aef1704--19ef56816378443aa564d10a228fdd84
19ef56816378443aa564d10a228fdd84--c3e7d331293249a5b07c03fa8dbb29a4
799e7d0121a54e688efbb5438ce3dc71
19ef56816378443aa564d10a228fdd84--799e7d0121a54e688efbb5438ce3dc71
799e7d0121a54e688efbb5438ce3dc71--984c4e829fb8490690d2c6c041a58026
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_316eea9b1df64b9198252535fcb4056f
Obs.
cluster_4e56628f0922485ab2f41dae3e07da00
cluster_cbbdf9aad3b44fd7b715da325a30b898
HEA
7d88a10fc4314cc5bfcb7419ff34c8d5
0
e098c47c5ce346d1b7a9d21fc263b2bf
RX(theta₀)
7d88a10fc4314cc5bfcb7419ff34c8d5--e098c47c5ce346d1b7a9d21fc263b2bf
2ad75e0e18fc4fbb95740c61d415fe4c
1
cff58c16eaa44559ba469e32f9090ae6
RY(theta₃)
e098c47c5ce346d1b7a9d21fc263b2bf--cff58c16eaa44559ba469e32f9090ae6
35d728a24a3944be829e81edab3ed724
RX(theta₆)
cff58c16eaa44559ba469e32f9090ae6--35d728a24a3944be829e81edab3ed724
9b70b7bc8b674c2484d46efaf1494254
35d728a24a3944be829e81edab3ed724--9b70b7bc8b674c2484d46efaf1494254
37fc044b47ac440987d49301db0f697d
9b70b7bc8b674c2484d46efaf1494254--37fc044b47ac440987d49301db0f697d
541fa4b47d49462d9e937ecd70d7739b
RX(theta₉)
37fc044b47ac440987d49301db0f697d--541fa4b47d49462d9e937ecd70d7739b
d037865f1fdf45a88410c6b6b34ac23c
RY(theta₁₂)
541fa4b47d49462d9e937ecd70d7739b--d037865f1fdf45a88410c6b6b34ac23c
3d5318a814794e1a9f21a5bdd9950a75
RX(theta₁₅)
d037865f1fdf45a88410c6b6b34ac23c--3d5318a814794e1a9f21a5bdd9950a75
c1d6bd8d9dfc4479912bd9380e8505ee
3d5318a814794e1a9f21a5bdd9950a75--c1d6bd8d9dfc4479912bd9380e8505ee
154419cce8f1467c897da6faed03a565
c1d6bd8d9dfc4479912bd9380e8505ee--154419cce8f1467c897da6faed03a565
2f3d1f893d324ea4818be592f40f4e9f
154419cce8f1467c897da6faed03a565--2f3d1f893d324ea4818be592f40f4e9f
9e7d502399cf4ca99fc80f3fbfa27c48
2f3d1f893d324ea4818be592f40f4e9f--9e7d502399cf4ca99fc80f3fbfa27c48
a1efe14892a74936a8ea211d79773292
f00e7c69af74474a8dab91b3551cbf5b
RX(theta₁)
2ad75e0e18fc4fbb95740c61d415fe4c--f00e7c69af74474a8dab91b3551cbf5b
6a77fb3618cf4aeb8a974e9063b0159d
2
96733f12db924ea092a88dcb6d76933f
RY(theta₄)
f00e7c69af74474a8dab91b3551cbf5b--96733f12db924ea092a88dcb6d76933f
40877626729c4ce896d1cbb38cb6019d
RX(theta₇)
96733f12db924ea092a88dcb6d76933f--40877626729c4ce896d1cbb38cb6019d
78da8e4bb5fc48d8b73a31d5bbb63cf5
X
40877626729c4ce896d1cbb38cb6019d--78da8e4bb5fc48d8b73a31d5bbb63cf5
78da8e4bb5fc48d8b73a31d5bbb63cf5--9b70b7bc8b674c2484d46efaf1494254
6abb108302134e1dbae7654b3c0fe29b
78da8e4bb5fc48d8b73a31d5bbb63cf5--6abb108302134e1dbae7654b3c0fe29b
bfe21f39d9a74b1d9b8e827931b504eb
RX(theta₁₀)
6abb108302134e1dbae7654b3c0fe29b--bfe21f39d9a74b1d9b8e827931b504eb
277fb8c8eea349a8ac81801a193f70de
RY(theta₁₃)
bfe21f39d9a74b1d9b8e827931b504eb--277fb8c8eea349a8ac81801a193f70de
2a7a2e0b91ed4934968a210eddbfa32c
RX(theta₁₆)
277fb8c8eea349a8ac81801a193f70de--2a7a2e0b91ed4934968a210eddbfa32c
f302cf8de081417fa7897e8d0488dbb3
X
2a7a2e0b91ed4934968a210eddbfa32c--f302cf8de081417fa7897e8d0488dbb3
f302cf8de081417fa7897e8d0488dbb3--c1d6bd8d9dfc4479912bd9380e8505ee
658150d6c22f4f9d92da8fcc4bb010ad
f302cf8de081417fa7897e8d0488dbb3--658150d6c22f4f9d92da8fcc4bb010ad
342f9660143649fab2fee004435af6bb
AddBlock
658150d6c22f4f9d92da8fcc4bb010ad--342f9660143649fab2fee004435af6bb
342f9660143649fab2fee004435af6bb--a1efe14892a74936a8ea211d79773292
da1593e888fb4c67bb38686834d46ce7
9eca9e743d24408a8e98b9dd4ccbc2ba
RX(theta₂)
6a77fb3618cf4aeb8a974e9063b0159d--9eca9e743d24408a8e98b9dd4ccbc2ba
1cc1fa3ae3234b69a6c62715585a51ca
RY(theta₅)
9eca9e743d24408a8e98b9dd4ccbc2ba--1cc1fa3ae3234b69a6c62715585a51ca
497d12ab6783478d99772f9c3f7984b3
RX(theta₈)
1cc1fa3ae3234b69a6c62715585a51ca--497d12ab6783478d99772f9c3f7984b3
08cc7e827556488895d26a1f6069e79c
497d12ab6783478d99772f9c3f7984b3--08cc7e827556488895d26a1f6069e79c
0dce57e97cbf4691a4827dc88e3af6b7
X
08cc7e827556488895d26a1f6069e79c--0dce57e97cbf4691a4827dc88e3af6b7
0dce57e97cbf4691a4827dc88e3af6b7--6abb108302134e1dbae7654b3c0fe29b
af751f37ce8846ba8e6fd6acccec40b4
RX(theta₁₁)
0dce57e97cbf4691a4827dc88e3af6b7--af751f37ce8846ba8e6fd6acccec40b4
00b5ffde7f124597a6a9ef830f696a90
RY(theta₁₄)
af751f37ce8846ba8e6fd6acccec40b4--00b5ffde7f124597a6a9ef830f696a90
1df2ef04f5d94a59a11e9f9b7b43735d
RX(theta₁₇)
00b5ffde7f124597a6a9ef830f696a90--1df2ef04f5d94a59a11e9f9b7b43735d
42d61eb5ea0248c6a78281ef30ada266
1df2ef04f5d94a59a11e9f9b7b43735d--42d61eb5ea0248c6a78281ef30ada266
07d65132db294973b221589535377c2d
X
42d61eb5ea0248c6a78281ef30ada266--07d65132db294973b221589535377c2d
07d65132db294973b221589535377c2d--658150d6c22f4f9d92da8fcc4bb010ad
6c580e5c80e547e69186198065f6ae19
07d65132db294973b221589535377c2d--6c580e5c80e547e69186198065f6ae19
6c580e5c80e547e69186198065f6ae19--da1593e888fb4c67bb38686834d46ce7
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
14075b7e7e2049f9974b2b9ef2356d35
0
6b898b54856c4e1f96ec95227928c65a
14075b7e7e2049f9974b2b9ef2356d35--6b898b54856c4e1f96ec95227928c65a
d91699992dc045c689d0eaa100d93295
1
32e32195154049f9ad2056d2334410aa
22ee6979a3b047418a007bf8ad41891d
6b898b54856c4e1f96ec95227928c65a--22ee6979a3b047418a007bf8ad41891d
c8ddcfd3811c4282a65348c0ed0c9e22
32e32195154049f9ad2056d2334410aa--c8ddcfd3811c4282a65348c0ed0c9e22
ab759d2431c24da49ab4ccf400cf0079
4c26f47ed6d04b85a18c28d589dd1bd9
c8ddcfd3811c4282a65348c0ed0c9e22--4c26f47ed6d04b85a18c28d589dd1bd9
4505637aeac642efa63defb212aa78fb
ab759d2431c24da49ab4ccf400cf0079--4505637aeac642efa63defb212aa78fb
72ddd44d6a5a4d5191c3c116355e533b
9a99105f983c4309be93be45abca5e84
d91699992dc045c689d0eaa100d93295--9a99105f983c4309be93be45abca5e84
3ed3a306f6ea46a4a1b0d05825e18f5e
2
9a99105f983c4309be93be45abca5e84--32e32195154049f9ad2056d2334410aa
86c37196da004c379ada2309082ac9df
22ee6979a3b047418a007bf8ad41891d--86c37196da004c379ada2309082ac9df
3fa2d69d3d9b435e9697b3572cbb017b
86c37196da004c379ada2309082ac9df--3fa2d69d3d9b435e9697b3572cbb017b
3fa2d69d3d9b435e9697b3572cbb017b--72ddd44d6a5a4d5191c3c116355e533b
3fb89fbc2c7143d18040551819e6a84e
5d8548f56c0f4143aae39e48f6ad6ac6
3ed3a306f6ea46a4a1b0d05825e18f5e--5d8548f56c0f4143aae39e48f6ad6ac6
1b11ca809a1c4a55b19915692f3dbc62
3
295a753bd8bf46d3b018fad7b03d5212
5d8548f56c0f4143aae39e48f6ad6ac6--295a753bd8bf46d3b018fad7b03d5212
d5829fd6fcd64c4ebfbe1428147cba7d
295a753bd8bf46d3b018fad7b03d5212--d5829fd6fcd64c4ebfbe1428147cba7d
133eda1eb6704deb8af405c191eda9db
d5829fd6fcd64c4ebfbe1428147cba7d--133eda1eb6704deb8af405c191eda9db
133eda1eb6704deb8af405c191eda9db--3fb89fbc2c7143d18040551819e6a84e
b3a931ec30424cd7a9cbbf6e23c83716
09b07e8a88144c0da711c320879c1ab2
1b11ca809a1c4a55b19915692f3dbc62--09b07e8a88144c0da711c320879c1ab2
b4876a7f242c4e4486412157b71e138b
09b07e8a88144c0da711c320879c1ab2--b4876a7f242c4e4486412157b71e138b
0318b154f7704f24a200e09829ba08b1
b4876a7f242c4e4486412157b71e138b--0318b154f7704f24a200e09829ba08b1
0318b154f7704f24a200e09829ba08b1--ab759d2431c24da49ab4ccf400cf0079
4c26f47ed6d04b85a18c28d589dd1bd9--b3a931ec30424cd7a9cbbf6e23c83716
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
0a33d86c4f9f4427a47ac4a969f13e6a
0
166d3495efb4492bb936368e0a81b614
0a33d86c4f9f4427a47ac4a969f13e6a--166d3495efb4492bb936368e0a81b614
616cdebfa54842bea6a4d8359602df93
1
e0bba3fa98bb4ebda26708da1867193b
166d3495efb4492bb936368e0a81b614--e0bba3fa98bb4ebda26708da1867193b
70974be0f6464f20826af5e33e3ea095
e0bba3fa98bb4ebda26708da1867193b--70974be0f6464f20826af5e33e3ea095
8a695cc80f6740158b97180a83dae459
70974be0f6464f20826af5e33e3ea095--8a695cc80f6740158b97180a83dae459
d2ebeb5438af49bfbc1520e3b543c255
c62d1ba2176e42bb984080dc9ca4750c
PHASE(0.5)
616cdebfa54842bea6a4d8359602df93--c62d1ba2176e42bb984080dc9ca4750c
1705c57729bc4993bb577ff11b2e37c7
2
c62d1ba2176e42bb984080dc9ca4750c--166d3495efb4492bb936368e0a81b614
32a8360629bc4dd9939be70b7b3b1721
c62d1ba2176e42bb984080dc9ca4750c--32a8360629bc4dd9939be70b7b3b1721
c109e0df50f0431da394171bb3521888
32a8360629bc4dd9939be70b7b3b1721--c109e0df50f0431da394171bb3521888
c109e0df50f0431da394171bb3521888--d2ebeb5438af49bfbc1520e3b543c255
107639f07d674afab75b1a6a0e3c59a5
fd5e9e3ce3c44baa8c64acd235abc8e0
1705c57729bc4993bb577ff11b2e37c7--fd5e9e3ce3c44baa8c64acd235abc8e0
8577a10fc9124d8a8b91339df4a593aa
3
d217442c9957404894d87313d7317cfe
PHASE(0.5)
fd5e9e3ce3c44baa8c64acd235abc8e0--d217442c9957404894d87313d7317cfe
d217442c9957404894d87313d7317cfe--e0bba3fa98bb4ebda26708da1867193b
9a908092286a4488b7139b704be6ab2b
d217442c9957404894d87313d7317cfe--9a908092286a4488b7139b704be6ab2b
9a908092286a4488b7139b704be6ab2b--107639f07d674afab75b1a6a0e3c59a5
e7c6c3be37d2404e80a57c0b8758e385
ed85f2f6ad0a414ba625f54213b222ce
8577a10fc9124d8a8b91339df4a593aa--ed85f2f6ad0a414ba625f54213b222ce
2f0fb32a3c1942cda4256d74a9421df0
ed85f2f6ad0a414ba625f54213b222ce--2f0fb32a3c1942cda4256d74a9421df0
b7257d2158314e8ab679587b802d5352
PHASE(0.5)
2f0fb32a3c1942cda4256d74a9421df0--b7257d2158314e8ab679587b802d5352
b7257d2158314e8ab679587b802d5352--70974be0f6464f20826af5e33e3ea095
b7257d2158314e8ab679587b802d5352--e7c6c3be37d2404e80a57c0b8758e385
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