From 24233b96de2875df9fc50dc9785c86bc1770870e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Mon, 18 Mar 2024 20:14:41 +0100 Subject: [PATCH] Add `FractionalISwap` gate --- src/Array.jl | 16 ++++++++++++++++ src/Gate.jl | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/src/Array.jl b/src/Array.jl index 0fd1ef7..b0fa8c5 100644 --- a/src/Array.jl +++ b/src/Array.jl @@ -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}([ @@ -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}( diff --git a/src/Gate.jl b/src/Gate.jl index bf61a9b..3c753b0 100644 --- a/src/Gate.jl +++ b/src/Gate.jl @@ -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)