ffsim.apply_fswap_gate

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

Apply an FSWAP gate.

The FSWAP gate swaps two orbitals. It is represented by the operator

\[\text{FSWAP}(p, q) = 1 + a^\dagger_p a_q + a^\dagger_q a_p - a_p^\dagger a_p - a_q^\dagger a_q\]

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 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -1 \\ \end{pmatrix}\end{split}\]
Parameters:
  • vec (ndarray) – The state vector to be transformed.

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

  • 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.

  • 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