diff --git a/Project.toml b/Project.toml index 8e2693a..9695af9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FLOYao" uuid = "6d9310a3-f1d0-41b7-8edb-11c1cf57cd2d" authors = ["janlukas.bosse and contributors"] -version = "1.4.2" +version = "1.4.3" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/expect.jl b/src/expect.jl index 5f21296..d39a79a 100644 --- a/src/expect.jl +++ b/src/expect.jl @@ -71,7 +71,7 @@ for BT in [:AbstractAdd, :(KronBlock{2}), :(PutBlock{2,1,ZGate})] end end -Yao.expect(op::Scale, reg::MajoranaReg) = op.alpha * Yao.expect(op.content, reg) +Yao.expect(op::Scale, reg::MajoranaReg) = Yao.factor(op) * Yao.expect(Yao.content(op), reg) # # ---------------------- # Calculating fidelities diff --git a/test/runtests.jl b/test/runtests.jl index 4eb3281..60bede4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -235,21 +235,21 @@ end θ = π/8 xxg = kron(nq, 1 => X, 2 => Y) rg = rot(xxg, θ) - push!(circuit, rg) + push!(circuit, rg) push!(circuit, put(nq, 3=>Rz(0.5))) - push!(circuit, rg) + push!(circuit, rg) θ = π/5 xxg = kron(nq, 2 => X, 3 => Z, 4 => Y) rg = rot(xxg, θ) rz = put(nq, 3 => Rz(θ)) - push!(circuit, rg) + push!(circuit, rg) push!(circuit, put(nq, 3=>Rz(0.5))) push!(circuit, put(nq, (2,3) => FSWAP)) push!(circuit, put(nq, 1=>Z)) push!(circuit, put(nq, 4=>X)) - push!(circuit, rg) - push!(circuit, rz) + push!(circuit, rg) + push!(circuit, rz) ham = put(nq, 1=>Z) + 2kron(nq, 1=>X, 2=>Z, 3=>Z, 4=>X) + 3.5put(nq, 2=>Z) mreg = FLOYao.zero_state(nq) @@ -265,6 +265,11 @@ end aeval = expect(ham[end], areg) @test meval ≈ aeval + op = -kron(nq, 2=>X, 3=>X) + meval = expect(op, mreg) + aeval = expect(op, areg) + @test meval ≈ aeval + # test kronblocks inside put blocks ham = put(nq, 2:3 => kron(2, 1 => X, 2 => Y)) + 2put(nq, 1:2 => kron(2, 1 => X, 2 => Y)) meval = expect(ham, mreg)