GTorlai / PastaQ.jl

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

Creating custom parameterised gates #262

Closed ghost closed 2 years ago

ghost commented 2 years ago

How should I create a custom parameterised gate? I tried to copy the example in https://github.com/GTorlai/PastaQ.jl/blob/master/examples/01_quantumgates.jl, but this seems to be incorrect.

using ITensors
using PastaQ
import PastaQ: gate

N = 2

hilbert = qubits(N)

gate(::GateName"G"; θ::Number) = [
  1 0 0 0
  0 cos(θ / 2) -sin(θ / 2) 0
  0 sin(θ / 2) cos(θ / 2) 0
  0 0 0 1
]

circuit = Tuple[("G", (1, 2), 0.1)]

psi = runcircuit(hilbert, circuit)
ghost commented 2 years ago

Solved, found that I needed to change the rotation argument:

circuit = Tuple[("G", (1, 2), (θ = 0.1,))]