diff --git a/src/gate_kernels.jl b/src/gate_kernels.jl index 39ae323..4303533 100644 --- a/src/gate_kernels.jl +++ b/src/gate_kernels.jl @@ -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} = diff --git a/test/test_sv_simulator.jl b/test/test_sv_simulator.jl index f68bc8c..111fd65 100644 --- a/test/test_sv_simulator.jl +++ b/test/test_sv_simulator.jl @@ -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,