Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger-luo committed Apr 24, 2019
1 parent b4ec7c9 commit 51d5323
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/register.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ ArrayReg(r::ArrayReg{B}) where B = ArrayReg{B}(copy(r.state))
Base.copy(r::ArrayReg) = ArrayReg(r)
Base.similar(r::ArrayRegOrAdjointArrayReg{B}) where B = ArrayReg{B}(similar(state(r)))

function Base.copyto!(dst::R, src::R) where {R <: ArrayRegOrAdjointArrayReg}
function Base.copyto!(dst::ArrayRegOrAdjointArrayReg, src::ArrayRegOrAdjointArrayReg)
copyto!(state(dst), state(src))
return dst
end
Expand Down
8 changes: 8 additions & 0 deletions test/register.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,11 @@ end
focus!(r, 2:4)
@test sum(r.state, dims=2) ArrayReg(bit"011").state
end

@testset "YaoBlocks.jl/issues/21" begin
st = rand(ComplexF64, 16, 2)
r1 = ArrayReg(view(st, :, 1))
r2 = ArrayReg(rand(ComplexF64, 16, 1))
copyto!(r1, r2)
@test r1 == r2
end

0 comments on commit 51d5323

Please sign in to comment.