ffsim.apply_givens_rotation

ffsim.apply_givens_rotation(vec, theta, target_orbs, norb, nelec, spin=<Spin.ALPHA_AND_BETA: 3>, *, phi=0.0, copy=True)[source]

Apply a Givens rotation gate.

The Givens rotation gate is

\[\text{G}(\theta, \varphi, (p, q)) = \prod_{\sigma} \exp\left(i\varphi a^\dagger_{p\sigma} a_{p\sigma}\right) \exp\left(\theta (a^\dagger_{p\sigma} a_{q\sigma} - a^\dagger_{q\sigma} a_{p\sigma})\right) \exp\left(-i\varphi a^\dagger_{p\sigma} a_{p\sigma}\right)\]

Under the Jordan-Wigner transform, this gate has the following matrix when applied to neighboring qubits:

\[\begin{split}\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos(\theta) & -e^{-i\varphi}\sin(\theta) & 0\\ 0 & e^{i\varphi}\sin(\theta) & \cos(\theta) & 0\\ 0 & 0 & 0 & 1 \\ \end{pmatrix}\end{split}\]
Parameters:
  • vec (ndarray) – The state vector to be transformed.

  • theta (float) – The rotation angle.

  • target_orbs (tuple[int, int]) – The orbitals (p, q) to rotate.

  • norb (int) – The number of spatial orbitals.

  • nelec (int | tuple[int, int]) – Either a single integer representing the number of fermions for a spinless system, or a pair of integers storing the numbers of spin alpha and spin beta fermions.

  • spin (Spin) –

    Choice of spin sector(s) to act on.

    • To act on only spin alpha, pass ffsim.Spin.ALPHA.

    • To act on only spin beta, pass ffsim.Spin.BETA.

    • To act on both spin alpha and spin beta, pass ffsim.Spin.ALPHA_AND_BETA (this is the default value).

  • phi (float) – The optional phase angle.

  • copy (bool) –

    Whether to copy the vector before operating on it.

    • If copy=True then this function always returns a newly allocated vector and the original vector is left untouched.

    • If copy=False then this function may still return a newly allocated vector, but the original vector may have its data overwritten. It is also possible that the original vector is returned, modified in-place.

Return type:

ndarray