Created
November 30, 2019 11:14
-
-
Save shukob/9ad0a3ced4b6cc05f90a5154adace22e to your computer and use it in GitHub Desktop.
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
#= | |
quantum_walk: | |
- Julia version: 1.1.1 | |
- Author: shunpeik | |
- Date: 2019-11-30 | |
=# | |
using Plots | |
using LinearAlgebra | |
gr() | |
let | |
generate = (P, Q) -> function (φ) | |
φ_next = hcat([0.0;0.0], zero(φ), [0.0;0.0]) | |
φ_next[:, 1:end-2] = mapslices(x -> Q * x , φ, dims=1) | |
φ_next[:, 3:end] .+= mapslices(x -> P * x , φ, dims=1) | |
return φ_next | |
end | |
θ = π / 4 | |
@show P = [[cos(θ) sin(θ)];[0 0]] | |
@show Q = [[0 0]; [sin(θ) -cos(θ)]] | |
@show φ = [1.0/√2; 1.0im/√2] | |
U = P + Q | |
@show U'U | |
@show φ'φ | |
evolve = generate(P, Q) | |
for i in 1:100 | |
φ = evolve(φ) | |
end | |
probs = mapslices(x -> convert(Float64, x'x), φ, dims=1) | |
display(plot(1:length(probs), probs')) | |
readline() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment