Skip to content

Commit

Permalink
update measure
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed Apr 25, 2019
1 parent 8d9cb01 commit adaab56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/register.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/focus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit adaab56

Please sign in to comment.