Skip to content

Commit

Permalink
fix: ECR gate representation and more correctness tests (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt-aws authored May 2, 2024
1 parent 3b09ba0 commit 3ddb41d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/gate_kernels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ matrix_rep(g::ZZ) = SMatrix{4,4}(
exp(-im * g.angle[1] / 2.0),
]),
)
matrix_rep(g::ECR) =
SMatrix{4,4}(1/√2 * [0.0 0.0 1.0 im; 0.0 0.0 im 1.0; 1.0 -im 0.0 0.0; -im 1.0 0.0 0.0])
# 1/√2 * (IX - XY)
matrix_rep(g::ECR) = SMatrix{4,4}(1/√2 * [0 1 0 im; 1 0 -im 0; 0 im 0 1; -im 0 1 0])
matrix_rep(g::Unitary) = g.matrix

apply_gate!(::Val{false}, g::I, state_vec::StateVector{T}, qubits::Int...) where {T<:Complex} =
Expand Down
41 changes: 41 additions & 0 deletions test/test_sv_simulator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,47 @@ LARGE_TESTS = get(ENV, "BRAKET_SV_LARGE_TESTS", false)
[0.70511898 - 0.0529833 * im, 0.70511898 + 0.0529833 * im],
[0.5, 0.5],
),
(
[Instruction(H(), [0]), Instruction(GPi(0.15), [0])],
1,
[0.69916673 - 0.10566872im, 0.69916673 + 0.10566872im],
[0.5, 0.5],
),
(
[Instruction(H(), [0]), Instruction(GPi2(0.15), [0])],
1,
[0.42528093 - 0.49438554im, 0.57471907 - 0.49438554im],
[0.42528093, 0.57471907],
),
(
[Instruction(MS/2, -π/4, 0.3), [0, 1])],
2,
[0.98877108, 0, 0, 0.10566872 - 0.10566872im],
[0.97766824, 0, 0, 0.02233176],
),
(
[Instruction(H(), [0]), Instruction(H(), [1]), Instruction(ECR(), [0, 1])],
2,
[
0.35355339 + 0.35355339im,
0.35355339 + 0.35355339im,
0.35355339 - 0.35355339im,
0.35355339 - 0.35355339im,
],
[0.25, 0.25, 0.25, 0.25],
),
(
[Instruction(H(), [0]), Instruction(U(0.15, 0.4, 0.7), [0])],
1,
[0.66459511 - 0.03413278im, 0.36864009 + 0.64903989im],
[0.44285171, 0.55714829],
),
(
[Instruction(H(), [0]), Instruction(MultiQubitPhaseShift{1}(0.15), [0])],
1,
[0.69916673 + 0.10566872im, 0.69916673 + 0.10566872im],
[0.5, 0.5],
),
(
[Instruction(X(), [0]), Instruction(PSwap(0.15), [0, 1])],
2,
Expand Down

0 comments on commit 3ddb41d

Please sign in to comment.