diff --git a/src/instructs.jl b/src/instructs.jl index 0548afe..6ed8e35 100644 --- a/src/instructs.jl +++ b/src/instructs.jl @@ -305,7 +305,7 @@ for RG in [:Rx, :Ry, :Rz] ::Val{$(QuoteNode(RG))}, locs::Tuple{Int}, theta::Number - ) where {T, N} + ) where {T} YaoArrayRegister.instruct!(Val(2), state, Val($(QuoteNode(RG))), locs, (), (), theta) return state end diff --git a/src/register.jl b/src/register.jl index 7e7d1f2..cc493e9 100644 --- a/src/register.jl +++ b/src/register.jl @@ -279,9 +279,6 @@ end function YaoBlocks.expect(op::AbstractBlock, dm::CuDensityMatrix{D}) where D return tr(apply(ArrayReg{D}(dm.state), op).state) end -function expect(op::Scale, reg::DensityMatrix) - factor(op) * expect(content(op), reg) -end measure( ::ComputationalBasis, @@ -289,4 +286,5 @@ measure( ::AllLocs; nshots::Int = 1, rng::AbstractRNG = Random.GLOBAL_RNG, -) = YaoArrayRegister._measure(rng, basis(reg), Array(reg |> probs), nshots) \ No newline at end of file +) = YaoArrayRegister._measure(rng, basis(reg), Array(reg |> probs), nshots) + diff --git a/test/register.jl b/test/register.jl index ff67f4c..18f1a0a 100644 --- a/test/register.jl +++ b/test/register.jl @@ -87,9 +87,9 @@ end @test size(res) == (32,) @test res2 == res - reg = repeat(ArrayReg([1,-1+0im]/sqrt(2.0)), 10) |> cu + reg = clone(ArrayReg([1,-1+0im]/sqrt(2.0)), 10) |> cu @test measure!(X, reg) |> mean ≈ -1 - reg = repeat(ArrayReg([1.0,0+0im]), 1000) + reg = clone(ArrayReg([1.0,0+0im]), 1000) @test abs(measure!(X, reg) |> mean) < 0.1 end @@ -135,4 +135,5 @@ end reg = cughz_state(3; nbatch=b) @test cpu(reg) ≈ ghz_state(3; nbatch=b) && reg isa AbstractCuArrayReg end -end \ No newline at end of file +end +