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
1d099807ee394f5083f441017892793d
0
58aa9d3ec5204e23bbd58086d0103629
X
1d099807ee394f5083f441017892793d--58aa9d3ec5204e23bbd58086d0103629
80eb5171c28044ce94be282d28971852
1
e49043b2140746eea1c3fe852c904bbf
58aa9d3ec5204e23bbd58086d0103629--e49043b2140746eea1c3fe852c904bbf
8fb4786c686e4bd6aeac7b98d3bcb33c
a4945db4fad2446683860f1abecb4dc1
Y
80eb5171c28044ce94be282d28971852--a4945db4fad2446683860f1abecb4dc1
a4945db4fad2446683860f1abecb4dc1--8fb4786c686e4bd6aeac7b98d3bcb33c
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
7225a2f5956f4b32a2c4742a6c106989
0
c7f34c9ff38d48f286b76704564ad596
X
7225a2f5956f4b32a2c4742a6c106989--c7f34c9ff38d48f286b76704564ad596
43d701f34add4529aafe8fac0348b6b4
Y
c7f34c9ff38d48f286b76704564ad596--43d701f34add4529aafe8fac0348b6b4
7bc3c2ac6c5c4120a233355fc5cb1f31
43d701f34add4529aafe8fac0348b6b4--7bc3c2ac6c5c4120a233355fc5cb1f31
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
d90b9462b0554913871e3d1730ee80bf
0
e989dc62e1f0460fbcfb3c0fdf183754
X
d90b9462b0554913871e3d1730ee80bf--e989dc62e1f0460fbcfb3c0fdf183754
054fb53b1ed44076b2512371635062b4
1
69eec04bc1b048c2b4b6df2eaa214690
e989dc62e1f0460fbcfb3c0fdf183754--69eec04bc1b048c2b4b6df2eaa214690
dc4829232de74ad8ae196710f6ace56b
69eec04bc1b048c2b4b6df2eaa214690--dc4829232de74ad8ae196710f6ace56b
33d632e61c254dea81d095c0e14a9629
fc1f4f0db45a40908320037a05b61119
054fb53b1ed44076b2512371635062b4--fc1f4f0db45a40908320037a05b61119
366c2963ec574c549f498ddcf0486b7f
Y
fc1f4f0db45a40908320037a05b61119--366c2963ec574c549f498ddcf0486b7f
366c2963ec574c549f498ddcf0486b7f--33d632e61c254dea81d095c0e14a9629
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_4d2fc99afce54601a2e74a2ed86ba1ca
7dc085f274c141568ecf1f5f1d5a4f40
0
c25c449a77594cb4a1c1a3bdc915badd
7dc085f274c141568ecf1f5f1d5a4f40--c25c449a77594cb4a1c1a3bdc915badd
2db378c0c2f34aecbabc7c000557bbdb
1
254f5d6e9061435daf52c450c91f9653
c25c449a77594cb4a1c1a3bdc915badd--254f5d6e9061435daf52c450c91f9653
0efcbbdf7a8744f7beb8c3409497fa57
99db1f368c964630a0893c1145a8fddb
AddBlock
2db378c0c2f34aecbabc7c000557bbdb--99db1f368c964630a0893c1145a8fddb
14488b673ecc40aebec488b04a8b326d
2
99db1f368c964630a0893c1145a8fddb--0efcbbdf7a8744f7beb8c3409497fa57
f1c1252e4bb1441fbeeeb869743e488a
e1f599ac5b9d4d448cea2556590e619a
14488b673ecc40aebec488b04a8b326d--e1f599ac5b9d4d448cea2556590e619a
e1f599ac5b9d4d448cea2556590e619a--f1c1252e4bb1441fbeeeb869743e488a
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_27c4101dd425471da974f3b2b3e9e318
cluster_fd164f70646444879be95288f3bec8ab
rx
655a41b9ddbe4a1a952dff52649bff75
0
2434f30f52f74c18ba7db4eeb81af880
X
655a41b9ddbe4a1a952dff52649bff75--2434f30f52f74c18ba7db4eeb81af880
acb73524c76f4e1994f9a50dc9d8da6b
1
9586dfec312541469eb7f4d8b95b3c1f
2434f30f52f74c18ba7db4eeb81af880--9586dfec312541469eb7f4d8b95b3c1f
d3d94a5773f84212938ccd573e7e5899
9586dfec312541469eb7f4d8b95b3c1f--d3d94a5773f84212938ccd573e7e5899
f43f9f2cb54f4e71aee6453c345a06c2
d3d94a5773f84212938ccd573e7e5899--f43f9f2cb54f4e71aee6453c345a06c2
675afae524004cd0a6095d13be0275f7
c5956a10f2cd4e6db02e062ada7e0763
Y
acb73524c76f4e1994f9a50dc9d8da6b--c5956a10f2cd4e6db02e062ada7e0763
11e386920c95471c8bd1d0bed99e6cec
2
19b353d6c15a416092fea430f1137a69
c5956a10f2cd4e6db02e062ada7e0763--19b353d6c15a416092fea430f1137a69
d882117fbdeb44dabc40857d175d4482
HamEvo
19b353d6c15a416092fea430f1137a69--d882117fbdeb44dabc40857d175d4482
d882117fbdeb44dabc40857d175d4482--675afae524004cd0a6095d13be0275f7
f8fdd485227a4b5a8c26f9d31e4b2c8a
479aafccf7044e76995a4ea5a5c3b8e9
RX(x)
11e386920c95471c8bd1d0bed99e6cec--479aafccf7044e76995a4ea5a5c3b8e9
e0b0d2a0e28b4ee291783fd3a5d7b51e
3
0eaec8c9593d4d5ba626625b24342073
479aafccf7044e76995a4ea5a5c3b8e9--0eaec8c9593d4d5ba626625b24342073
22b639dc65754b92b9aabe1b227c07e0
t = 10
0eaec8c9593d4d5ba626625b24342073--22b639dc65754b92b9aabe1b227c07e0
22b639dc65754b92b9aabe1b227c07e0--f8fdd485227a4b5a8c26f9d31e4b2c8a
4ab82ad82287408ab526affc1d6edd71
7415916ab8124c418675beace0432ac0
RX(0.5)
e0b0d2a0e28b4ee291783fd3a5d7b51e--7415916ab8124c418675beace0432ac0
6645b29556204941a8c28b1c4a936d6c
X
7415916ab8124c418675beace0432ac0--6645b29556204941a8c28b1c4a936d6c
6645b29556204941a8c28b1c4a936d6c--0eaec8c9593d4d5ba626625b24342073
03bd61a323234521be738bef9d3a904c
6645b29556204941a8c28b1c4a936d6c--03bd61a323234521be738bef9d3a904c
03bd61a323234521be738bef9d3a904c--4ab82ad82287408ab526affc1d6edd71
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_97c1da2be22d47079a8ffd538063b2b8
HEA
cluster_26443d38f8af4ad4a9257408538ac1a2
Tower Fourier FM
5e2060c548e1438b8fa20a918c5414ef
0
f65ba803dc1546a3bc54bf41e7d0d2d9
RX(1.0*phi)
5e2060c548e1438b8fa20a918c5414ef--f65ba803dc1546a3bc54bf41e7d0d2d9
3d0dbbad73a142829711597c81cac88e
1
e6033e46c5dc4d90add1ac968ffe710c
RX(theta₀)
f65ba803dc1546a3bc54bf41e7d0d2d9--e6033e46c5dc4d90add1ac968ffe710c
e3af49cce68a49adb59884305d3d58c0
RY(theta₄)
e6033e46c5dc4d90add1ac968ffe710c--e3af49cce68a49adb59884305d3d58c0
4f1523d3e6d5457587f4a433df938a9e
RX(theta₈)
e3af49cce68a49adb59884305d3d58c0--4f1523d3e6d5457587f4a433df938a9e
0c512273f3c946e7988a07a2765f5ed1
4f1523d3e6d5457587f4a433df938a9e--0c512273f3c946e7988a07a2765f5ed1
682963fd1bd9493ca1433ed3361c2b0f
0c512273f3c946e7988a07a2765f5ed1--682963fd1bd9493ca1433ed3361c2b0f
74959d59ed9c423ab69dc473c055d585
RX(theta₁₂)
682963fd1bd9493ca1433ed3361c2b0f--74959d59ed9c423ab69dc473c055d585
1192011ecaf64049a0ee82bd771b2b6f
RY(theta₁₆)
74959d59ed9c423ab69dc473c055d585--1192011ecaf64049a0ee82bd771b2b6f
dd9b643de33c4cecb6e5565d0f9662fd
RX(theta₂₀)
1192011ecaf64049a0ee82bd771b2b6f--dd9b643de33c4cecb6e5565d0f9662fd
27f7fd9de26c4ed589b4093946c9a840
dd9b643de33c4cecb6e5565d0f9662fd--27f7fd9de26c4ed589b4093946c9a840
8886fb8712564c4aa05897a051ae8cc4
27f7fd9de26c4ed589b4093946c9a840--8886fb8712564c4aa05897a051ae8cc4
d400f0d9e4484039b06b28c4ca86cbe8
8886fb8712564c4aa05897a051ae8cc4--d400f0d9e4484039b06b28c4ca86cbe8
752b715aefcf4b7e8e421afa048d1a7d
cb931dc2d86848528c093266295c65db
RX(2.0*phi)
3d0dbbad73a142829711597c81cac88e--cb931dc2d86848528c093266295c65db
88878195dd274fb3bcf821306c1ab660
2
c72d7eb3d7894c4e81fd56b22ad6eb39
RX(theta₁)
cb931dc2d86848528c093266295c65db--c72d7eb3d7894c4e81fd56b22ad6eb39
470dd7736bae4ede9873fdbb1703e23c
RY(theta₅)
c72d7eb3d7894c4e81fd56b22ad6eb39--470dd7736bae4ede9873fdbb1703e23c
5904f2527290467da54eb16b1e7fbe5f
RX(theta₉)
470dd7736bae4ede9873fdbb1703e23c--5904f2527290467da54eb16b1e7fbe5f
c5ec008e544d435380e1ae1e27558049
X
5904f2527290467da54eb16b1e7fbe5f--c5ec008e544d435380e1ae1e27558049
c5ec008e544d435380e1ae1e27558049--0c512273f3c946e7988a07a2765f5ed1
51b37d1188f04b8fb529ceaac071d7f7
c5ec008e544d435380e1ae1e27558049--51b37d1188f04b8fb529ceaac071d7f7
61b655a569f0462686dbda3cbf58418f
RX(theta₁₃)
51b37d1188f04b8fb529ceaac071d7f7--61b655a569f0462686dbda3cbf58418f
b916fbf2a7054693aba2598465839a92
RY(theta₁₇)
61b655a569f0462686dbda3cbf58418f--b916fbf2a7054693aba2598465839a92
a5ea31686c5a44ef8b928ff8cedd28a2
RX(theta₂₁)
b916fbf2a7054693aba2598465839a92--a5ea31686c5a44ef8b928ff8cedd28a2
e351daa6127b408c993a1d7fe9fa0e69
X
a5ea31686c5a44ef8b928ff8cedd28a2--e351daa6127b408c993a1d7fe9fa0e69
e351daa6127b408c993a1d7fe9fa0e69--27f7fd9de26c4ed589b4093946c9a840
a204d117b6ff4b138dacacb0edd0affd
e351daa6127b408c993a1d7fe9fa0e69--a204d117b6ff4b138dacacb0edd0affd
a204d117b6ff4b138dacacb0edd0affd--752b715aefcf4b7e8e421afa048d1a7d
5cb119bcc88b4add8725a0d44dec6ceb
3516f381c6af46c88c78f2723bd9cee4
RX(3.0*phi)
88878195dd274fb3bcf821306c1ab660--3516f381c6af46c88c78f2723bd9cee4
2e4e96581694474e8cd17f94ab983bd4
3
83014a265c654706818fb3aaa0e5e0e9
RX(theta₂)
3516f381c6af46c88c78f2723bd9cee4--83014a265c654706818fb3aaa0e5e0e9
0ebb8ac198464188a78fdcecd1c72098
RY(theta₆)
83014a265c654706818fb3aaa0e5e0e9--0ebb8ac198464188a78fdcecd1c72098
f8e854745f1b45db9e9e3e362db72691
RX(theta₁₀)
0ebb8ac198464188a78fdcecd1c72098--f8e854745f1b45db9e9e3e362db72691
07b0272393ad42b4b77874d75d88d5a0
f8e854745f1b45db9e9e3e362db72691--07b0272393ad42b4b77874d75d88d5a0
dd3e3e941de74b1a8e9085a69bc8e57f
X
07b0272393ad42b4b77874d75d88d5a0--dd3e3e941de74b1a8e9085a69bc8e57f
dd3e3e941de74b1a8e9085a69bc8e57f--51b37d1188f04b8fb529ceaac071d7f7
338b143b5b774fba9e027cdbf627e26f
RX(theta₁₄)
dd3e3e941de74b1a8e9085a69bc8e57f--338b143b5b774fba9e027cdbf627e26f
51aa55585a1d45deb8d40a4afb15d7d7
RY(theta₁₈)
338b143b5b774fba9e027cdbf627e26f--51aa55585a1d45deb8d40a4afb15d7d7
dd17ebb57fa64ce6a6b0db69b8ccf3ae
RX(theta₂₂)
51aa55585a1d45deb8d40a4afb15d7d7--dd17ebb57fa64ce6a6b0db69b8ccf3ae
f56c28cab9304262bfbde591fbf15f18
dd17ebb57fa64ce6a6b0db69b8ccf3ae--f56c28cab9304262bfbde591fbf15f18
d44b3824e03c49b693197395ce36bf32
X
f56c28cab9304262bfbde591fbf15f18--d44b3824e03c49b693197395ce36bf32
d44b3824e03c49b693197395ce36bf32--a204d117b6ff4b138dacacb0edd0affd
d44b3824e03c49b693197395ce36bf32--5cb119bcc88b4add8725a0d44dec6ceb
3e93678ffcdd4868a8364c10c22b7e8d
cb2efb1639ee41d7b40935a00e5db38d
RX(4.0*phi)
2e4e96581694474e8cd17f94ab983bd4--cb2efb1639ee41d7b40935a00e5db38d
9f35f5d6e9cd4ee6b3373801000134db
RX(theta₃)
cb2efb1639ee41d7b40935a00e5db38d--9f35f5d6e9cd4ee6b3373801000134db
ed4e6f86df6a4c5b88e1b938460e77a2
RY(theta₇)
9f35f5d6e9cd4ee6b3373801000134db--ed4e6f86df6a4c5b88e1b938460e77a2
c758aa03b6524332918720565eab5973
RX(theta₁₁)
ed4e6f86df6a4c5b88e1b938460e77a2--c758aa03b6524332918720565eab5973
c8c6e6fa983542ea96ca04e84c6b47da
X
c758aa03b6524332918720565eab5973--c8c6e6fa983542ea96ca04e84c6b47da
c8c6e6fa983542ea96ca04e84c6b47da--07b0272393ad42b4b77874d75d88d5a0
dfc101539f174a9f8621726457e1b10e
c8c6e6fa983542ea96ca04e84c6b47da--dfc101539f174a9f8621726457e1b10e
723e7bfd14bf41ca8bdb2e495cff471f
RX(theta₁₅)
dfc101539f174a9f8621726457e1b10e--723e7bfd14bf41ca8bdb2e495cff471f
252399969d8d4c37bee0bdb54470b651
RY(theta₁₉)
723e7bfd14bf41ca8bdb2e495cff471f--252399969d8d4c37bee0bdb54470b651
380a0135d3ef412eb764aecfa4766436
RX(theta₂₃)
252399969d8d4c37bee0bdb54470b651--380a0135d3ef412eb764aecfa4766436
ee23954cd07b4e1095a3899281b97829
X
380a0135d3ef412eb764aecfa4766436--ee23954cd07b4e1095a3899281b97829
ee23954cd07b4e1095a3899281b97829--f56c28cab9304262bfbde591fbf15f18
06a179392a5b4b6996a4f22735a7a870
ee23954cd07b4e1095a3899281b97829--06a179392a5b4b6996a4f22735a7a870
06a179392a5b4b6996a4f22735a7a870--3e93678ffcdd4868a8364c10c22b7e8d
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_0375f1bc02fb48ff9b5418b8eee605a9
Obs.
cluster_0e909908ebe84e5e8d6dacfae2b99763
cluster_d266161d4800483591afd4fb527f226a
HEA
29b2263e950a4da7be822984771afa69
0
4acea8661c6e43b8b6a9c8c37ac107b7
RX(theta₀)
29b2263e950a4da7be822984771afa69--4acea8661c6e43b8b6a9c8c37ac107b7
ff1161a694184850a579da5f7f041dc4
1
03df1990680d4edf8397174b27376d99
RY(theta₃)
4acea8661c6e43b8b6a9c8c37ac107b7--03df1990680d4edf8397174b27376d99
c87d8a46a762464581ee4f70798e3194
RX(theta₆)
03df1990680d4edf8397174b27376d99--c87d8a46a762464581ee4f70798e3194
73193c0983eb40dbbc31e6194441bf90
c87d8a46a762464581ee4f70798e3194--73193c0983eb40dbbc31e6194441bf90
5107b102bd1a4d109fd63f50bd282c1c
73193c0983eb40dbbc31e6194441bf90--5107b102bd1a4d109fd63f50bd282c1c
21e6391e9b1a426ebd74d1a6c837d62f
RX(theta₉)
5107b102bd1a4d109fd63f50bd282c1c--21e6391e9b1a426ebd74d1a6c837d62f
efa6e52dd57d4441952836eae3cc944f
RY(theta₁₂)
21e6391e9b1a426ebd74d1a6c837d62f--efa6e52dd57d4441952836eae3cc944f
8175f0ac5995403cb9dd1f68853f10fa
RX(theta₁₅)
efa6e52dd57d4441952836eae3cc944f--8175f0ac5995403cb9dd1f68853f10fa
be922ae0f6594fc990bbe0766f75f2bb
8175f0ac5995403cb9dd1f68853f10fa--be922ae0f6594fc990bbe0766f75f2bb
d5ded76dc7cd482894c9f7f7a606c47a
be922ae0f6594fc990bbe0766f75f2bb--d5ded76dc7cd482894c9f7f7a606c47a
cf529cefc4d04bd493593b121c7a3ca7
d5ded76dc7cd482894c9f7f7a606c47a--cf529cefc4d04bd493593b121c7a3ca7
3a784da860c942d685da25d648abcfd2
cf529cefc4d04bd493593b121c7a3ca7--3a784da860c942d685da25d648abcfd2
a958a7d625324bb3a220d799c9ceb744
f2f5a2f4d94f469bb9fe569f876cdc42
RX(theta₁)
ff1161a694184850a579da5f7f041dc4--f2f5a2f4d94f469bb9fe569f876cdc42
59c752d99d7142a7b5b2cfca39b6a248
2
d94de649c7f54802a0be6918832462e5
RY(theta₄)
f2f5a2f4d94f469bb9fe569f876cdc42--d94de649c7f54802a0be6918832462e5
a574b0d0ca4f4399ba22fe8c3d3d447a
RX(theta₇)
d94de649c7f54802a0be6918832462e5--a574b0d0ca4f4399ba22fe8c3d3d447a
7eedaa8adf774f24bbc976351e4d4838
X
a574b0d0ca4f4399ba22fe8c3d3d447a--7eedaa8adf774f24bbc976351e4d4838
7eedaa8adf774f24bbc976351e4d4838--73193c0983eb40dbbc31e6194441bf90
efce71a60ee34d71ade13df28abe38d8
7eedaa8adf774f24bbc976351e4d4838--efce71a60ee34d71ade13df28abe38d8
5cad9674f5b74de79f8fe4094cea4b34
RX(theta₁₀)
efce71a60ee34d71ade13df28abe38d8--5cad9674f5b74de79f8fe4094cea4b34
cde0943a2a7a44cc84fd133666188600
RY(theta₁₃)
5cad9674f5b74de79f8fe4094cea4b34--cde0943a2a7a44cc84fd133666188600
b70eaf00815f4845bfb5fce1db142288
RX(theta₁₆)
cde0943a2a7a44cc84fd133666188600--b70eaf00815f4845bfb5fce1db142288
5484d45b51694ecaafe0799277f7540e
X
b70eaf00815f4845bfb5fce1db142288--5484d45b51694ecaafe0799277f7540e
5484d45b51694ecaafe0799277f7540e--be922ae0f6594fc990bbe0766f75f2bb
f94d0135bc554e7e9a23abba57b78ce0
5484d45b51694ecaafe0799277f7540e--f94d0135bc554e7e9a23abba57b78ce0
ff65416d331a49888df18a5fcd4785ef
AddBlock
f94d0135bc554e7e9a23abba57b78ce0--ff65416d331a49888df18a5fcd4785ef
ff65416d331a49888df18a5fcd4785ef--a958a7d625324bb3a220d799c9ceb744
df01e692da974f97af2f37954585fd1a
80c928a19656499eb4a647ceca3eaaf3
RX(theta₂)
59c752d99d7142a7b5b2cfca39b6a248--80c928a19656499eb4a647ceca3eaaf3
91b9a4ab30824386a2c272498d0d6b2d
RY(theta₅)
80c928a19656499eb4a647ceca3eaaf3--91b9a4ab30824386a2c272498d0d6b2d
dbf6d564abc046ffb9f988c7f45c16e3
RX(theta₈)
91b9a4ab30824386a2c272498d0d6b2d--dbf6d564abc046ffb9f988c7f45c16e3
ec8be73236504d61839be8c031d73d55
dbf6d564abc046ffb9f988c7f45c16e3--ec8be73236504d61839be8c031d73d55
a4d6f47f427543d89fc1e84672c3d2fb
X
ec8be73236504d61839be8c031d73d55--a4d6f47f427543d89fc1e84672c3d2fb
a4d6f47f427543d89fc1e84672c3d2fb--efce71a60ee34d71ade13df28abe38d8
72cad3e7334044eeb3b926c72108e315
RX(theta₁₁)
a4d6f47f427543d89fc1e84672c3d2fb--72cad3e7334044eeb3b926c72108e315
2e3cd3c7638b4e31bc32b4514d1626fb
RY(theta₁₄)
72cad3e7334044eeb3b926c72108e315--2e3cd3c7638b4e31bc32b4514d1626fb
28764eefa7d242e2bf3389eb5b80dcd3
RX(theta₁₇)
2e3cd3c7638b4e31bc32b4514d1626fb--28764eefa7d242e2bf3389eb5b80dcd3
f76e046c7a1b41609d698ce253ad5654
28764eefa7d242e2bf3389eb5b80dcd3--f76e046c7a1b41609d698ce253ad5654
0860c71c5d654870b17e5025d6525bba
X
f76e046c7a1b41609d698ce253ad5654--0860c71c5d654870b17e5025d6525bba
0860c71c5d654870b17e5025d6525bba--f94d0135bc554e7e9a23abba57b78ce0
9dc5b41d9217468ead2d8f4e02d72db2
0860c71c5d654870b17e5025d6525bba--9dc5b41d9217468ead2d8f4e02d72db2
9dc5b41d9217468ead2d8f4e02d72db2--df01e692da974f97af2f37954585fd1a
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
2395405c9475479bb387abd216c091e4
0
7aee3ca611c544cfb4b35e3241a8ec06
2395405c9475479bb387abd216c091e4--7aee3ca611c544cfb4b35e3241a8ec06
86b21981aa4e4680904130cea145fb13
1
11ad6dee5c9540488058c8893061c656
fb94768ddb7a46278b604c3624a8aba3
7aee3ca611c544cfb4b35e3241a8ec06--fb94768ddb7a46278b604c3624a8aba3
49b0d3f906704b8da3039e4d1d6d4fca
11ad6dee5c9540488058c8893061c656--49b0d3f906704b8da3039e4d1d6d4fca
440d693a21174f5ba0d2cf95119ef8fb
7075cec085964fe7835ebe3567c3a864
49b0d3f906704b8da3039e4d1d6d4fca--7075cec085964fe7835ebe3567c3a864
87e4eb9b641b4fce8d4accd2b1f3b3bb
440d693a21174f5ba0d2cf95119ef8fb--87e4eb9b641b4fce8d4accd2b1f3b3bb
21a074273bc84f348e5ac91234cb4f79
650df43c979a454698d6622163b0004e
86b21981aa4e4680904130cea145fb13--650df43c979a454698d6622163b0004e
a2e48d19039043bb8d99929e33758b7a
2
650df43c979a454698d6622163b0004e--11ad6dee5c9540488058c8893061c656
fa66c7ba14174f3c87e5d4226f4c833e
fb94768ddb7a46278b604c3624a8aba3--fa66c7ba14174f3c87e5d4226f4c833e
611dc7d19a734af7a8524b0dd1e68d98
fa66c7ba14174f3c87e5d4226f4c833e--611dc7d19a734af7a8524b0dd1e68d98
611dc7d19a734af7a8524b0dd1e68d98--21a074273bc84f348e5ac91234cb4f79
08e3dec68f7c463d84556cb9c7ee6a65
ab32b630f9d646048bdfa5acdad3bce5
a2e48d19039043bb8d99929e33758b7a--ab32b630f9d646048bdfa5acdad3bce5
e7e1bb6b324148ebafd2385ea81bdb95
3
19afa054c3ea4b5795e5817fcd73781a
ab32b630f9d646048bdfa5acdad3bce5--19afa054c3ea4b5795e5817fcd73781a
b009183989874d4e8921d28ea0531554
19afa054c3ea4b5795e5817fcd73781a--b009183989874d4e8921d28ea0531554
d0e16adc4f924c52993e1f8ee469a3a2
b009183989874d4e8921d28ea0531554--d0e16adc4f924c52993e1f8ee469a3a2
d0e16adc4f924c52993e1f8ee469a3a2--08e3dec68f7c463d84556cb9c7ee6a65
9c8a073c9e454cafa79f87c96bdcb51f
fe336cc460ed488c8adf6b1aebeda00a
e7e1bb6b324148ebafd2385ea81bdb95--fe336cc460ed488c8adf6b1aebeda00a
97997090ca574202824a3501f90424d0
fe336cc460ed488c8adf6b1aebeda00a--97997090ca574202824a3501f90424d0
4e27d237059f48d09498581638e4d833
97997090ca574202824a3501f90424d0--4e27d237059f48d09498581638e4d833
4e27d237059f48d09498581638e4d833--440d693a21174f5ba0d2cf95119ef8fb
7075cec085964fe7835ebe3567c3a864--9c8a073c9e454cafa79f87c96bdcb51f
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
79b9d2df44e6404d8b0de822def03de2
0
515fcb6422a548d9905c962470d03c5a
79b9d2df44e6404d8b0de822def03de2--515fcb6422a548d9905c962470d03c5a
e237aa928cfc41768b630a264e4e102f
1
8d1b137db316493ea2a6a95c80c039ed
515fcb6422a548d9905c962470d03c5a--8d1b137db316493ea2a6a95c80c039ed
91e697a273c8450395f89d524af7997b
8d1b137db316493ea2a6a95c80c039ed--91e697a273c8450395f89d524af7997b
b52f71a4d2f54a148f8c77a1a302bcea
91e697a273c8450395f89d524af7997b--b52f71a4d2f54a148f8c77a1a302bcea
3b92e0c2ab974a64a0509bfc66dd98c4
dd8838735efb488bbf767b8621dd927d
PHASE(0.5)
e237aa928cfc41768b630a264e4e102f--dd8838735efb488bbf767b8621dd927d
29222f48fbbb46b5880b7133417a3a8d
2
dd8838735efb488bbf767b8621dd927d--515fcb6422a548d9905c962470d03c5a
604d80ea22844f8a8b5136e5c13eee47
dd8838735efb488bbf767b8621dd927d--604d80ea22844f8a8b5136e5c13eee47
c4f0d4134fe34efe9c6f51f5b9cf17b2
604d80ea22844f8a8b5136e5c13eee47--c4f0d4134fe34efe9c6f51f5b9cf17b2
c4f0d4134fe34efe9c6f51f5b9cf17b2--3b92e0c2ab974a64a0509bfc66dd98c4
45ad8627a69743da857c473fb47387de
1a6a232cc6fa4bf8ba9fb1a34c8fba18
29222f48fbbb46b5880b7133417a3a8d--1a6a232cc6fa4bf8ba9fb1a34c8fba18
0aa59e78e0b04b78941d609ef08e32ec
3
e5d2fcf8a1284b34a8b8a0fd71fa21fc
PHASE(0.5)
1a6a232cc6fa4bf8ba9fb1a34c8fba18--e5d2fcf8a1284b34a8b8a0fd71fa21fc
e5d2fcf8a1284b34a8b8a0fd71fa21fc--8d1b137db316493ea2a6a95c80c039ed
0e70f63513e4434c8c92731a2e982034
e5d2fcf8a1284b34a8b8a0fd71fa21fc--0e70f63513e4434c8c92731a2e982034
0e70f63513e4434c8c92731a2e982034--45ad8627a69743da857c473fb47387de
1f643a61aac046f6ab00f2fd2adee463
258b87ada5954e298a6b4cc5e188b7c0
0aa59e78e0b04b78941d609ef08e32ec--258b87ada5954e298a6b4cc5e188b7c0
662e82ff4cd34810be4efdea28ef1603
258b87ada5954e298a6b4cc5e188b7c0--662e82ff4cd34810be4efdea28ef1603
217f604a742a40aeb63e9b3351f7625d
PHASE(0.5)
662e82ff4cd34810be4efdea28ef1603--217f604a742a40aeb63e9b3351f7625d
217f604a742a40aeb63e9b3351f7625d--91e697a273c8450395f89d524af7997b
217f604a742a40aeb63e9b3351f7625d--1f643a61aac046f6ab00f2fd2adee463
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