GTorlai / PastaQ.jl

Package for Simulation, Tomography and Analysis of Quantum Computers
Apache License 2.0
142 stars 23 forks source link

Introduce appendlayer! function #55

Closed mtfishman closed 3 years ago

mtfishman commented 4 years ago

There are many functions that do similar things, like:

It seems like we could compress this into a unified interface, for example:

N = 10 # N sites
# Same as hadamardlayer
g = gatelayer("H", N)

and

# Same as hadamardlayer!
appendlayer!(gates, "H", N)

randomrotation could be implemented through the gate interface with a special GateName, for example gate("randrot", s). Then, randomrotation[!] could be replaced by:

gatelayer("randU", N)
appendlayer!(gates, "randU", N)

Also, the two-qubit layer could be determined automatically internally, or be specified with a keyword argument. I think a keyword argument may be best, such as:

appendlayer!(gates, "CX", N; nqubit = 2) # Every other site, starting at site 1 (on odd sites)
appendlayer!(gates, "CX", N; nqubit = 2, start = 2) # Every other site, starting at site 2 (so on even sites)

Also, we could probably just simplify:

mtfishman commented 4 years ago

@GTorlai, let me know what you think of these changes, I could implement them this week. Open to suggestions about the function names, keyword argument names, etc.

GTorlai commented 4 years ago

Sounds good, let me first merge the Choi matrix branch

mtfishman commented 4 years ago

This is partially implemented in #62. What remains is incorporating twoqubitlayer! into appendlayer! with a keyword argument nqubit = 2.