Currently, appendlayer! works for adding a uniform layer of single qubit gates. It would be nice to have some more advanced features, such as:
[ ] appendlayer!(gates, "H", N÷2+1:N) # Hadamard gate on only the second half of the system
[ ] appendlayer!(gates, "X", 1:2:N) # X gate on every other site, starting at site 1 (on odd sites)
[ ] appendlayer!(gates, "X", 2:2:N) # X gate on every other site, starting at site 2 (on even sites)
[ ] appendlayer!(gates, "CX", 1:2:N-1) # Controlled X gate on every other site, starting at site 1 (on odd sites)
[ ] appendlayer!(gates, "CX", 2:2:N-1) # Controlled X gate on every other site, starting at site 2 (on even sites)
The number of qubits of the gate can be determined automatically from Int(log2(size(gate("CX"), 1))). To get more advanced gates, it could accept a function which takes the site and returns a gate, for example:
[ ] appendlayer!(gates, n -> ("Rx", n, (θ = π/4,)), N÷2+1:N) # Apply the "Rx" gate with rotation π/4 to the second half of the system
[ ] appendlayer!(gates, n -> ("CX", (n, n+2)), 1:4:N-2) # Apply the "CX" gate to every 4th site, applied 2-qubits apart
In general, appendlayer! could accept a range of sites where the 1st qubit of the gate is applied. Additionally, it could accept a vector of arbitrary sites where the 1st qubit is applied (if the pattern is not uniform), as well as reverse ranges.
Functions like randomcircuit and qft could accept ranges and vectors as well, for example:
[ ] randcircuit(1:2:N, 3) # Make 3 layers, where the random circuit is only applied to odd sites
[ ] qft(N÷2+1:N) # Make a QFT on the second half of the system
This can help with using pre-defined circuits as subcircuits of more advanced circuits.
Currently,
appendlayer!
works for adding a uniform layer of single qubit gates. It would be nice to have some more advanced features, such as:appendlayer!(gates, "H", N÷2+1:N)
# Hadamard gate on only the second half of the systemappendlayer!(gates, "X", 1:2:N)
# X gate on every other site, starting at site 1 (on odd sites)appendlayer!(gates, "X", 2:2:N)
# X gate on every other site, starting at site 2 (on even sites)appendlayer!(gates, "CX", 1:2:N-1)
# Controlled X gate on every other site, starting at site 1 (on odd sites)appendlayer!(gates, "CX", 2:2:N-1)
# Controlled X gate on every other site, starting at site 2 (on even sites)The number of qubits of the gate can be determined automatically from
Int(log2(size(gate("CX"), 1)))
. To get more advanced gates, it could accept a function which takes the site and returns a gate, for example:appendlayer!(gates, n -> ("Rx", n, (θ = π/4,)), N÷2+1:N)
# Apply the "Rx" gate with rotation π/4 to the second half of the systemappendlayer!(gates, n -> ("CX", (n, n+2)), 1:4:N-2)
# Apply the "CX" gate to every 4th site, applied 2-qubits apartIn general,
appendlayer!
could accept a range of sites where the 1st qubit of the gate is applied. Additionally, it could accept a vector of arbitrary sites where the 1st qubit is applied (if the pattern is not uniform), as well as reverse ranges.Functions like
randomcircuit
andqft
could accept ranges and vectors as well, for example:randcircuit(1:2:N, 3)
# Make 3 layers, where the random circuit is only applied to odd sitesqft(N÷2+1:N)
# Make a QFT on the second half of the systemThis can help with using pre-defined circuits as subcircuits of more advanced circuits.