Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
remove compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed Jul 21, 2019
1 parent d495c75 commit fdf5ce8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ YaoBase = "a8f54c17-34bc-5a9d-b050-f522fe3f755f"
[compat]
BitBasis = "^0.5.0"
LuxurySparse = "~0.4.0"
YaoBase = "~0.9.0"
YaoBase = "~0.10.0"
julia = "^1.0.0"

[extras]
Expand Down
22 changes: 5 additions & 17 deletions src/instruct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,28 +249,16 @@ end

# Specialized
import YaoBase: rot_mat
"""rotation gate, will be removed to YaoBase."""
function rot_mat(::Type{T}, gen::AbstractMatrix, theta::Real) where {N, T}
I = IMatrix{size(gen, 1), T}()
m = I * cos(theta / 2) - im * sin(theta / 2) * gen
if eltype(m) != T
m2 = similar(m, T)
copyto!(m2, m)
return m2
else
return m
end
end

YaoBase.rot_mat(::Type{T}, ::Val{:Rx}, theta::Real) where T =
rot_mat(::Type{T}, ::Val{:Rx}, theta::Real) where T =
T[cos(theta/2) -im * sin(theta/2); -im * sin(theta/2) cos(theta/2)]
YaoBase.rot_mat(::Type{T}, ::Val{:Ry}, theta::Real) where T =
rot_mat(::Type{T}, ::Val{:Ry}, theta::Real) where T =
T[cos(theta/2) -sin(theta/2); sin(theta/2) cos(theta/2)]
YaoBase.rot_mat(::Type{T}, ::Val{:Rz}, theta::Real) where T =
rot_mat(::Type{T}, ::Val{:Rz}, theta::Real) where T =
Diagonal(T[exp(-im*theta/2), exp(im*theta/2)])
YaoBase.rot_mat(::Type{T}, ::Val{:CPHASE}, theta::Real) where T =
rot_mat(::Type{T}, ::Val{:CPHASE}, theta::Real) where T =
Diagonal(T[1, 1, 1, exp(im*theta)])
YaoBase.rot_mat(::Type{T}, ::Val{:PSWAP}, theta::Real) where T =
rot_mat(::Type{T}, ::Val{:PSWAP}, theta::Real) where T =
rot_mat(T, Const.SWAP, theta)

for G in [:Rx, :Ry, :Rz, :CPHASE]
Expand Down

0 comments on commit fdf5ce8

Please sign in to comment.