QuantumBFS / YaoLang.jl

YaoLang: The next DSL for Yao and quantum programs.
https://yaoquantum.org/YaoLang.jl/dev/
Apache License 2.0
31 stars 6 forks source link

force Circuit to return register #18

Closed Roger-luo closed 4 years ago

Roger-luo commented 4 years ago

MWE:

@device function cnot_layer(configs::AbstractMatrix)
    @inbounds for j in 1:size(configs, 2), i in 1:size(configs, 1)
        if (i != j) && (configs[i, j] == true)
            @ctrl i j=>X
        end
    end
    return
end

returns nothing, but

@device function cnot_layer(configs::AbstractMatrix)
    @inbounds for j in 1:size(configs, 2), i in 1:size(configs, 1)
        if (i != j) && (configs[i, j] == true)
            @ctrl i j=>X
        end
    end
end

returns register