jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
467 stars 107 forks source link

Add complex Givens rotation #245

Open kevinsung opened 2 weeks ago

kevinsung commented 2 weeks ago

Is your feature request related to a problem?

From looking at the documentation, the Givens rotation has only one parameter, theta. I couldn't find the documentation of the gate matrix, but I believe it is

[ c   s ]
[ -s  c ]

where c = cos(theta) and s = sin(theta). In general however, a Givens rotation can be complex with the form

[ c    s ]
[ -s*  c ]

For example, see https://www.cs.cornell.edu/~bindel/papers/2002-toms.pdf.

Describe the solution you'd like

The complex Givens rotation can be accommodated by adding a parameter phi and replacing s with s * e^{i phi}. I don't know if the current gate should be modified, or a new gate added.

Describe alternatives you've considered

A workaround is to use the Givens gate together with two Rz gates. But it's more convenient to have a single gate to represent the concept, and it might enable better performance optimizations (I'm not sure).

Additional context

No response

jcmgray commented 2 weeks ago

hi @kevinsung, yes the source is here: https://github.com/jcmgray/quimb/blob/main/quimb/tensor/circuit.py#L787-L806, its a two qubit gate with that first matrix you give on the number conserving subspace - some other info here: https://pennylane.ai/qml/demos/tutorial_givens_rotations/.

Would be very happy to add that phi parameter - would you want to open an PR ?

kevinsung commented 2 weeks ago

Sure, I can open a PR. Should I add it to the existing gate? That would break some APIs, like Circuit.givens, right?

jcmgray commented 2 weeks ago

That's true, maybe a new gate method called 'givens2' for the two parameter version is necessary (or some other more appropriate name?).