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
e6d40a3026404d4295380fd2f295fdfb
0
05234c35a4664b6591303fdff859406e
X
e6d40a3026404d4295380fd2f295fdfb--05234c35a4664b6591303fdff859406e
cfc7aea46a2645d6bd95953ff5327916
1
975b4f40af51479fa98246d73fa25259
05234c35a4664b6591303fdff859406e--975b4f40af51479fa98246d73fa25259
482a3834c06f45faba41045b8f50cb6c
074ac93a596746029581509a7979f940
Y
cfc7aea46a2645d6bd95953ff5327916--074ac93a596746029581509a7979f940
074ac93a596746029581509a7979f940--482a3834c06f45faba41045b8f50cb6c
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
425155f2f19447dcb3b74015303c7c0a
0
9ee56c35c8084a7a81d5b2f8a600db9a
X
425155f2f19447dcb3b74015303c7c0a--9ee56c35c8084a7a81d5b2f8a600db9a
db79cc553d7746f39e7d76a6b0810597
Y
9ee56c35c8084a7a81d5b2f8a600db9a--db79cc553d7746f39e7d76a6b0810597
7370f7fd71844d55a15fb359dd874e72
db79cc553d7746f39e7d76a6b0810597--7370f7fd71844d55a15fb359dd874e72
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
e5b119bb368c4c1691fad98d9323c6f4
0
fb4ad30a0dba4420870aec72f564d9d1
X
e5b119bb368c4c1691fad98d9323c6f4--fb4ad30a0dba4420870aec72f564d9d1
d9510ebf6d7f456ea56dcdfe98b37a0e
1
ffac6ec75afc42e59574f5ed0b57c1a0
fb4ad30a0dba4420870aec72f564d9d1--ffac6ec75afc42e59574f5ed0b57c1a0
0d98d85426ed421c9f36fd07ab1a60de
ffac6ec75afc42e59574f5ed0b57c1a0--0d98d85426ed421c9f36fd07ab1a60de
18464b2938df4ea3aa30e127e7ee6666
8cd43809c48042999d2bf2ffa61ac3b2
d9510ebf6d7f456ea56dcdfe98b37a0e--8cd43809c48042999d2bf2ffa61ac3b2
b710a8cdfdad4bddac08e4e09dd979da
Y
8cd43809c48042999d2bf2ffa61ac3b2--b710a8cdfdad4bddac08e4e09dd979da
b710a8cdfdad4bddac08e4e09dd979da--18464b2938df4ea3aa30e127e7ee6666
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_9fa0cbc2994945b786ac6774db8dc838
e2dfe2c0910b46fc8d41e99860a2607b
0
a948e6125c994234bbc3aed2147308a1
e2dfe2c0910b46fc8d41e99860a2607b--a948e6125c994234bbc3aed2147308a1
30ba00e8b692461aa3b0a2e0577b98bb
1
f55e59cf547646f78230316b91dc3f9f
a948e6125c994234bbc3aed2147308a1--f55e59cf547646f78230316b91dc3f9f
18371e1e7aec4a2e979eb31c0a5ab01e
fe747e3bff9149b28216774aaa1411bf
AddBlock
30ba00e8b692461aa3b0a2e0577b98bb--fe747e3bff9149b28216774aaa1411bf
d621947fe40841f5a4e0e46d07dae5bb
2
fe747e3bff9149b28216774aaa1411bf--18371e1e7aec4a2e979eb31c0a5ab01e
4237ddd22058482c8e7a07d044440047
0c1561a69c0e471e9c3b035cd35bb4c3
d621947fe40841f5a4e0e46d07dae5bb--0c1561a69c0e471e9c3b035cd35bb4c3
0c1561a69c0e471e9c3b035cd35bb4c3--4237ddd22058482c8e7a07d044440047
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_6ee223de4ed141a5abfa528f8bc602d3
cluster_95f26a76bb6a4501b08272e9b3f20fd1
rx
b6fee3a32c204bf591cced3752d46b83
0
2beedcc3143a4c3facd41070ded79324
X
b6fee3a32c204bf591cced3752d46b83--2beedcc3143a4c3facd41070ded79324
7c81cbabe87246f19bbbd3d5bf473aa6
1
383d914313b34636be1695fa1bcc3d5a
2beedcc3143a4c3facd41070ded79324--383d914313b34636be1695fa1bcc3d5a
1a63c7f7c6a7425f878c0434cf5027a8
383d914313b34636be1695fa1bcc3d5a--1a63c7f7c6a7425f878c0434cf5027a8
a5fe5bf51f9b4b19b5f6cbd2961348a6
1a63c7f7c6a7425f878c0434cf5027a8--a5fe5bf51f9b4b19b5f6cbd2961348a6
b9c572492b8a45a4b07d1cb8314f4928
629052a78cfa4e58a5b4276a5a3a41ce
Y
7c81cbabe87246f19bbbd3d5bf473aa6--629052a78cfa4e58a5b4276a5a3a41ce
73a08a2cfc534883925015ac0c70d784
2
8278f168948544bfa3cdf5ae94a82e10
629052a78cfa4e58a5b4276a5a3a41ce--8278f168948544bfa3cdf5ae94a82e10
03ceef123a2045e7a34cdbc699fe12ea
HamEvo
8278f168948544bfa3cdf5ae94a82e10--03ceef123a2045e7a34cdbc699fe12ea
03ceef123a2045e7a34cdbc699fe12ea--b9c572492b8a45a4b07d1cb8314f4928
0c935486b42c4614a15c96ac3c32d588
7caccbf0b3d54c0bb417a9dd33772a60
RX(x)
73a08a2cfc534883925015ac0c70d784--7caccbf0b3d54c0bb417a9dd33772a60
2956c04d00e740c7bf7a4df66c65e028
3
ad51a170724940cd830e99b4234f6787
7caccbf0b3d54c0bb417a9dd33772a60--ad51a170724940cd830e99b4234f6787
76b538bc45684976bd52151058842999
t = 10
ad51a170724940cd830e99b4234f6787--76b538bc45684976bd52151058842999
76b538bc45684976bd52151058842999--0c935486b42c4614a15c96ac3c32d588
fd296df0527e42e380d5d66064f5075a
69229d44e2184834ad50d665c42b661e
RX(0.5)
2956c04d00e740c7bf7a4df66c65e028--69229d44e2184834ad50d665c42b661e
012c21c236954369be85354f2c28ee61
X
69229d44e2184834ad50d665c42b661e--012c21c236954369be85354f2c28ee61
012c21c236954369be85354f2c28ee61--ad51a170724940cd830e99b4234f6787
a7d3e46c1bcb47fba9716a7da5cf6ec7
012c21c236954369be85354f2c28ee61--a7d3e46c1bcb47fba9716a7da5cf6ec7
a7d3e46c1bcb47fba9716a7da5cf6ec7--fd296df0527e42e380d5d66064f5075a
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_c2914d9af53f44d39be2a4ea1de94ced
HEA
cluster_6178bc5296634925990e8ce2e4cd9b8e
Tower Fourier FM
b2c2a2e0fedf485d8dc3e297e960319e
0
2ef756c8b71e4455ab610cccb0e7c024
RX(1.0*phi)
b2c2a2e0fedf485d8dc3e297e960319e--2ef756c8b71e4455ab610cccb0e7c024
388e62b4ce9f4133940aab37fccac26f
1
458aa578fdb44d8dad4624e662c0441a
RX(theta₀)
2ef756c8b71e4455ab610cccb0e7c024--458aa578fdb44d8dad4624e662c0441a
4fe418525e3948da95b4c31834c089f1
RY(theta₄)
458aa578fdb44d8dad4624e662c0441a--4fe418525e3948da95b4c31834c089f1
d109e01ab40e46249d59f67ea5164b0f
RX(theta₈)
4fe418525e3948da95b4c31834c089f1--d109e01ab40e46249d59f67ea5164b0f
5377da87db2a4b41aa56848a98af9fae
d109e01ab40e46249d59f67ea5164b0f--5377da87db2a4b41aa56848a98af9fae
c2ef26792cb044558055610b12f44bca
5377da87db2a4b41aa56848a98af9fae--c2ef26792cb044558055610b12f44bca
60e0f25b5a8e477ca1fb4a0ac0f82f72
RX(theta₁₂)
c2ef26792cb044558055610b12f44bca--60e0f25b5a8e477ca1fb4a0ac0f82f72
ea938ec1fbe1431a975c2b9c894b913e
RY(theta₁₆)
60e0f25b5a8e477ca1fb4a0ac0f82f72--ea938ec1fbe1431a975c2b9c894b913e
e419df563dd7420eb0b3f161c10a2af7
RX(theta₂₀)
ea938ec1fbe1431a975c2b9c894b913e--e419df563dd7420eb0b3f161c10a2af7
b483ea6034ce48d0b836be8906f59deb
e419df563dd7420eb0b3f161c10a2af7--b483ea6034ce48d0b836be8906f59deb
555c1a5625004943937424c404f71177
b483ea6034ce48d0b836be8906f59deb--555c1a5625004943937424c404f71177
8851e2e445a9491a875db54798b0a205
555c1a5625004943937424c404f71177--8851e2e445a9491a875db54798b0a205
3782932e17f34f798193e3f7df93746d
33d46b82ea414e05aa1aaf31df38a91e
RX(2.0*phi)
388e62b4ce9f4133940aab37fccac26f--33d46b82ea414e05aa1aaf31df38a91e
1f83d5a5351c48ec9afabd1b9ca83ca8
2
0dd311a3ed054078a6745f370e3567bf
RX(theta₁)
33d46b82ea414e05aa1aaf31df38a91e--0dd311a3ed054078a6745f370e3567bf
f8afda0e686a44fbb9b3ff2b8a00efdc
RY(theta₅)
0dd311a3ed054078a6745f370e3567bf--f8afda0e686a44fbb9b3ff2b8a00efdc
58af76b5482a403c8458242dce7397be
RX(theta₉)
f8afda0e686a44fbb9b3ff2b8a00efdc--58af76b5482a403c8458242dce7397be
07ad9897c1a847d381d7cc7e67c04b71
X
58af76b5482a403c8458242dce7397be--07ad9897c1a847d381d7cc7e67c04b71
07ad9897c1a847d381d7cc7e67c04b71--5377da87db2a4b41aa56848a98af9fae
9895faffb3aa4b2a8e6c7ffa88ff8392
07ad9897c1a847d381d7cc7e67c04b71--9895faffb3aa4b2a8e6c7ffa88ff8392
0b8314d0fbc246478087d56519e1c08b
RX(theta₁₃)
9895faffb3aa4b2a8e6c7ffa88ff8392--0b8314d0fbc246478087d56519e1c08b
a3d14caba3024aab896d2a66b99a0ee4
RY(theta₁₇)
0b8314d0fbc246478087d56519e1c08b--a3d14caba3024aab896d2a66b99a0ee4
4288fff5633a44b2803fafa3a6dde32f
RX(theta₂₁)
a3d14caba3024aab896d2a66b99a0ee4--4288fff5633a44b2803fafa3a6dde32f
106b6112191b4e95b9ecb0c941a58f2d
X
4288fff5633a44b2803fafa3a6dde32f--106b6112191b4e95b9ecb0c941a58f2d
106b6112191b4e95b9ecb0c941a58f2d--b483ea6034ce48d0b836be8906f59deb
efe15a6fcb1e4819ac0b2422e4d3f870
106b6112191b4e95b9ecb0c941a58f2d--efe15a6fcb1e4819ac0b2422e4d3f870
efe15a6fcb1e4819ac0b2422e4d3f870--3782932e17f34f798193e3f7df93746d
735e4fadfef54af08c778d2ce9f31bd9
f4236f1d3a7b4c2e88e8de99f97fe914
RX(3.0*phi)
1f83d5a5351c48ec9afabd1b9ca83ca8--f4236f1d3a7b4c2e88e8de99f97fe914
0d72202f9e41479696a53fea99764fd6
3
12b709cced524e8e842648aced817807
RX(theta₂)
f4236f1d3a7b4c2e88e8de99f97fe914--12b709cced524e8e842648aced817807
f3ac773d9e8a45dd9a5c3c0e23e927b6
RY(theta₆)
12b709cced524e8e842648aced817807--f3ac773d9e8a45dd9a5c3c0e23e927b6
3a796a0fb1714cf092304162c1f758e3
RX(theta₁₀)
f3ac773d9e8a45dd9a5c3c0e23e927b6--3a796a0fb1714cf092304162c1f758e3
c72e38cb9dde4616966e665cd2a1be82
3a796a0fb1714cf092304162c1f758e3--c72e38cb9dde4616966e665cd2a1be82
7948608efde3483ab61fbbb83e461f4f
X
c72e38cb9dde4616966e665cd2a1be82--7948608efde3483ab61fbbb83e461f4f
7948608efde3483ab61fbbb83e461f4f--9895faffb3aa4b2a8e6c7ffa88ff8392
8d225be714034991a37cc3f0f2ffa66f
RX(theta₁₄)
7948608efde3483ab61fbbb83e461f4f--8d225be714034991a37cc3f0f2ffa66f
6cb8f2132a2a4f2ab2649a4693b47409
RY(theta₁₈)
8d225be714034991a37cc3f0f2ffa66f--6cb8f2132a2a4f2ab2649a4693b47409
5a9d7da8cd71401e9201b6730fed5c75
RX(theta₂₂)
6cb8f2132a2a4f2ab2649a4693b47409--5a9d7da8cd71401e9201b6730fed5c75
629bb65d53f8428eba5ddcdc6ef9d2c3
5a9d7da8cd71401e9201b6730fed5c75--629bb65d53f8428eba5ddcdc6ef9d2c3
fa3118beb7d4490180dc7391d7dd304d
X
629bb65d53f8428eba5ddcdc6ef9d2c3--fa3118beb7d4490180dc7391d7dd304d
fa3118beb7d4490180dc7391d7dd304d--efe15a6fcb1e4819ac0b2422e4d3f870
fa3118beb7d4490180dc7391d7dd304d--735e4fadfef54af08c778d2ce9f31bd9
c770a365ff3f486ba2d36792856d9de5
1163abb52d524d3baca0e079c7ae15fa
RX(4.0*phi)
0d72202f9e41479696a53fea99764fd6--1163abb52d524d3baca0e079c7ae15fa
b14aaaf7bf074a149f37bb804877deae
RX(theta₃)
1163abb52d524d3baca0e079c7ae15fa--b14aaaf7bf074a149f37bb804877deae
a55a07a09d7142a3af4886dc046e18bc
RY(theta₇)
b14aaaf7bf074a149f37bb804877deae--a55a07a09d7142a3af4886dc046e18bc
b4ef16ebcbbd419aaba9460409fcf088
RX(theta₁₁)
a55a07a09d7142a3af4886dc046e18bc--b4ef16ebcbbd419aaba9460409fcf088
a8e5b54b6ca643c8bf753d20fb25ef19
X
b4ef16ebcbbd419aaba9460409fcf088--a8e5b54b6ca643c8bf753d20fb25ef19
a8e5b54b6ca643c8bf753d20fb25ef19--c72e38cb9dde4616966e665cd2a1be82
9abad9326db14dd3a1a5a8a15fada04e
a8e5b54b6ca643c8bf753d20fb25ef19--9abad9326db14dd3a1a5a8a15fada04e
8fec0dadc52a42a2ae14c535f326cf72
RX(theta₁₅)
9abad9326db14dd3a1a5a8a15fada04e--8fec0dadc52a42a2ae14c535f326cf72
075f862c33834bbb976883dc084ba379
RY(theta₁₉)
8fec0dadc52a42a2ae14c535f326cf72--075f862c33834bbb976883dc084ba379
21ada74f3b87466d865993d9d0ca9712
RX(theta₂₃)
075f862c33834bbb976883dc084ba379--21ada74f3b87466d865993d9d0ca9712
462f98a659904e7a91298941341b986a
X
21ada74f3b87466d865993d9d0ca9712--462f98a659904e7a91298941341b986a
462f98a659904e7a91298941341b986a--629bb65d53f8428eba5ddcdc6ef9d2c3
9440249c92044ea0b667229869275215
462f98a659904e7a91298941341b986a--9440249c92044ea0b667229869275215
9440249c92044ea0b667229869275215--c770a365ff3f486ba2d36792856d9de5
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_ce5370f6c3e141c487172c5454be66fc
Obs.
cluster_3b5a386594ee42e8840fff19e519826b
cluster_37367fcc718d4f50bae916fbd5f5f9bf
HEA
69fa5e88f62a4b60a4ef9ce8f67543c0
0
89f94770aae948768705b498afe7ff29
RX(theta₀)
69fa5e88f62a4b60a4ef9ce8f67543c0--89f94770aae948768705b498afe7ff29
0c4f8fa692674f41bc9239ce77462d90
1
cfeca51c0f9843dab38c4eec240e3383
RY(theta₃)
89f94770aae948768705b498afe7ff29--cfeca51c0f9843dab38c4eec240e3383
709979591a9446829539223db2d87e6d
RX(theta₆)
cfeca51c0f9843dab38c4eec240e3383--709979591a9446829539223db2d87e6d
ad50a5514b3648ec875d16682a0738fb
709979591a9446829539223db2d87e6d--ad50a5514b3648ec875d16682a0738fb
c4831f7e2d974cdd80307c396766ed7a
ad50a5514b3648ec875d16682a0738fb--c4831f7e2d974cdd80307c396766ed7a
81bed86c6f4f433c8b86fca5cfa8e147
RX(theta₉)
c4831f7e2d974cdd80307c396766ed7a--81bed86c6f4f433c8b86fca5cfa8e147
2d0c8e257e9e433cb6def377183efd59
RY(theta₁₂)
81bed86c6f4f433c8b86fca5cfa8e147--2d0c8e257e9e433cb6def377183efd59
96067eb196534579b4cbba6d25980873
RX(theta₁₅)
2d0c8e257e9e433cb6def377183efd59--96067eb196534579b4cbba6d25980873
3012b482f93249c9a407428484743d17
96067eb196534579b4cbba6d25980873--3012b482f93249c9a407428484743d17
b6a393a9444d431c910e1c7edbc36377
3012b482f93249c9a407428484743d17--b6a393a9444d431c910e1c7edbc36377
627c6e924f604b309c20066d694d89cf
b6a393a9444d431c910e1c7edbc36377--627c6e924f604b309c20066d694d89cf
d85a34347ffc4dbe87da9c15d7452b06
627c6e924f604b309c20066d694d89cf--d85a34347ffc4dbe87da9c15d7452b06
ec573aed98ca4113806794fc8711a916
8e2ab98b713d4ddeabc945acb925b84c
RX(theta₁)
0c4f8fa692674f41bc9239ce77462d90--8e2ab98b713d4ddeabc945acb925b84c
a633131c8f4d4ebc953dd9f9176f674d
2
3b99f228ff3845da86124b79ff82e3a8
RY(theta₄)
8e2ab98b713d4ddeabc945acb925b84c--3b99f228ff3845da86124b79ff82e3a8
8b6b58d78ba14f21aa6407536cf118b7
RX(theta₇)
3b99f228ff3845da86124b79ff82e3a8--8b6b58d78ba14f21aa6407536cf118b7
e7ea43f231524ee0ac175ae27417db7b
X
8b6b58d78ba14f21aa6407536cf118b7--e7ea43f231524ee0ac175ae27417db7b
e7ea43f231524ee0ac175ae27417db7b--ad50a5514b3648ec875d16682a0738fb
cec4bec0d03b438e82924f0c0e094e66
e7ea43f231524ee0ac175ae27417db7b--cec4bec0d03b438e82924f0c0e094e66
4f6e358f81124ca6918d6e380accafbe
RX(theta₁₀)
cec4bec0d03b438e82924f0c0e094e66--4f6e358f81124ca6918d6e380accafbe
88f32a80d6ba40dd9ab50370a5ededee
RY(theta₁₃)
4f6e358f81124ca6918d6e380accafbe--88f32a80d6ba40dd9ab50370a5ededee
866f7d8318264c55b97bde49cf2d347d
RX(theta₁₆)
88f32a80d6ba40dd9ab50370a5ededee--866f7d8318264c55b97bde49cf2d347d
e8ef3556ae72452e8500d60430839004
X
866f7d8318264c55b97bde49cf2d347d--e8ef3556ae72452e8500d60430839004
e8ef3556ae72452e8500d60430839004--3012b482f93249c9a407428484743d17
07b4eca7e8224cb6ac94bd3774453630
e8ef3556ae72452e8500d60430839004--07b4eca7e8224cb6ac94bd3774453630
439dc097a52f4046ab407d35bbf9747a
AddBlock
07b4eca7e8224cb6ac94bd3774453630--439dc097a52f4046ab407d35bbf9747a
439dc097a52f4046ab407d35bbf9747a--ec573aed98ca4113806794fc8711a916
d6f99cb4e4744089a6687eedfcb5d9fb
891fd14527e24af4bc823e378b1fbc8e
RX(theta₂)
a633131c8f4d4ebc953dd9f9176f674d--891fd14527e24af4bc823e378b1fbc8e
aeb5bef205474daea4a13ea81330bb22
RY(theta₅)
891fd14527e24af4bc823e378b1fbc8e--aeb5bef205474daea4a13ea81330bb22
d253c3d2813e49df9fcf262f5e4629a8
RX(theta₈)
aeb5bef205474daea4a13ea81330bb22--d253c3d2813e49df9fcf262f5e4629a8
bd2c098005534d69af44167ffd34343f
d253c3d2813e49df9fcf262f5e4629a8--bd2c098005534d69af44167ffd34343f
d747ad5e9a33439689b30fed702984bc
X
bd2c098005534d69af44167ffd34343f--d747ad5e9a33439689b30fed702984bc
d747ad5e9a33439689b30fed702984bc--cec4bec0d03b438e82924f0c0e094e66
ca5936fa68ae40fd9c7a5b368da0655c
RX(theta₁₁)
d747ad5e9a33439689b30fed702984bc--ca5936fa68ae40fd9c7a5b368da0655c
6ab268667ec5487f83c297788af5c694
RY(theta₁₄)
ca5936fa68ae40fd9c7a5b368da0655c--6ab268667ec5487f83c297788af5c694
1feb39484db746b6b406953106b1554b
RX(theta₁₇)
6ab268667ec5487f83c297788af5c694--1feb39484db746b6b406953106b1554b
30dfb3267c554d1dbd14fd4cb22b5857
1feb39484db746b6b406953106b1554b--30dfb3267c554d1dbd14fd4cb22b5857
ddef5a4796b14ddaa8e4699215125724
X
30dfb3267c554d1dbd14fd4cb22b5857--ddef5a4796b14ddaa8e4699215125724
ddef5a4796b14ddaa8e4699215125724--07b4eca7e8224cb6ac94bd3774453630
044c13aa2ac94a43a72cd8d4613c43db
ddef5a4796b14ddaa8e4699215125724--044c13aa2ac94a43a72cd8d4613c43db
044c13aa2ac94a43a72cd8d4613c43db--d6f99cb4e4744089a6687eedfcb5d9fb
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
cb266945888e40e89814e13d29cf1954
0
2a0830b724d64ab6b189bd36cb71fbb6
cb266945888e40e89814e13d29cf1954--2a0830b724d64ab6b189bd36cb71fbb6
8f4e3cd724ad47b9a90d0f3d6ec42fd4
1
64d0713b0ddc4d18aad77688cecbcc3f
9c62f97b9ae747f38dfc2a36cad4b13b
2a0830b724d64ab6b189bd36cb71fbb6--9c62f97b9ae747f38dfc2a36cad4b13b
ce69b5789c314f1ba04899a2464737cd
64d0713b0ddc4d18aad77688cecbcc3f--ce69b5789c314f1ba04899a2464737cd
c310fb82832a46bdb0b1409de7c4b21e
2aaee117e08a4fa9884c3a8bf99a50f5
ce69b5789c314f1ba04899a2464737cd--2aaee117e08a4fa9884c3a8bf99a50f5
6ce30b714b3f43678fe382ce2c38a71d
c310fb82832a46bdb0b1409de7c4b21e--6ce30b714b3f43678fe382ce2c38a71d
5cff159ea9b3431d887d5057604e2417
14fb6690414d43beaf373218b8f99da9
8f4e3cd724ad47b9a90d0f3d6ec42fd4--14fb6690414d43beaf373218b8f99da9
7ff40b466a4a4214824e1e919b585bc0
2
14fb6690414d43beaf373218b8f99da9--64d0713b0ddc4d18aad77688cecbcc3f
0396969e232e426284e2b009acf88c51
9c62f97b9ae747f38dfc2a36cad4b13b--0396969e232e426284e2b009acf88c51
9ab4f98abbee4fc4b7ba60ea5ada3ea9
0396969e232e426284e2b009acf88c51--9ab4f98abbee4fc4b7ba60ea5ada3ea9
9ab4f98abbee4fc4b7ba60ea5ada3ea9--5cff159ea9b3431d887d5057604e2417
ba799220abc3433ea6021f8b0ba73004
390d2324b5164957b3d722e8be264824
7ff40b466a4a4214824e1e919b585bc0--390d2324b5164957b3d722e8be264824
9d12ebc22a45419192a3c14bc0e36202
3
106428dadb16411c89d424e1e474d94f
390d2324b5164957b3d722e8be264824--106428dadb16411c89d424e1e474d94f
8168183ae3864c18b904aac05417b2b1
106428dadb16411c89d424e1e474d94f--8168183ae3864c18b904aac05417b2b1
819958cfe6b3440786c63e26aadf47f8
8168183ae3864c18b904aac05417b2b1--819958cfe6b3440786c63e26aadf47f8
819958cfe6b3440786c63e26aadf47f8--ba799220abc3433ea6021f8b0ba73004
337949b6a9d3489c8f62cec518c9479d
db473e14d1214b42b556fcb06432c280
9d12ebc22a45419192a3c14bc0e36202--db473e14d1214b42b556fcb06432c280
eac22a124d5d4a55bd9c03d284403dec
db473e14d1214b42b556fcb06432c280--eac22a124d5d4a55bd9c03d284403dec
b4e2829e413d4a18b1453a1b533a869d
eac22a124d5d4a55bd9c03d284403dec--b4e2829e413d4a18b1453a1b533a869d
b4e2829e413d4a18b1453a1b533a869d--c310fb82832a46bdb0b1409de7c4b21e
2aaee117e08a4fa9884c3a8bf99a50f5--337949b6a9d3489c8f62cec518c9479d
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
c9ed1fb306554c398e962dea1d913c6d
0
38b0ec2416ca42d29a36332a47ae418a
c9ed1fb306554c398e962dea1d913c6d--38b0ec2416ca42d29a36332a47ae418a
94dcd5313cf14884956765144f347ef1
1
46c269f29eed4e1db0a902e3606b793f
38b0ec2416ca42d29a36332a47ae418a--46c269f29eed4e1db0a902e3606b793f
703f5957890d44a6978c8316c52d90d0
46c269f29eed4e1db0a902e3606b793f--703f5957890d44a6978c8316c52d90d0
691ba7ad6e0a499e8c9387e551175d6f
703f5957890d44a6978c8316c52d90d0--691ba7ad6e0a499e8c9387e551175d6f
cff5f819664a46beb1fb63bdf8f1a238
b1a1dddf241f46af9e37757bfa8325ac
PHASE(0.5)
94dcd5313cf14884956765144f347ef1--b1a1dddf241f46af9e37757bfa8325ac
e54465c53c254573aff12b562d6ba547
2
b1a1dddf241f46af9e37757bfa8325ac--38b0ec2416ca42d29a36332a47ae418a
d83f9791920a4e9a8b0a3cfdf575b91c
b1a1dddf241f46af9e37757bfa8325ac--d83f9791920a4e9a8b0a3cfdf575b91c
9507734916714217bd107ac74e1453e8
d83f9791920a4e9a8b0a3cfdf575b91c--9507734916714217bd107ac74e1453e8
9507734916714217bd107ac74e1453e8--cff5f819664a46beb1fb63bdf8f1a238
14a9fac5cdd248bfa19854320d6b76b7
658faf84d588420cadedb17c43a07afa
e54465c53c254573aff12b562d6ba547--658faf84d588420cadedb17c43a07afa
f17fdfd4b8d04fd5a299bd1087eb0aa6
3
e9b4ed01ceef4675b5dfcee61c050082
PHASE(0.5)
658faf84d588420cadedb17c43a07afa--e9b4ed01ceef4675b5dfcee61c050082
e9b4ed01ceef4675b5dfcee61c050082--46c269f29eed4e1db0a902e3606b793f
cd5be69409f54cd6b9d4039eb340104b
e9b4ed01ceef4675b5dfcee61c050082--cd5be69409f54cd6b9d4039eb340104b
cd5be69409f54cd6b9d4039eb340104b--14a9fac5cdd248bfa19854320d6b76b7
7abf396465ef4c9b9cc00374d7a267b6
e129c3bbe382423084649bf06d8bd0ac
f17fdfd4b8d04fd5a299bd1087eb0aa6--e129c3bbe382423084649bf06d8bd0ac
9c056be35be54417a96fcb11863c9b94
e129c3bbe382423084649bf06d8bd0ac--9c056be35be54417a96fcb11863c9b94
49f2ffeb23744e6ca962444c102b8183
PHASE(0.5)
9c056be35be54417a96fcb11863c9b94--49f2ffeb23744e6ca962444c102b8183
49f2ffeb23744e6ca962444c102b8183--703f5957890d44a6978c8316c52d90d0
49f2ffeb23744e6ca962444c102b8183--7abf396465ef4c9b9cc00374d7a267b6
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