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
21f50c39b60748919f84df9961100dde
0
c95dfade2f6f417dbba09d240104abf3
X
21f50c39b60748919f84df9961100dde--c95dfade2f6f417dbba09d240104abf3
b5a31f4195e4485c8467d9bcf5944f74
1
8bc86726b8414a60afe964cbe9b21e62
c95dfade2f6f417dbba09d240104abf3--8bc86726b8414a60afe964cbe9b21e62
bb12106363cc4d2cafa28cdf15a95ec1
f15a38c330bf436bb597d80b3516b164
Y
b5a31f4195e4485c8467d9bcf5944f74--f15a38c330bf436bb597d80b3516b164
f15a38c330bf436bb597d80b3516b164--bb12106363cc4d2cafa28cdf15a95ec1
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
67dff4a9b1da42e09d0487afa97f93d8
0
934148860e35411dbcebfd184a664ade
X
67dff4a9b1da42e09d0487afa97f93d8--934148860e35411dbcebfd184a664ade
906a8c3ed57c46f9a5e4187fcd0d0d93
Y
934148860e35411dbcebfd184a664ade--906a8c3ed57c46f9a5e4187fcd0d0d93
4eb47d49e8624e27b82fc923f116c74e
906a8c3ed57c46f9a5e4187fcd0d0d93--4eb47d49e8624e27b82fc923f116c74e
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
a9b0edc5eb02413eaa968354fc1f027a
0
5b30a2b7aaff4edc85535f231c44c1b5
X
a9b0edc5eb02413eaa968354fc1f027a--5b30a2b7aaff4edc85535f231c44c1b5
5052166403ca42d893bc98040bd78ae1
1
34a932e5f28242a3b06db75fad51a641
5b30a2b7aaff4edc85535f231c44c1b5--34a932e5f28242a3b06db75fad51a641
5795817bcc194bbbae78a3b95d7152e8
34a932e5f28242a3b06db75fad51a641--5795817bcc194bbbae78a3b95d7152e8
f03fc7a924dd4b098877250d10756d7f
9a86ca5138bb4f039f5d7d5f5aaf81e7
5052166403ca42d893bc98040bd78ae1--9a86ca5138bb4f039f5d7d5f5aaf81e7
cda64fba18d74a1c928d58c342f7054e
Y
9a86ca5138bb4f039f5d7d5f5aaf81e7--cda64fba18d74a1c928d58c342f7054e
cda64fba18d74a1c928d58c342f7054e--f03fc7a924dd4b098877250d10756d7f
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_754502922c164035bf624af6fdfac8cf
a6d1694092d24794bd3e5d143ef26f29
0
c1631c85999c44879ba11aa91b74cef6
a6d1694092d24794bd3e5d143ef26f29--c1631c85999c44879ba11aa91b74cef6
2399bda3bf4244d0aeb5d05eeac97e86
1
583c8c80153147adb500c5f1d53037bb
c1631c85999c44879ba11aa91b74cef6--583c8c80153147adb500c5f1d53037bb
13cf688a303d459e98ed6c49c587f4bc
78e173d3732d44338cdfe7cde72395f0
AddBlock
2399bda3bf4244d0aeb5d05eeac97e86--78e173d3732d44338cdfe7cde72395f0
35777ed4f9ce4559a65c73c0c7ddee42
2
78e173d3732d44338cdfe7cde72395f0--13cf688a303d459e98ed6c49c587f4bc
cc7d1b0174b74ee4a0efbb49a6319902
713f217e5971456f987e0750aa720d26
35777ed4f9ce4559a65c73c0c7ddee42--713f217e5971456f987e0750aa720d26
713f217e5971456f987e0750aa720d26--cc7d1b0174b74ee4a0efbb49a6319902
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_f5faadb81b374613996d04863e8b8f99
cluster_0c23d36e0ede45b39dac57aef435440b
rx
ff5ca9d84c084b67990c4818c4db5a80
0
71a1366af90941819dfefd8853a21718
X
ff5ca9d84c084b67990c4818c4db5a80--71a1366af90941819dfefd8853a21718
45dc2cba98764d91b2d0ff9a077cac39
1
a012174d74e54108b293d7fb4c1a240f
71a1366af90941819dfefd8853a21718--a012174d74e54108b293d7fb4c1a240f
c723bd6c216f4e86bcffdb2e527af86c
a012174d74e54108b293d7fb4c1a240f--c723bd6c216f4e86bcffdb2e527af86c
076017f47fda487b808a8fe414114f4d
c723bd6c216f4e86bcffdb2e527af86c--076017f47fda487b808a8fe414114f4d
a411f082bd2b49f3b12a8f4cf4d4029a
d51b0c9579ab4b3cb136f3f3d045f981
Y
45dc2cba98764d91b2d0ff9a077cac39--d51b0c9579ab4b3cb136f3f3d045f981
b98e04737a9b456babc339697d017d93
2
28cf48203c174280b663bfcaf1b6290b
d51b0c9579ab4b3cb136f3f3d045f981--28cf48203c174280b663bfcaf1b6290b
a8587c74aa784b849c95ba61f786f096
HamEvo
28cf48203c174280b663bfcaf1b6290b--a8587c74aa784b849c95ba61f786f096
a8587c74aa784b849c95ba61f786f096--a411f082bd2b49f3b12a8f4cf4d4029a
4e1b669a70b24c0183b0eb84fae6eaf0
87501d68125e4bf88fc362728bc45dd8
RX(x)
b98e04737a9b456babc339697d017d93--87501d68125e4bf88fc362728bc45dd8
d9c7d1d0cae7480fb3e5ecc43aa0cbcf
3
f8c37c0eb2934a7ca8c6697e95a7f0b1
87501d68125e4bf88fc362728bc45dd8--f8c37c0eb2934a7ca8c6697e95a7f0b1
4a0382f41016414f82b761d0763126eb
t = 10
f8c37c0eb2934a7ca8c6697e95a7f0b1--4a0382f41016414f82b761d0763126eb
4a0382f41016414f82b761d0763126eb--4e1b669a70b24c0183b0eb84fae6eaf0
3c09a369f1ad4bcdb03caa8c59325863
c5fd34122b8f45a5ae58636d49f39054
RX(0.5)
d9c7d1d0cae7480fb3e5ecc43aa0cbcf--c5fd34122b8f45a5ae58636d49f39054
c6e33b9608a84c1f864065461f8f0f5d
X
c5fd34122b8f45a5ae58636d49f39054--c6e33b9608a84c1f864065461f8f0f5d
c6e33b9608a84c1f864065461f8f0f5d--f8c37c0eb2934a7ca8c6697e95a7f0b1
6a9b260c116345da9f3d5415c9dbbf95
c6e33b9608a84c1f864065461f8f0f5d--6a9b260c116345da9f3d5415c9dbbf95
6a9b260c116345da9f3d5415c9dbbf95--3c09a369f1ad4bcdb03caa8c59325863
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_c518a45ef31644ee8ef1bec81b3df2da
HEA
cluster_1871d20634d94551b71d0cda7e1dfafb
Tower Fourier FM
b1c81387933e414183e7ee203c3eb79e
0
4afae8197b184e718b4307dfb1b5659b
RX(1.0*phi)
b1c81387933e414183e7ee203c3eb79e--4afae8197b184e718b4307dfb1b5659b
e0ab402173d143d195a3d36ed7ef4553
1
4a8ae88343034e92ab526565d41bff37
RX(theta₀)
4afae8197b184e718b4307dfb1b5659b--4a8ae88343034e92ab526565d41bff37
a5d39b299cfc49a8903a65c9d86d9c78
RY(theta₄)
4a8ae88343034e92ab526565d41bff37--a5d39b299cfc49a8903a65c9d86d9c78
907ec5b832f84e41949ccc8fca7cf139
RX(theta₈)
a5d39b299cfc49a8903a65c9d86d9c78--907ec5b832f84e41949ccc8fca7cf139
b88ed76fdc264c2bab2ceefc2ffc6654
907ec5b832f84e41949ccc8fca7cf139--b88ed76fdc264c2bab2ceefc2ffc6654
45b33214ac074071b3f22f8cf3a9f507
b88ed76fdc264c2bab2ceefc2ffc6654--45b33214ac074071b3f22f8cf3a9f507
de8ac35d9d10405a82192878ce057b52
RX(theta₁₂)
45b33214ac074071b3f22f8cf3a9f507--de8ac35d9d10405a82192878ce057b52
2dee006cd3074b709ae74b056aa86cc2
RY(theta₁₆)
de8ac35d9d10405a82192878ce057b52--2dee006cd3074b709ae74b056aa86cc2
09e3d27c7a964a0cb030e6dc131b0094
RX(theta₂₀)
2dee006cd3074b709ae74b056aa86cc2--09e3d27c7a964a0cb030e6dc131b0094
59b7997a1c6546839d0ed55d032e78d5
09e3d27c7a964a0cb030e6dc131b0094--59b7997a1c6546839d0ed55d032e78d5
a34cd76a937a4db38bc0818833862e4e
59b7997a1c6546839d0ed55d032e78d5--a34cd76a937a4db38bc0818833862e4e
705ac507f5774595ad7369de1b29f998
a34cd76a937a4db38bc0818833862e4e--705ac507f5774595ad7369de1b29f998
54cf6d4706374e069f6958b008d60761
4792e2190c2f41188b44d75e75a46153
RX(2.0*phi)
e0ab402173d143d195a3d36ed7ef4553--4792e2190c2f41188b44d75e75a46153
6db7a706a00044dbb8bdc8ebdb1c7e9f
2
b0d715b8cc96477ca108ddccf80c9def
RX(theta₁)
4792e2190c2f41188b44d75e75a46153--b0d715b8cc96477ca108ddccf80c9def
f61349f518cf4aadb37bc5378de16883
RY(theta₅)
b0d715b8cc96477ca108ddccf80c9def--f61349f518cf4aadb37bc5378de16883
4a65698dba784868bb9293d0a3c12f48
RX(theta₉)
f61349f518cf4aadb37bc5378de16883--4a65698dba784868bb9293d0a3c12f48
9c349078c312445dbce8a701cfd106ef
X
4a65698dba784868bb9293d0a3c12f48--9c349078c312445dbce8a701cfd106ef
9c349078c312445dbce8a701cfd106ef--b88ed76fdc264c2bab2ceefc2ffc6654
f5a336f5388445298bb8d1d730cfb330
9c349078c312445dbce8a701cfd106ef--f5a336f5388445298bb8d1d730cfb330
a4605871399f4b0e80f9c4bc54605c9b
RX(theta₁₃)
f5a336f5388445298bb8d1d730cfb330--a4605871399f4b0e80f9c4bc54605c9b
05c8260bd90346f3b4a1327cdd4636ce
RY(theta₁₇)
a4605871399f4b0e80f9c4bc54605c9b--05c8260bd90346f3b4a1327cdd4636ce
cb07a9f4d5084378b8a11e31279ea3d3
RX(theta₂₁)
05c8260bd90346f3b4a1327cdd4636ce--cb07a9f4d5084378b8a11e31279ea3d3
a91949d33fcd474da898592e50997885
X
cb07a9f4d5084378b8a11e31279ea3d3--a91949d33fcd474da898592e50997885
a91949d33fcd474da898592e50997885--59b7997a1c6546839d0ed55d032e78d5
c2c888d989414346a5b0c1cdd6b1c769
a91949d33fcd474da898592e50997885--c2c888d989414346a5b0c1cdd6b1c769
c2c888d989414346a5b0c1cdd6b1c769--54cf6d4706374e069f6958b008d60761
b39721cd24e6457c96fcfe5892bdc761
7dd39d43a9914ee1ab75cac998bcf30c
RX(3.0*phi)
6db7a706a00044dbb8bdc8ebdb1c7e9f--7dd39d43a9914ee1ab75cac998bcf30c
05108a0759204522be0a2d64530098bf
3
952a708df05f489daf41aa343705d423
RX(theta₂)
7dd39d43a9914ee1ab75cac998bcf30c--952a708df05f489daf41aa343705d423
0163b3472cd04a68a2a1c4e949678f12
RY(theta₆)
952a708df05f489daf41aa343705d423--0163b3472cd04a68a2a1c4e949678f12
da4ffa3118844708b92fabefbbb2a16d
RX(theta₁₀)
0163b3472cd04a68a2a1c4e949678f12--da4ffa3118844708b92fabefbbb2a16d
bd18bb45882c4f42bb1f5d90fad73f73
da4ffa3118844708b92fabefbbb2a16d--bd18bb45882c4f42bb1f5d90fad73f73
1bfaca61539c449bae1708d584d81616
X
bd18bb45882c4f42bb1f5d90fad73f73--1bfaca61539c449bae1708d584d81616
1bfaca61539c449bae1708d584d81616--f5a336f5388445298bb8d1d730cfb330
14860c740785460b859bcfc37e260c3b
RX(theta₁₄)
1bfaca61539c449bae1708d584d81616--14860c740785460b859bcfc37e260c3b
bb088340dc234d0cabcefa95d8aae1d0
RY(theta₁₈)
14860c740785460b859bcfc37e260c3b--bb088340dc234d0cabcefa95d8aae1d0
47b07a3222404e5c8562e4501e2f9962
RX(theta₂₂)
bb088340dc234d0cabcefa95d8aae1d0--47b07a3222404e5c8562e4501e2f9962
3ac0dc3870e24a7fad76ad4f74f242a1
47b07a3222404e5c8562e4501e2f9962--3ac0dc3870e24a7fad76ad4f74f242a1
871d13e558734ad6b8f85448ee5e5645
X
3ac0dc3870e24a7fad76ad4f74f242a1--871d13e558734ad6b8f85448ee5e5645
871d13e558734ad6b8f85448ee5e5645--c2c888d989414346a5b0c1cdd6b1c769
871d13e558734ad6b8f85448ee5e5645--b39721cd24e6457c96fcfe5892bdc761
5ce2149b33704beaa4c9209082837a0a
ba815222a30c4cd0b55917d8ee366532
RX(4.0*phi)
05108a0759204522be0a2d64530098bf--ba815222a30c4cd0b55917d8ee366532
44c5edeeb0194ac2b50c0476530df0e2
RX(theta₃)
ba815222a30c4cd0b55917d8ee366532--44c5edeeb0194ac2b50c0476530df0e2
d79d2370b27f4e7698f0164618fb7d0d
RY(theta₇)
44c5edeeb0194ac2b50c0476530df0e2--d79d2370b27f4e7698f0164618fb7d0d
55b8a41a9eed44189db47109f71c4c86
RX(theta₁₁)
d79d2370b27f4e7698f0164618fb7d0d--55b8a41a9eed44189db47109f71c4c86
0b7dec3cc3874c57b84f079bba8a2f7d
X
55b8a41a9eed44189db47109f71c4c86--0b7dec3cc3874c57b84f079bba8a2f7d
0b7dec3cc3874c57b84f079bba8a2f7d--bd18bb45882c4f42bb1f5d90fad73f73
66926c2f48544cdcaf8770e598bf82d2
0b7dec3cc3874c57b84f079bba8a2f7d--66926c2f48544cdcaf8770e598bf82d2
ee367222b741461a8edd5712cb36fd6f
RX(theta₁₅)
66926c2f48544cdcaf8770e598bf82d2--ee367222b741461a8edd5712cb36fd6f
70eb9bafe890440d80be167dc5b0712c
RY(theta₁₉)
ee367222b741461a8edd5712cb36fd6f--70eb9bafe890440d80be167dc5b0712c
08b819e8610e41e08d373b138cd73326
RX(theta₂₃)
70eb9bafe890440d80be167dc5b0712c--08b819e8610e41e08d373b138cd73326
b932aba988c0453a9b182f9e0ee85b3a
X
08b819e8610e41e08d373b138cd73326--b932aba988c0453a9b182f9e0ee85b3a
b932aba988c0453a9b182f9e0ee85b3a--3ac0dc3870e24a7fad76ad4f74f242a1
3c5178d7a62d4a289b384c48ba972fd6
b932aba988c0453a9b182f9e0ee85b3a--3c5178d7a62d4a289b384c48ba972fd6
3c5178d7a62d4a289b384c48ba972fd6--5ce2149b33704beaa4c9209082837a0a
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_51a317e75ebc44068287e79298aa62a1
Obs.
cluster_6cbd65e1945247dd8b47c718ba0a73b8
cluster_2b4388aa144b4c38914636ab76973e87
HEA
d467bc16f254409d9c2b53d3aa085f33
0
4c4778f47fed46d580603b813d6e92b3
RX(theta₀)
d467bc16f254409d9c2b53d3aa085f33--4c4778f47fed46d580603b813d6e92b3
2fd7cee97b314d7bbbc3b2c648a0c575
1
f12079da92404686a15a64435f099887
RY(theta₃)
4c4778f47fed46d580603b813d6e92b3--f12079da92404686a15a64435f099887
8c2cd970a33d4862867abc9ce45a0f39
RX(theta₆)
f12079da92404686a15a64435f099887--8c2cd970a33d4862867abc9ce45a0f39
ace39e075293405fb16b5d95626d17a9
8c2cd970a33d4862867abc9ce45a0f39--ace39e075293405fb16b5d95626d17a9
6b8721fce24043d9aeb98302e488d36b
ace39e075293405fb16b5d95626d17a9--6b8721fce24043d9aeb98302e488d36b
ef0f030f0c744d578419c4c3e71da2dd
RX(theta₉)
6b8721fce24043d9aeb98302e488d36b--ef0f030f0c744d578419c4c3e71da2dd
9ee915c05b6d4c63b308ddfb7ae0761e
RY(theta₁₂)
ef0f030f0c744d578419c4c3e71da2dd--9ee915c05b6d4c63b308ddfb7ae0761e
6238ca9be5904e53b16101c035620c15
RX(theta₁₅)
9ee915c05b6d4c63b308ddfb7ae0761e--6238ca9be5904e53b16101c035620c15
84213c74d23a4cb0b034789162e03db1
6238ca9be5904e53b16101c035620c15--84213c74d23a4cb0b034789162e03db1
e86ca6c77ed44966abc1640a948a4537
84213c74d23a4cb0b034789162e03db1--e86ca6c77ed44966abc1640a948a4537
07ad517888514b21b6a2b0152043e0d9
e86ca6c77ed44966abc1640a948a4537--07ad517888514b21b6a2b0152043e0d9
57498adb881741a88baaaf88bd9d0371
07ad517888514b21b6a2b0152043e0d9--57498adb881741a88baaaf88bd9d0371
763a036eafbb43408d81543bad54b566
0ca68004c35347ffbd8bb8034946cdf6
RX(theta₁)
2fd7cee97b314d7bbbc3b2c648a0c575--0ca68004c35347ffbd8bb8034946cdf6
9833d2424991404681f3afa33ecf6d2d
2
f1a7e4cfb0c345dfa4899f741bfdeb73
RY(theta₄)
0ca68004c35347ffbd8bb8034946cdf6--f1a7e4cfb0c345dfa4899f741bfdeb73
438a423b2ffe4d2e86f48e3de19e11f6
RX(theta₇)
f1a7e4cfb0c345dfa4899f741bfdeb73--438a423b2ffe4d2e86f48e3de19e11f6
cb6fba63f01746b9b8aa80cf35a7b486
X
438a423b2ffe4d2e86f48e3de19e11f6--cb6fba63f01746b9b8aa80cf35a7b486
cb6fba63f01746b9b8aa80cf35a7b486--ace39e075293405fb16b5d95626d17a9
e2d80eb6f1ca4ff2898728661bae4b66
cb6fba63f01746b9b8aa80cf35a7b486--e2d80eb6f1ca4ff2898728661bae4b66
b191190a8919416280b0b3eaa3ef8289
RX(theta₁₀)
e2d80eb6f1ca4ff2898728661bae4b66--b191190a8919416280b0b3eaa3ef8289
97bd6164d72d44178e8432289c9e1c65
RY(theta₁₃)
b191190a8919416280b0b3eaa3ef8289--97bd6164d72d44178e8432289c9e1c65
5ebbe154205344859f1ab4bdb99e4967
RX(theta₁₆)
97bd6164d72d44178e8432289c9e1c65--5ebbe154205344859f1ab4bdb99e4967
e077056ec11b49bca57b05d552522473
X
5ebbe154205344859f1ab4bdb99e4967--e077056ec11b49bca57b05d552522473
e077056ec11b49bca57b05d552522473--84213c74d23a4cb0b034789162e03db1
f77418a120b247589eab27dd5659dd06
e077056ec11b49bca57b05d552522473--f77418a120b247589eab27dd5659dd06
43762e4ceb4a498daa7af46ac5fc6a8d
AddBlock
f77418a120b247589eab27dd5659dd06--43762e4ceb4a498daa7af46ac5fc6a8d
43762e4ceb4a498daa7af46ac5fc6a8d--763a036eafbb43408d81543bad54b566
eeb67e1601614b009922676de4a79ae5
bbf5a415cced449694011857720b007c
RX(theta₂)
9833d2424991404681f3afa33ecf6d2d--bbf5a415cced449694011857720b007c
01a502cd12ff43999ed6edec7d170221
RY(theta₅)
bbf5a415cced449694011857720b007c--01a502cd12ff43999ed6edec7d170221
e7394de036aa42ef87ff2f20903149d4
RX(theta₈)
01a502cd12ff43999ed6edec7d170221--e7394de036aa42ef87ff2f20903149d4
0b834c753dc149898d0415c6db359061
e7394de036aa42ef87ff2f20903149d4--0b834c753dc149898d0415c6db359061
9cf15a3636d4492da90ccd60d6b68c02
X
0b834c753dc149898d0415c6db359061--9cf15a3636d4492da90ccd60d6b68c02
9cf15a3636d4492da90ccd60d6b68c02--e2d80eb6f1ca4ff2898728661bae4b66
fb3277c5767941b9ba57fd077a8ceca9
RX(theta₁₁)
9cf15a3636d4492da90ccd60d6b68c02--fb3277c5767941b9ba57fd077a8ceca9
136b4e7c830949bdbd48db32f7b3ac44
RY(theta₁₄)
fb3277c5767941b9ba57fd077a8ceca9--136b4e7c830949bdbd48db32f7b3ac44
cfc6c6191a024ad7b15c950ba4ddc4cd
RX(theta₁₇)
136b4e7c830949bdbd48db32f7b3ac44--cfc6c6191a024ad7b15c950ba4ddc4cd
1873a18d3257474d99b8c1252dd83b83
cfc6c6191a024ad7b15c950ba4ddc4cd--1873a18d3257474d99b8c1252dd83b83
f2f4d5ddf32f4ec7be9ef4aa2b218efd
X
1873a18d3257474d99b8c1252dd83b83--f2f4d5ddf32f4ec7be9ef4aa2b218efd
f2f4d5ddf32f4ec7be9ef4aa2b218efd--f77418a120b247589eab27dd5659dd06
8c6463ccea394e2fbe8e4002d221adba
f2f4d5ddf32f4ec7be9ef4aa2b218efd--8c6463ccea394e2fbe8e4002d221adba
8c6463ccea394e2fbe8e4002d221adba--eeb67e1601614b009922676de4a79ae5
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
14875bf5e9494e20bd2aab5a41b45207
0
7468bc71a4a84654afeea9d7bad7e7db
14875bf5e9494e20bd2aab5a41b45207--7468bc71a4a84654afeea9d7bad7e7db
709163f13c7844efaedafcb699067f86
1
9146b8cb5fc14f6dae5ac739aa67fd94
315cb5f1c26145be97f36e8e14a4893c
7468bc71a4a84654afeea9d7bad7e7db--315cb5f1c26145be97f36e8e14a4893c
2a34c6bf8f914352946d186edb0db23d
9146b8cb5fc14f6dae5ac739aa67fd94--2a34c6bf8f914352946d186edb0db23d
d639d0ad1459413fb664c76332835b7f
febf0ea7641d4fba939d5985d830eb2c
2a34c6bf8f914352946d186edb0db23d--febf0ea7641d4fba939d5985d830eb2c
d1a8821ad42e435fadba41200c36cf8d
d639d0ad1459413fb664c76332835b7f--d1a8821ad42e435fadba41200c36cf8d
a3f387a17e244dd49bcdd5a91b4eff62
d398c9b4325b4528809b5293c0d3b9b7
709163f13c7844efaedafcb699067f86--d398c9b4325b4528809b5293c0d3b9b7
b57fbdcf37f749af8e544f727ff0e3ad
2
d398c9b4325b4528809b5293c0d3b9b7--9146b8cb5fc14f6dae5ac739aa67fd94
29e376c151ee449594d5a06f7cd76dcd
315cb5f1c26145be97f36e8e14a4893c--29e376c151ee449594d5a06f7cd76dcd
75a9c6254c804f928556e4a7720bbcc1
29e376c151ee449594d5a06f7cd76dcd--75a9c6254c804f928556e4a7720bbcc1
75a9c6254c804f928556e4a7720bbcc1--a3f387a17e244dd49bcdd5a91b4eff62
b1cea723bd4b4e5c9668107745789ca9
ecf518c39f8a4e6bb54b46dd2ff2499d
b57fbdcf37f749af8e544f727ff0e3ad--ecf518c39f8a4e6bb54b46dd2ff2499d
ea4a52de89124f749c89274b92327972
3
db8ba0a53e884ce5bd6d9da0018b7ede
ecf518c39f8a4e6bb54b46dd2ff2499d--db8ba0a53e884ce5bd6d9da0018b7ede
e84304e747704bafb48d2e93f584a3be
db8ba0a53e884ce5bd6d9da0018b7ede--e84304e747704bafb48d2e93f584a3be
57befc3eb9eb47aa9aaa1e392fe61113
e84304e747704bafb48d2e93f584a3be--57befc3eb9eb47aa9aaa1e392fe61113
57befc3eb9eb47aa9aaa1e392fe61113--b1cea723bd4b4e5c9668107745789ca9
4fc79c6fb89b4dddbe1024c7d5075ef9
e7d361229d5c4e7d95cfe2b6c4aced20
ea4a52de89124f749c89274b92327972--e7d361229d5c4e7d95cfe2b6c4aced20
c773b22faa6c435aa1ccc2a0bdc9dedc
e7d361229d5c4e7d95cfe2b6c4aced20--c773b22faa6c435aa1ccc2a0bdc9dedc
4604b5fd4224402ba204adce15ced842
c773b22faa6c435aa1ccc2a0bdc9dedc--4604b5fd4224402ba204adce15ced842
4604b5fd4224402ba204adce15ced842--d639d0ad1459413fb664c76332835b7f
febf0ea7641d4fba939d5985d830eb2c--4fc79c6fb89b4dddbe1024c7d5075ef9
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
7edf7b3639a74656a2ec50ef9d2dd4fc
0
edf6a13be29441ff888ccde5030ead32
7edf7b3639a74656a2ec50ef9d2dd4fc--edf6a13be29441ff888ccde5030ead32
5ae4d96401e843378d07da133943367c
1
f2e270d4332a4d899e37a69ef82c13af
edf6a13be29441ff888ccde5030ead32--f2e270d4332a4d899e37a69ef82c13af
3e794fe7dac44d05bca975075aadad83
f2e270d4332a4d899e37a69ef82c13af--3e794fe7dac44d05bca975075aadad83
ed30b5f759e7458bb65620e625c3fa29
3e794fe7dac44d05bca975075aadad83--ed30b5f759e7458bb65620e625c3fa29
93bbdab239b44777b9d7336a899522d4
eb3c438ccfe84a0db48a24b86d476518
PHASE(0.5)
5ae4d96401e843378d07da133943367c--eb3c438ccfe84a0db48a24b86d476518
6a68192bec6048b0a6ea394e19ee82a6
2
eb3c438ccfe84a0db48a24b86d476518--edf6a13be29441ff888ccde5030ead32
a514da35e716432982988bb8518166b9
eb3c438ccfe84a0db48a24b86d476518--a514da35e716432982988bb8518166b9
4fe6bfdc46414eb2a959d3def39b632a
a514da35e716432982988bb8518166b9--4fe6bfdc46414eb2a959d3def39b632a
4fe6bfdc46414eb2a959d3def39b632a--93bbdab239b44777b9d7336a899522d4
ec9bd9e8135a4f4eb130f2daf48cbe98
5d199b2065344ee18c4b0e8a42ed1c02
6a68192bec6048b0a6ea394e19ee82a6--5d199b2065344ee18c4b0e8a42ed1c02
a44aeae174cf4b6d95c4179d90e72da3
3
feca53033fe54de385d119017933740c
PHASE(0.5)
5d199b2065344ee18c4b0e8a42ed1c02--feca53033fe54de385d119017933740c
feca53033fe54de385d119017933740c--f2e270d4332a4d899e37a69ef82c13af
09703874f90a4fbd88702e26c3bfe606
feca53033fe54de385d119017933740c--09703874f90a4fbd88702e26c3bfe606
09703874f90a4fbd88702e26c3bfe606--ec9bd9e8135a4f4eb130f2daf48cbe98
7855c3d209574cefb145ee4b6ef670b6
7c8cde33c19a4391aa8788412502cac1
a44aeae174cf4b6d95c4179d90e72da3--7c8cde33c19a4391aa8788412502cac1
ed7df4b292b243998c5b451662f7b0cb
7c8cde33c19a4391aa8788412502cac1--ed7df4b292b243998c5b451662f7b0cb
c27af9caabdd403e898f140010eb2799
PHASE(0.5)
ed7df4b292b243998c5b451662f7b0cb--c27af9caabdd403e898f140010eb2799
c27af9caabdd403e898f140010eb2799--3e794fe7dac44d05bca975075aadad83
c27af9caabdd403e898f140010eb2799--7855c3d209574cefb145ee4b6ef670b6
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