Open TysonRayJones opened 5 years ago
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!
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!
Bespoke gates remain frivolous; however, it may be convenient to provide matrix-getters for things like sqrt
. E.g. CompMatr1 b = getCompMatr1Sqrt(a)
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