This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update luxor * fix line break * fix labelled example * fix margin * fix test * ... * more spacious * ... * seperate zx calculus
- Loading branch information
Showing
25 changed files
with
286 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,50 @@ | ||
using Yao.EasyBuild, YaoPlots, Yao | ||
using Compose, Cairo | ||
|
||
_save(str) = PNG(joinpath(@__DIR__, str)) | ||
|
||
lighttheme!() | ||
YaoPlots.CircuitStyles.gate_bgcolor[] = "white" # default is transparent | ||
# qft circuit | ||
vizcircuit(qft_circuit(5)) |> _save("qft.png") | ||
vizcircuit(qft_circuit(5); filename=joinpath(@__DIR__, "qft.png")) | ||
|
||
# labeled and time evolution | ||
vizcircuit(chain(control(5, 3, (2,4)=>matblock(rand_unitary(4); tag="label")), | ||
put(5, (2,4)=>matblock(rand_unitary(4); tag="label")), time_evolve(put(5, 2=>X), 0.2))) |> _save("labelled.png") | ||
put(5, (2,4)=>matblock(rand_unitary(4); tag="labellabel")), time_evolve(+(put(5, 2=>X), kron(5, 2=>Z, 3=>Y)), 0.2)), filename=joinpath(@__DIR__, "labelled.png")) | ||
|
||
# variational circuit | ||
vizcircuit(variational_circuit(5)) |> _save("variational.png") | ||
vizcircuit(variational_circuit(5), filename=joinpath(@__DIR__, "variational.png")) | ||
# vizcircuit(variational_circuit(5; mode=:Merged)) | ||
|
||
# general U4 gate | ||
vizcircuit(general_U4()) |> _save("u4.png") | ||
vizcircuit(general_U4(), filename=joinpath(@__DIR__, "u4.png")) | ||
|
||
# quantum supremacy circuit | ||
vizcircuit(rand_supremacy2d(2, 2, 8)) |> _save("supremacy2d.png") | ||
vizcircuit(rand_supremacy2d(2, 2, 8), filename=joinpath(@__DIR__, "supremacy2d.png")) | ||
|
||
# google 52 qubit | ||
vizcircuit(rand_google53(5); scale=0.5) |> _save("google53.png") | ||
vizcircuit(rand_google53(5); filename=joinpath(@__DIR__, "google53.png")) | ||
|
||
# control blocks | ||
vizcircuit(chain(control(5, (2,-3), 4=>X), control(5, (-4, -2), 1=>Z))) |> _save("controls.png") | ||
vizcircuit(chain(control(5, (2,-3), 4=>X), control(5, (-4, -2), 1=>Z)), filename=joinpath(@__DIR__, "controls.png")) | ||
|
||
# controlled kron | ||
control(4, 2, (1, 3)=>kron(X, X)) |> vizcircuit |> _save("cxx.png") | ||
vizcircuit(control(4, 2, (1, 3)=>kron(X, X)), filename=joinpath(@__DIR__, "cxx.png")) | ||
|
||
control(4, -collect(1:4-1), 4=>-Z) |> vizcircuit |> _save("reflect.png") | ||
vizcircuit(control(4, -collect(1:4-1), 4=>-Z), filename=joinpath(@__DIR__, "reflect.png")) | ||
|
||
chain(5, [put(5, 2=>X), Yao.Measure(5; locs=(2,3)), Yao.Measure(5;locs=(2,)), Yao.Measure(5; resetto=bit"00110")]) |> vizcircuit |> _save("measure.png") | ||
vizcircuit(chain(5, [put(5, 2=>X), Yao.Measure(5; locs=(2,3)), Yao.Measure(5;locs=(2,)), Yao.Measure(5; resetto=bit"00110")]), filename=joinpath(@__DIR__, "measure.png")) | ||
|
||
chain(5, [put(5, 2=>ConstGate.Sdag), put(5, 3=>ConstGate.Tdag), | ||
vizcircuit(chain(5, [put(5, 2=>ConstGate.Sdag), put(5, 3=>ConstGate.Tdag), | ||
put(5, (2,3)=>ConstGate.CNOT), put(5, (1,4)=>ConstGate.CZ), put(5, (1,2,5)=>ConstGate.Toffoli), | ||
put(5, (2,3)=>ConstGate.SWAP), put(5, (1,)=>ConstGate.P0), put(5, (1,)=>ConstGate.I2), | ||
put(5, (2,)=>ConstGate.P1), put(5, (1,)=>ConstGate.Pu), put(5, (1,)=>ConstGate.Pd), | ||
put(5, (2,)=>ConstGate.T), | ||
put(5, (2,)=>phase(0.4π)), | ||
put(5, (2,)=>shift(0.4π)), | ||
]) |> vizcircuit |> _save("constgates.png") | ||
]), filename=joinpath(@__DIR__, "constgates.png")) | ||
|
||
chain(5, [put(5, (2,3)=>matblock(Matrix(SWAP), tag="SWAP")'), put(5, 2=>matblock(mat(I2), tag="id")), put(5, 2=>label(X, "X")), control(5, (5,3), (2,4,1)=>put(3, (1,3)=>label(SWAP, "SWAP")))]) |> vizcircuit |> _save("multiqubit.png") | ||
vizcircuit(chain(5, [put(5, (2,3)=>matblock(Matrix(SWAP), tag="SWAP")'), put(5, 2=>matblock(mat(I2), tag="id")), put(5, 2=>addlabel(X, "X")), control(5, (5,3), (2,4,1)=>put(3, (1,3)=>addlabel(SWAP, "SWAP")))]), filename=joinpath(@__DIR__, "multiqubit.png")) | ||
|
||
YaoPlots.darktheme!() | ||
YaoPlots.CircuitStyles.gate_bgcolor[] = "transparent" # default is transparent | ||
# qft circuit | ||
vizcircuit(qft_circuit(5)) |> _save("qft-white.png") | ||
vizcircuit(qft_circuit(5), filename=joinpath(@__DIR__, "qft-white.png")) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
module YaoPlots | ||
|
||
export plot | ||
using Yao | ||
import Luxor | ||
|
||
using Compose | ||
export CircuitStyles, CircuitGrid, circuit_canvas, vizcircuit, darktheme!, lighttheme! | ||
export plot | ||
|
||
plot(;kwargs...) = x->plot(x;kwargs...) | ||
plot(blk::AbstractBlock; kwargs...) = vizcircuit(blk; kwargs...) | ||
|
||
include("helperblock.jl") | ||
include("vizcircuit.jl") | ||
include("zx_plot.jl") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.