Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating custom parameterised gates #262

Closed
ghost opened this issue Mar 6, 2022 · 1 comment
Closed

Creating custom parameterised gates #262

ghost opened this issue Mar 6, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Mar 6, 2022

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
Copy link
Author

ghost commented Mar 6, 2022

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

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

@ghost ghost closed this as completed Mar 6, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants