Qaintum / Qaintessent.jl

Digital quantum circuit simulator written in Julia
Apache License 2.0
30 stars 8 forks source link

Method Match Error for `controlled_circuit_gate` #88

Closed isolatedinformation closed 3 years ago

isolatedinformation commented 3 years ago
Closest candidates are:
  controlled_circuit_gate(!Matched::Main.Qaintessent.QRegister, ::Union{Expr, var"#s41"} where var"#s41"<:Integer, ::AbstractGate{M}, ::Integer) where M at c:\Users\varun\OneDrive\Documents\Masters\Open Source Projects\Qaintessent.jl\src\circuit.jl:278
  controlled_circuit_gate(!Matched::Main.Qaintessent.QRegister, ::Union{Expr, var"#s36"} where var"#s36"<:Integer, ::AbstractGate{M}, ::Integer, !Matched::AbstractArray{var"#s35",1} where var"#s35"<:Integer) where {K, M} at c:\Users\varun\OneDrive\Documents\Masters\Open Source Projects\Qaintessent.jl\src\circuit.jl:278
  controlled_circuit_gate(!Matched::Integer, ::Union{Expr, Integer}, ::AbstractGate{1}, ::Integer) at c:\Users\varun\OneDrive\Documents\Masters\Open Source Projects\Qaintessent.jl\src\circuit.jl:204
  ...

Stacktrace:
 [1] top-level scope at In[2]:3
 [2] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091

The following error showed up while running the view_example.ipynb. My conjecture is this may arise because controlled_circuit_gate method is overloaded before it is defined. It does not show up as error. But it also doesn't suggest the overloaded function in line 213 as a close candidate. If I understood the source code properly, then that is the overloaded method which has to be executed

isolatedinformation commented 3 years ago

The issue is fixed by interchanging the tuples between target and control qubits. line 5 in the second code block should be

controlled_circuit_gate( 2, (1, 4), RxGate(√0.2), N)
keefehuang commented 3 years ago

Hi, Thanks for bringing this to my attention. Sorry for the late response. We are actually shifting over to a new API now. We now use: circuit_gate(wires::NTuple(...) , ::AbstractGate, control_wires::NTuple(...)=...) to create CircuitGate objectes.