Skip to content

Commit 350fb9a

Browse files
author
Harsha Nagarajan
committed
Fermionic swap gate added
1 parent 632b0a8 commit 350fb9a

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ QuantumCircuitOpt.jl Change Log
33

44
### v0.6.0
55
- Minor clean up in global phase enforcing constraints
6+
- Added 2-qubit Fermionic SWAP gate, that swaps adjacent fermionic modes
67
- Added support for `unitary_complex_conjugate` constraints (for both with and without global phase), which significantly speeds up QCOpt’s decomposition methods.
78
- Added `is_zero` function with a `tol` option
89
- Added `QFT3Gate` to docs

docs/src/2_qubit_gates.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ CU3RevGate
116116
```@docs
117117
SwapGate
118118
```
119+
## fSwapGate
120+
```@docs
121+
fSwapGate
122+
```
119123
## SSwapGate
120124
```@docs
121125
SSwapGate

src/gates.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,31 @@ function SwapGate()
13691369
return Array{Complex{Float64},2}([1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 1])
13701370
end
13711371

1372+
@doc raw"""
1373+
fSwapGate()
1374+
1375+
Two-qubit, symmetric, Fermionic SWAP gate, that swaps adjacent fermionic modes
1376+
in the Jordan-Wigner representation. Because the qubits represent identical
1377+
fermions, swapping two particles applies a -1 phase to the state.
1378+
1379+
Reference: https://doi.org/10.22331/q-2018-12-21-114
1380+
1381+
**Matrix Representation**
1382+
1383+
```math
1384+
fSWAP = \begin{pmatrix}
1385+
1 & 0 & 0 & 0 \\
1386+
0 & 0 & 1 & 0 \\
1387+
0 & 1 & 0 & 0 \\
1388+
0 & 0 & 0 & -1
1389+
\end{pmatrix}
1390+
```
1391+
"""
1392+
function fSwapGate()
1393+
return Array{Complex{Float64},2}([1 0 0 0; 0 0 1 0; 0 1 0 0; 0 0 0 -1])
1394+
end
1395+
1396+
13721397
@doc raw"""
13731398
SSwapGate()
13741399

test/gates_tests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,7 @@
207207
M1 = QCO.multi_controlled_gate(QCO.HGate(), [1], 2, 3)
208208
M2 = kron(QCO.CHGate(), QCO.IGate(1))
209209
@test isapprox(M1, M2, atol=tol_0)
210+
211+
# Test Fermionic-Swap gate
212+
@test isapprox(QCO.fSwapGate(), QCO.SwapGate()*QCO.CZGate(), atol=tol_0)
210213
end

0 commit comments

Comments
 (0)