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

New feature: sqrt Pauli gates #102

Open
TysonRayJones opened this issue Feb 16, 2019 · 3 comments
Open

New feature: sqrt Pauli gates #102

TysonRayJones opened this issue Feb 16, 2019 · 3 comments

Comments

@TysonRayJones
Copy link
Member

E.g. sqrtPauliX = rotateX(pi/2), but avoids using pi or evaluating transcendentals.
This might as well be added, since these functions are to exist to implement #97
They're generally useful for a user for changing basis

@bmarco82
Copy link

Hello, I am also interested in using sqrt(X) and sqrt(Y) gates. I am wondering if these have been implemented, even in a non-public version, and/or if it's difficult to patch the code to add them. Thank you!

@TysonRayJones
Copy link
Member Author

Hi Marco,

Explicit sqrt pauli gates were ultimately unnecessary and were not added in the end.
They can of course be simply effected using rotations.

// effects exp(i M_PI/4) sqrt(X)
rotateX(qureg, qubit, M_PI/2);

// effects exp(i M_PI/4) sqrt(Y);
rotateY(qureg, qubit, M_PI/2);

Note these also effect an arbitrary phase-factor of exp(i M_PI/4), hence controlled rotations will not effect controlled sqrt-gates.

If you need controlled sqrt gates, you can simply specify them element-wise, and use functions like unitary().

ComplexMatrix2 sqrtX = {
    .real = {{.5, .5}, 
             {.5, .5}},
    .imag = {{.5, -.5}, 
             {-.5, .5}}};

ComplexMatrix2 sqrtY = {
    .real = {{.5, -.5}, 
             {.5, .5}},
    .imag = {{.5, -.5}, 
             {.5, .5}}};

unitary(qureg, qubit, sqrtX);
controlledUnitary(qureg, ctrl, targ, sqrtY); 

I hope this helps in the near-term!

@TysonRayJones
Copy link
Member Author

Bespoke gates remain frivolous; however, it may be convenient to provide matrix-getters for things like sqrt. E.g. CompMatr1 b = getCompMatr1Sqrt(a)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants