From adaab563a9d14367155ebb9bff84ba9dc102e948 Mon Sep 17 00:00:00 2001 From: GiggleLiu Date: Thu, 25 Apr 2019 22:49:53 +0800 Subject: [PATCH] update measure --- src/register.jl | 4 ++-- test/focus.jl | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/register.jl b/src/register.jl index c4997828c..bf80c51f0 100644 --- a/src/register.jl +++ b/src/register.jl @@ -143,10 +143,10 @@ function YaoBase.addbits!(r::ArrayReg, n::Int) return r end -function YaoBase.insert_qubits!(reg::ArrayReg{B}, loc::Int; nbit::Int=1) where B +function YaoBase.insert_qubits!(reg::ArrayReg{B}, loc::Int; nqubits::Int=1) where B na = nactive(reg) focus!(reg, 1:loc-1) - reg2 = join(zero_state(nbit, B), reg) |> relax! |> focus!((1:na+nbit)...) + reg2 = join(zero_state(nqubits; nbatch=B), reg) |> relax! |> focus!((1:na+nqubits)...) reg.state = reg2.state reg end diff --git a/test/focus.jl b/test/focus.jl index cfa2dc5e7..efd9d28ee 100644 --- a/test/focus.jl +++ b/test/focus.jl @@ -35,6 +35,8 @@ end @test copy(reg) |> addbits!(2) |> nactive == 5 reg2 = copy(reg) |> addbits!(2) |> focus!(4,5) @test (reg2 |> measure_remove!; reg2) |> relax!(to_nactive=nqubits(reg2)) ≈ reg + + @test insert_qubits!(copy(reg), 2; nqubits=2) |> nactive == 5 end @testset "Focus 2" begin