SupportsApplyUnitary
class SupportsApplyUnitary(*args, **kwargs)
Bases: Protocol
A mirror of the ffsim.SupportsApplyUnitary protocol.
See apply_unitary() for the type-agnostic helper function dispatching to the method below.
>>> import numpy as np
>>> from qiskit_fermions.circuit.library import OrbitalRotation
>>> gate = OrbitalRotation(np.eye(2))
>>> vec = np.array([1.0, 0.0], dtype=complex)
>>> gate._apply_unitary_(vec, norb=2, nelec=1, copy=True)
array([1.+0.j, 0.+0.j])
Protocol Methods
_apply_unitary_
_apply_unitary_(vec, norb, nelec, copy)
Applies a unitary transformation to a state vector.
Parameters
-
vec (np.ndarray) – the state vector to apply the unitary transformation to.
-
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.
-
copy (bool) –
whether to copy the vector before operating on it.
- If
copy=Truethen this method always returns a newly allocated vector and the original vector is left untouched. - If
copy=Falsethen this method 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.
- If
Returns
The transformed vector.
Return type
np.ndarray