Skip to content

Commit

Permalink
Add FractionalISwap gate
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Mar 18, 2024
1 parent 0bde6bd commit 24233b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ Matrix{T}(::Swap) where {T} = Matrix{T}([1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 1])

Matrix{T}(::ISwap) where {T} = Matrix{T}([1 0 0 0; 0 0 1im 0; 0 1im 0 0; 0 0 0 1])

Matrix{T}(op::FractionalISwap) where {T} = Matrix{T}(
[
1 0 0 0
0 cospi(op.exponent / 2) 1im*sinpi(op.exponent / 2)*cispi(2 * op.phase_exponent) 0
0 1im*sinpi(op.exponent / 2)*cispi(-2 * op.phase_exponent) cospi(op.exponent / 2) 0
0 0 0 1
],
)

Matrix{T}(::FSwap) where {T} = Matrix{T}([1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 -1])

Matrix{T}(op::FSim) where {T} = Matrix{T}([
Expand Down Expand Up @@ -165,6 +174,13 @@ Array{T,4}(::Swap) where {T} = Array{T}([1; 0;; 0; 0;;; 0; 0;; 1; 0;;;; 0; 1;; 0

Array{T,4}(::ISwap) where {T} = Array{T}([1; 0;; 0; 0;;; 0; 0;; 1im; 0;;;; 0; 1im;; 0; 0;;; 0; 0;; 0; 1])

Array{T,4}(op::FractionalISwap) where {T} = Array{T}(
[
1; 0;; 0; 0;;; 0; cospi(op.exponent / 2);; 1im*sinpi(op.exponent / 2)*cispi(-2 * op.phase_exponent); 0;;;;
0; 1im*sinpi(op.exponent / 2)*cispi(-2 * op.phase_exponent);; cospi(op.exponent / 2); 0;;; 0; 0;; 0; 1
],
)

Array{T,4}(::Swap) where {T} = Array{T}([1; 0;; 0; 0;;; 0; 0;; 1; 0;;;; 0; 1;; 0; 0;;; 0; 0;; 0; -1])

Array{T,4}(op::FSim) where {T} = Array{T}(
Expand Down
6 changes: 6 additions & 0 deletions src/Gate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ The ISWAP gate.
"""
@gatedecl ISwap n = 2

# TODO move `exponent`, `phase_exponent` to `ISwap` operator?
@gatedecl FractionalISwap n = 2 begin
exponent::Float64 = 1
phase_exponent::Float64 = 0
end

"""
FSwap(lane1, lane2)
Expand Down

0 comments on commit 24233b9

Please sign in to comment.