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
972d1fdaa854468bb8718ff867211104
0
d6dc85e32b8242779a04e8c13fb600bd
X
972d1fdaa854468bb8718ff867211104--d6dc85e32b8242779a04e8c13fb600bd
1eae7e7ece6b436c961e942193c9163d
1
5286ce6b6aa64b8fae7264e5fb1f49df
d6dc85e32b8242779a04e8c13fb600bd--5286ce6b6aa64b8fae7264e5fb1f49df
dd5b2aa2fae94e4cbc820e7e777bca96
bd18072cecda47dabed04f8e11cd0908
Y
1eae7e7ece6b436c961e942193c9163d--bd18072cecda47dabed04f8e11cd0908
bd18072cecda47dabed04f8e11cd0908--dd5b2aa2fae94e4cbc820e7e777bca96
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
7e6b747841f74ee4a88eee893945ff8d
0
2bbbf11182574db196c7457a62b10416
X
7e6b747841f74ee4a88eee893945ff8d--2bbbf11182574db196c7457a62b10416
b9270598295f4821a717fdaad76b0898
Y
2bbbf11182574db196c7457a62b10416--b9270598295f4821a717fdaad76b0898
03add37e9be54394a637346eef535bad
b9270598295f4821a717fdaad76b0898--03add37e9be54394a637346eef535bad
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
e63df064465b416a86a4cc00d1e2aef9
0
d3ab9f94eb584def90bcb41e05af4fd7
X
e63df064465b416a86a4cc00d1e2aef9--d3ab9f94eb584def90bcb41e05af4fd7
01703fe99b8c4f32852012db97e9d0c4
1
ce1f4f7aaa594d6e82f1e25db7106ceb
d3ab9f94eb584def90bcb41e05af4fd7--ce1f4f7aaa594d6e82f1e25db7106ceb
18f3aa38f7794bccbe7ff8df075cb5c4
ce1f4f7aaa594d6e82f1e25db7106ceb--18f3aa38f7794bccbe7ff8df075cb5c4
7755acd16ada47928fc36e3367f26aef
84097f99a97f4f81b9ade9bc780beb8a
01703fe99b8c4f32852012db97e9d0c4--84097f99a97f4f81b9ade9bc780beb8a
62d0c283de964f23ab6f6ea0618a1615
Y
84097f99a97f4f81b9ade9bc780beb8a--62d0c283de964f23ab6f6ea0618a1615
62d0c283de964f23ab6f6ea0618a1615--7755acd16ada47928fc36e3367f26aef
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_878e1adecffe49cebf9801a16a1fb3b7
a26d48d24b9a4716a8795acca27f05f4
0
9e6ebedfd7eb4af088a4a0c2aeb58746
a26d48d24b9a4716a8795acca27f05f4--9e6ebedfd7eb4af088a4a0c2aeb58746
9e894d87566540a195a5429eec20142b
1
465e4d8e84354be193ebbb15be90c26c
9e6ebedfd7eb4af088a4a0c2aeb58746--465e4d8e84354be193ebbb15be90c26c
b582b4d4df664c9387d5b59618852de8
9684429138284bbdb3849d9b9c16b383
AddBlock
9e894d87566540a195a5429eec20142b--9684429138284bbdb3849d9b9c16b383
86ce7975bdac489f9776de1592e2152a
2
9684429138284bbdb3849d9b9c16b383--b582b4d4df664c9387d5b59618852de8
f12f40e375954d25aa0f54de59e5dae2
8cb2c45d37264feaa8e0c289778d6b29
86ce7975bdac489f9776de1592e2152a--8cb2c45d37264feaa8e0c289778d6b29
8cb2c45d37264feaa8e0c289778d6b29--f12f40e375954d25aa0f54de59e5dae2
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_1e5d0aab02de46c5822091840a8a5654
cluster_34745e8689ca4aec96ba1ada5c16b4c1
rx
0acf7cd486db467cacde3405ef3c81a4
0
41ad55c3012f43e9a1ab5db39bb0ac70
X
0acf7cd486db467cacde3405ef3c81a4--41ad55c3012f43e9a1ab5db39bb0ac70
5a1490d40e02457abc0255dbaa6721fb
1
5da2875367a942a593d16aa1a33fb4a0
41ad55c3012f43e9a1ab5db39bb0ac70--5da2875367a942a593d16aa1a33fb4a0
19ad74e5653b4c8d8480463c077ecdbb
5da2875367a942a593d16aa1a33fb4a0--19ad74e5653b4c8d8480463c077ecdbb
0b57eaff460a468a8dee89c6d70dd42c
19ad74e5653b4c8d8480463c077ecdbb--0b57eaff460a468a8dee89c6d70dd42c
ae070f900ced4168a5c90a15fd0a0c51
72f27e1d9f484499afaf00c681483db5
Y
5a1490d40e02457abc0255dbaa6721fb--72f27e1d9f484499afaf00c681483db5
ee847bd0ffcc45358a122f4be79e203f
2
aae2d890862f4db5b34fdc4ea1b4e7fe
72f27e1d9f484499afaf00c681483db5--aae2d890862f4db5b34fdc4ea1b4e7fe
b5a133a3327241669ca42ac278b121cf
HamEvo
aae2d890862f4db5b34fdc4ea1b4e7fe--b5a133a3327241669ca42ac278b121cf
b5a133a3327241669ca42ac278b121cf--ae070f900ced4168a5c90a15fd0a0c51
d60ce105e7f640a5be6f61c15903a6c8
f507b4bf0b0745cb8dea542e86c106bc
RX(x)
ee847bd0ffcc45358a122f4be79e203f--f507b4bf0b0745cb8dea542e86c106bc
b313281681484ac7a82b961ad19bf89e
3
1ea0a4c2505b4225afa82a3e46325a66
f507b4bf0b0745cb8dea542e86c106bc--1ea0a4c2505b4225afa82a3e46325a66
901b4759c46f4c1cb9908ec0d1e1e7c5
t = 10
1ea0a4c2505b4225afa82a3e46325a66--901b4759c46f4c1cb9908ec0d1e1e7c5
901b4759c46f4c1cb9908ec0d1e1e7c5--d60ce105e7f640a5be6f61c15903a6c8
ad344e5c0ae745c499381173935b594a
6585b8e487d845fbab79b12f33fb7e5b
RX(0.5)
b313281681484ac7a82b961ad19bf89e--6585b8e487d845fbab79b12f33fb7e5b
b0c159919d76467084409587a9275072
X
6585b8e487d845fbab79b12f33fb7e5b--b0c159919d76467084409587a9275072
b0c159919d76467084409587a9275072--1ea0a4c2505b4225afa82a3e46325a66
801ecf538ed5413fa5c909b2dbce8f24
b0c159919d76467084409587a9275072--801ecf538ed5413fa5c909b2dbce8f24
801ecf538ed5413fa5c909b2dbce8f24--ad344e5c0ae745c499381173935b594a
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_406d09ae4a494190bb35fe77b01c574b
HEA
cluster_2a302f87ac3f486598a6408ffb42968e
Tower Fourier FM
cc7cecc04bf74681937c2f4862881b8e
0
db3b0c6953df415b818e58b03b5e743d
RX(1.0*phi)
cc7cecc04bf74681937c2f4862881b8e--db3b0c6953df415b818e58b03b5e743d
f064d8a90dde4727a7dd8be4c7cd8885
1
840b42d10a464beaaa0bd14dfb7db603
RX(theta₀)
db3b0c6953df415b818e58b03b5e743d--840b42d10a464beaaa0bd14dfb7db603
31f879df684c451cb1602eb012cf9750
RY(theta₄)
840b42d10a464beaaa0bd14dfb7db603--31f879df684c451cb1602eb012cf9750
25f3a181847e496aa848094b2ebf2984
RX(theta₈)
31f879df684c451cb1602eb012cf9750--25f3a181847e496aa848094b2ebf2984
688d42e27270441b802950dfbe8f1c0b
25f3a181847e496aa848094b2ebf2984--688d42e27270441b802950dfbe8f1c0b
b3773517e9b74bc3941e0ad7059e7f2f
688d42e27270441b802950dfbe8f1c0b--b3773517e9b74bc3941e0ad7059e7f2f
c81947212af347aba4af65780bb5df66
RX(theta₁₂)
b3773517e9b74bc3941e0ad7059e7f2f--c81947212af347aba4af65780bb5df66
6617a0e2e7b241e9bf8ac2c94ae52b89
RY(theta₁₆)
c81947212af347aba4af65780bb5df66--6617a0e2e7b241e9bf8ac2c94ae52b89
3164e4aac81d4605a579b68ef59ca4d9
RX(theta₂₀)
6617a0e2e7b241e9bf8ac2c94ae52b89--3164e4aac81d4605a579b68ef59ca4d9
ad302d9ae4b045daa8559440b66a97cf
3164e4aac81d4605a579b68ef59ca4d9--ad302d9ae4b045daa8559440b66a97cf
5c76431ca9dd4c93aaad988847d2de7c
ad302d9ae4b045daa8559440b66a97cf--5c76431ca9dd4c93aaad988847d2de7c
cfa4b4576146446b908873b06c0926da
5c76431ca9dd4c93aaad988847d2de7c--cfa4b4576146446b908873b06c0926da
6afb01b3e37b44ac95ac995d9659ce9e
0e4b5d192b5843ed86a2c71aa0de529b
RX(2.0*phi)
f064d8a90dde4727a7dd8be4c7cd8885--0e4b5d192b5843ed86a2c71aa0de529b
a29b7287c03b4c308c2623b589ef9746
2
f9766916417746e99c702afe1ae298c9
RX(theta₁)
0e4b5d192b5843ed86a2c71aa0de529b--f9766916417746e99c702afe1ae298c9
fa57a367db9e44528d7333df69704265
RY(theta₅)
f9766916417746e99c702afe1ae298c9--fa57a367db9e44528d7333df69704265
0a4a058b8efd4ad081acff26d5f13b58
RX(theta₉)
fa57a367db9e44528d7333df69704265--0a4a058b8efd4ad081acff26d5f13b58
3cb870d55f4b4971bc00072c23c25c22
X
0a4a058b8efd4ad081acff26d5f13b58--3cb870d55f4b4971bc00072c23c25c22
3cb870d55f4b4971bc00072c23c25c22--688d42e27270441b802950dfbe8f1c0b
1eb8cecdaabf4b648851315da392819c
3cb870d55f4b4971bc00072c23c25c22--1eb8cecdaabf4b648851315da392819c
f78c6ffe7d0141c582c720819df97314
RX(theta₁₃)
1eb8cecdaabf4b648851315da392819c--f78c6ffe7d0141c582c720819df97314
d17e12ec249f412e8829b74d634cd208
RY(theta₁₇)
f78c6ffe7d0141c582c720819df97314--d17e12ec249f412e8829b74d634cd208
580affc0159746edb531c829fd3d4d93
RX(theta₂₁)
d17e12ec249f412e8829b74d634cd208--580affc0159746edb531c829fd3d4d93
d2ab1129cc4c4b5eb0b79150b7b13623
X
580affc0159746edb531c829fd3d4d93--d2ab1129cc4c4b5eb0b79150b7b13623
d2ab1129cc4c4b5eb0b79150b7b13623--ad302d9ae4b045daa8559440b66a97cf
2a649a87680c44acb40e0979d3c64ab2
d2ab1129cc4c4b5eb0b79150b7b13623--2a649a87680c44acb40e0979d3c64ab2
2a649a87680c44acb40e0979d3c64ab2--6afb01b3e37b44ac95ac995d9659ce9e
63e5d61005d942abbaf8a32c326f1513
ba954cb3e40f4613938a24352f98d2db
RX(3.0*phi)
a29b7287c03b4c308c2623b589ef9746--ba954cb3e40f4613938a24352f98d2db
e46ee041e6bc4f2ea13f8a22a31fbe00
3
85d585b8b0af47a7956fcced390c00c6
RX(theta₂)
ba954cb3e40f4613938a24352f98d2db--85d585b8b0af47a7956fcced390c00c6
97771aab2e9840daa775c331175e3207
RY(theta₆)
85d585b8b0af47a7956fcced390c00c6--97771aab2e9840daa775c331175e3207
5629741d47db46369755cd2e48fd2f37
RX(theta₁₀)
97771aab2e9840daa775c331175e3207--5629741d47db46369755cd2e48fd2f37
7488e2e8ffe94c1da95f107163225c51
5629741d47db46369755cd2e48fd2f37--7488e2e8ffe94c1da95f107163225c51
06135b7c306d4be99eadfaa7ea6d1599
X
7488e2e8ffe94c1da95f107163225c51--06135b7c306d4be99eadfaa7ea6d1599
06135b7c306d4be99eadfaa7ea6d1599--1eb8cecdaabf4b648851315da392819c
5269e2f5ae6248bcb7998ae94c968110
RX(theta₁₄)
06135b7c306d4be99eadfaa7ea6d1599--5269e2f5ae6248bcb7998ae94c968110
2f7b3e9601904664915eb978ce83f5a4
RY(theta₁₈)
5269e2f5ae6248bcb7998ae94c968110--2f7b3e9601904664915eb978ce83f5a4
d553d3667cd24551958fc827656bf70d
RX(theta₂₂)
2f7b3e9601904664915eb978ce83f5a4--d553d3667cd24551958fc827656bf70d
d07735b42740427ba02517a2624cc5c0
d553d3667cd24551958fc827656bf70d--d07735b42740427ba02517a2624cc5c0
7c784ecf9785404099b9d7d23fe39ee7
X
d07735b42740427ba02517a2624cc5c0--7c784ecf9785404099b9d7d23fe39ee7
7c784ecf9785404099b9d7d23fe39ee7--2a649a87680c44acb40e0979d3c64ab2
7c784ecf9785404099b9d7d23fe39ee7--63e5d61005d942abbaf8a32c326f1513
be21787eb4ad42508554d611386ac552
66c49d0af07d4a50a70d137cfa10e492
RX(4.0*phi)
e46ee041e6bc4f2ea13f8a22a31fbe00--66c49d0af07d4a50a70d137cfa10e492
8756b8c6b64b4d3dbe1e268acc2a2ff6
RX(theta₃)
66c49d0af07d4a50a70d137cfa10e492--8756b8c6b64b4d3dbe1e268acc2a2ff6
3b55efd3760f4141936bd83824ac850c
RY(theta₇)
8756b8c6b64b4d3dbe1e268acc2a2ff6--3b55efd3760f4141936bd83824ac850c
9d89181303b548588231dbce45ea0c23
RX(theta₁₁)
3b55efd3760f4141936bd83824ac850c--9d89181303b548588231dbce45ea0c23
702051d2a5aa42a8a6580455288c8bae
X
9d89181303b548588231dbce45ea0c23--702051d2a5aa42a8a6580455288c8bae
702051d2a5aa42a8a6580455288c8bae--7488e2e8ffe94c1da95f107163225c51
646894277cff41ffbdd9387dff0764db
702051d2a5aa42a8a6580455288c8bae--646894277cff41ffbdd9387dff0764db
92ab7569b6f4450092212174945f38f2
RX(theta₁₅)
646894277cff41ffbdd9387dff0764db--92ab7569b6f4450092212174945f38f2
e84c7a041acd4f9581143427e22b3b71
RY(theta₁₉)
92ab7569b6f4450092212174945f38f2--e84c7a041acd4f9581143427e22b3b71
2e429ad47b5843d28b0e484c60727932
RX(theta₂₃)
e84c7a041acd4f9581143427e22b3b71--2e429ad47b5843d28b0e484c60727932
0ef5577b41f5473aa7db328489231e49
X
2e429ad47b5843d28b0e484c60727932--0ef5577b41f5473aa7db328489231e49
0ef5577b41f5473aa7db328489231e49--d07735b42740427ba02517a2624cc5c0
0526b1f754b64e019bbac61e5b199a98
0ef5577b41f5473aa7db328489231e49--0526b1f754b64e019bbac61e5b199a98
0526b1f754b64e019bbac61e5b199a98--be21787eb4ad42508554d611386ac552
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_d4b75b6d3f424ca99596865fa3303f9f
Obs.
cluster_c7e68c0c5ff3418db0001fa6c3012be4
cluster_17598bb061df4b04ad2a84f8b54b616c
HEA
630b324aecfa4fdebbcfed9186b640c4
0
e9f45add01044203b1d2504a9909387d
RX(theta₀)
630b324aecfa4fdebbcfed9186b640c4--e9f45add01044203b1d2504a9909387d
a387da09d9a343f087cf05e84acfb713
1
cdc33919a2fe4a48a22793dec3cdc57e
RY(theta₃)
e9f45add01044203b1d2504a9909387d--cdc33919a2fe4a48a22793dec3cdc57e
84e3597d3c2d4053ac4097eb72592da7
RX(theta₆)
cdc33919a2fe4a48a22793dec3cdc57e--84e3597d3c2d4053ac4097eb72592da7
8424b597934d473193c899f87f4a6573
84e3597d3c2d4053ac4097eb72592da7--8424b597934d473193c899f87f4a6573
fd3690c2360f4a029aa186c231a7af72
8424b597934d473193c899f87f4a6573--fd3690c2360f4a029aa186c231a7af72
2806b3ba727a47cda0f5eb847cd04909
RX(theta₉)
fd3690c2360f4a029aa186c231a7af72--2806b3ba727a47cda0f5eb847cd04909
c345962dca9b462a98fada0acdeb4dad
RY(theta₁₂)
2806b3ba727a47cda0f5eb847cd04909--c345962dca9b462a98fada0acdeb4dad
6f7d3654ce3640439a16f348c5257d81
RX(theta₁₅)
c345962dca9b462a98fada0acdeb4dad--6f7d3654ce3640439a16f348c5257d81
a9e898abfc8f459db397772af9511b6b
6f7d3654ce3640439a16f348c5257d81--a9e898abfc8f459db397772af9511b6b
9902b5506d7c40f9826ddbc820624a48
a9e898abfc8f459db397772af9511b6b--9902b5506d7c40f9826ddbc820624a48
df128f1e8e77433f8d6460267836f97d
9902b5506d7c40f9826ddbc820624a48--df128f1e8e77433f8d6460267836f97d
4d6aca378c224cc997bc4dcaf747f0bb
df128f1e8e77433f8d6460267836f97d--4d6aca378c224cc997bc4dcaf747f0bb
2fdd602920804dc0b7185f7ad2897299
a873e93d1c7042a9b3350d76b4870d8c
RX(theta₁)
a387da09d9a343f087cf05e84acfb713--a873e93d1c7042a9b3350d76b4870d8c
ab693d17d5e04bbfa3fffdc77cc33aef
2
30b5e42054b94fc692206177f274e14e
RY(theta₄)
a873e93d1c7042a9b3350d76b4870d8c--30b5e42054b94fc692206177f274e14e
f4eaa7ff60a84411be5014d67a83be1d
RX(theta₇)
30b5e42054b94fc692206177f274e14e--f4eaa7ff60a84411be5014d67a83be1d
171c9cb02d4f470a8f5a2739143ad047
X
f4eaa7ff60a84411be5014d67a83be1d--171c9cb02d4f470a8f5a2739143ad047
171c9cb02d4f470a8f5a2739143ad047--8424b597934d473193c899f87f4a6573
b82428e14cce47639351c4aad2984afe
171c9cb02d4f470a8f5a2739143ad047--b82428e14cce47639351c4aad2984afe
c9fc8d8002024b49ae8a9b5f2ef975b3
RX(theta₁₀)
b82428e14cce47639351c4aad2984afe--c9fc8d8002024b49ae8a9b5f2ef975b3
6474f87696084b0fbcd20180c14b3263
RY(theta₁₃)
c9fc8d8002024b49ae8a9b5f2ef975b3--6474f87696084b0fbcd20180c14b3263
6298c42dd1d84d4887d63a3d635e40a4
RX(theta₁₆)
6474f87696084b0fbcd20180c14b3263--6298c42dd1d84d4887d63a3d635e40a4
b4e76b2978a54646b3431a9331b10438
X
6298c42dd1d84d4887d63a3d635e40a4--b4e76b2978a54646b3431a9331b10438
b4e76b2978a54646b3431a9331b10438--a9e898abfc8f459db397772af9511b6b
5e5d8384b2fd4a46aad1b4c162b2835f
b4e76b2978a54646b3431a9331b10438--5e5d8384b2fd4a46aad1b4c162b2835f
6fbf019f144740cfa64bdf5c6167795c
AddBlock
5e5d8384b2fd4a46aad1b4c162b2835f--6fbf019f144740cfa64bdf5c6167795c
6fbf019f144740cfa64bdf5c6167795c--2fdd602920804dc0b7185f7ad2897299
b067c84319994196b574e997a49ed85c
0537e7b67fc74c3f9fcaf09fc4b669c9
RX(theta₂)
ab693d17d5e04bbfa3fffdc77cc33aef--0537e7b67fc74c3f9fcaf09fc4b669c9
df92003c17d8499daa0bb6260b71672d
RY(theta₅)
0537e7b67fc74c3f9fcaf09fc4b669c9--df92003c17d8499daa0bb6260b71672d
b794aed9c248400e90c4d17dfb4f1966
RX(theta₈)
df92003c17d8499daa0bb6260b71672d--b794aed9c248400e90c4d17dfb4f1966
59b4b823327c40f1a51d7c72ce26a2c9
b794aed9c248400e90c4d17dfb4f1966--59b4b823327c40f1a51d7c72ce26a2c9
b75e10abc474440cb42649677900da13
X
59b4b823327c40f1a51d7c72ce26a2c9--b75e10abc474440cb42649677900da13
b75e10abc474440cb42649677900da13--b82428e14cce47639351c4aad2984afe
cd2a1194dd2a4c108e1de2956e5bdc0e
RX(theta₁₁)
b75e10abc474440cb42649677900da13--cd2a1194dd2a4c108e1de2956e5bdc0e
e80289e3e05c4ed7b717e52cf8f32c06
RY(theta₁₄)
cd2a1194dd2a4c108e1de2956e5bdc0e--e80289e3e05c4ed7b717e52cf8f32c06
6ae6cfc9b083473da5ac4da2a5bee9fe
RX(theta₁₇)
e80289e3e05c4ed7b717e52cf8f32c06--6ae6cfc9b083473da5ac4da2a5bee9fe
a1c6707c1d944596949684956bbc5664
6ae6cfc9b083473da5ac4da2a5bee9fe--a1c6707c1d944596949684956bbc5664
5e08e546edac446abc3a5162dc695b5a
X
a1c6707c1d944596949684956bbc5664--5e08e546edac446abc3a5162dc695b5a
5e08e546edac446abc3a5162dc695b5a--5e5d8384b2fd4a46aad1b4c162b2835f
570a1892f9834974b3e54e1118d191cf
5e08e546edac446abc3a5162dc695b5a--570a1892f9834974b3e54e1118d191cf
570a1892f9834974b3e54e1118d191cf--b067c84319994196b574e997a49ed85c
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
0d69ef8b9d774586a91ddcaa17281093
0
c67a996cf3024d4787cecdfd719fe009
0d69ef8b9d774586a91ddcaa17281093--c67a996cf3024d4787cecdfd719fe009
94665d5a1f9e44cdae8d4603cfcc5170
1
22f654d448544d98a1665e8a6c152ee3
85d81d93fb39455e9395bea58810ae09
c67a996cf3024d4787cecdfd719fe009--85d81d93fb39455e9395bea58810ae09
fa05ae68f3784aa0a9b02b7d1f8b31b7
22f654d448544d98a1665e8a6c152ee3--fa05ae68f3784aa0a9b02b7d1f8b31b7
b5098201b29348cda1e524ae8ddb34c4
23e282d675254460ab9c1cf90e032b10
fa05ae68f3784aa0a9b02b7d1f8b31b7--23e282d675254460ab9c1cf90e032b10
db1e5dad2f5641a4ad07c078e276ac3e
b5098201b29348cda1e524ae8ddb34c4--db1e5dad2f5641a4ad07c078e276ac3e
fa13930effbb4742ab34714cb160357c
a939b89df62f4fb4ad5da9d3b34856c6
94665d5a1f9e44cdae8d4603cfcc5170--a939b89df62f4fb4ad5da9d3b34856c6
43c2b4db57144e0486d3b31a0913415e
2
a939b89df62f4fb4ad5da9d3b34856c6--22f654d448544d98a1665e8a6c152ee3
a3399bb75cf442589328c2cb04da66b2
85d81d93fb39455e9395bea58810ae09--a3399bb75cf442589328c2cb04da66b2
6a6950081655460aaeafa888319b52bc
a3399bb75cf442589328c2cb04da66b2--6a6950081655460aaeafa888319b52bc
6a6950081655460aaeafa888319b52bc--fa13930effbb4742ab34714cb160357c
6a5588981c2c4c3faeb8cc8cef1e34b7
30cd3ddaa9de43b3b6828857eb0c1504
43c2b4db57144e0486d3b31a0913415e--30cd3ddaa9de43b3b6828857eb0c1504
ce4827df089840ac879b6707c1c413d4
3
0a3a58f1d5e146d9991e6c810a1f00ba
30cd3ddaa9de43b3b6828857eb0c1504--0a3a58f1d5e146d9991e6c810a1f00ba
3d444ab89bdf43a49bb2f308ea0667e1
0a3a58f1d5e146d9991e6c810a1f00ba--3d444ab89bdf43a49bb2f308ea0667e1
fa0ca324b9e44937b7fce86d151130c3
3d444ab89bdf43a49bb2f308ea0667e1--fa0ca324b9e44937b7fce86d151130c3
fa0ca324b9e44937b7fce86d151130c3--6a5588981c2c4c3faeb8cc8cef1e34b7
25be45d34544470785e318eeac66655a
9e33a99edaa9465e960c6add0cef2a98
ce4827df089840ac879b6707c1c413d4--9e33a99edaa9465e960c6add0cef2a98
3a510c55b71e42dc8303e1e999b9980c
9e33a99edaa9465e960c6add0cef2a98--3a510c55b71e42dc8303e1e999b9980c
99e20b462d844d4287d8b9cc4ab4cd94
3a510c55b71e42dc8303e1e999b9980c--99e20b462d844d4287d8b9cc4ab4cd94
99e20b462d844d4287d8b9cc4ab4cd94--b5098201b29348cda1e524ae8ddb34c4
23e282d675254460ab9c1cf90e032b10--25be45d34544470785e318eeac66655a
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
06f9cf6c061e473086638f275326dcac
0
c6201fda2e664416afee15b3e8441ad0
06f9cf6c061e473086638f275326dcac--c6201fda2e664416afee15b3e8441ad0
8daa7be82d36413c9992dceeed2e922a
1
3ba1da94b41b4d659dd2994338e18ada
c6201fda2e664416afee15b3e8441ad0--3ba1da94b41b4d659dd2994338e18ada
b6f625ae7a034d9cb9299a8991b13f18
3ba1da94b41b4d659dd2994338e18ada--b6f625ae7a034d9cb9299a8991b13f18
e9628a5c8f22430985464f3b7f3d20cc
b6f625ae7a034d9cb9299a8991b13f18--e9628a5c8f22430985464f3b7f3d20cc
45042b575df54fc48142319b79ad1f41
58ac8de7e9444c8ba9ba97951685e8f0
PHASE(0.5)
8daa7be82d36413c9992dceeed2e922a--58ac8de7e9444c8ba9ba97951685e8f0
0ffa2297b9734c4996f1d1924f7d5547
2
58ac8de7e9444c8ba9ba97951685e8f0--c6201fda2e664416afee15b3e8441ad0
5c526f1b623049228416b885565c0aae
58ac8de7e9444c8ba9ba97951685e8f0--5c526f1b623049228416b885565c0aae
20ebea766709432f8982f23328f44672
5c526f1b623049228416b885565c0aae--20ebea766709432f8982f23328f44672
20ebea766709432f8982f23328f44672--45042b575df54fc48142319b79ad1f41
85c233d7284a493da0ee1c8017c9ea20
002fb7bfe68a4f1dbcf015a2b59dc209
0ffa2297b9734c4996f1d1924f7d5547--002fb7bfe68a4f1dbcf015a2b59dc209
95fdd8722355484098002c548a4b8edb
3
cca5a2ef984f496a80b320c27a5dd05c
PHASE(0.5)
002fb7bfe68a4f1dbcf015a2b59dc209--cca5a2ef984f496a80b320c27a5dd05c
cca5a2ef984f496a80b320c27a5dd05c--3ba1da94b41b4d659dd2994338e18ada
f7850a204cbb42adb77d63c9af1618d3
cca5a2ef984f496a80b320c27a5dd05c--f7850a204cbb42adb77d63c9af1618d3
f7850a204cbb42adb77d63c9af1618d3--85c233d7284a493da0ee1c8017c9ea20
491fcc11d3dc45f6b1c85d5eeba3ee0d
e767646c9e424c598d3fcf6491b78bbc
95fdd8722355484098002c548a4b8edb--e767646c9e424c598d3fcf6491b78bbc
eac13138bfbc4edf81dc5c0e1e8e0a73
e767646c9e424c598d3fcf6491b78bbc--eac13138bfbc4edf81dc5c0e1e8e0a73
2d38b6d953404c07aceaa95ad754246f
PHASE(0.5)
eac13138bfbc4edf81dc5c0e1e8e0a73--2d38b6d953404c07aceaa95ad754246f
2d38b6d953404c07aceaa95ad754246f--b6f625ae7a034d9cb9299a8991b13f18
2d38b6d953404c07aceaa95ad754246f--491fcc11d3dc45f6b1c85d5eeba3ee0d
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