get_unitary_evolver

py_ste.get_unitary_evolver(drift_hamiltonian: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], control_hamiltonians: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str], sparse: bool = False, force_dynamic: bool = False) UnitaryEvolver[source]

Initialises a class to store the diagonalised drift and control Hamiltonians. On initialisation the Hamiltonians are diagonalised and the eigenvectors and values stored. This initial diagonalisation may be slow and takes \(O(\textrm{dim}^3)\) time for a \(\textrm{dim}\times \textrm{dim}\) Hamiltonian. However, it allows each step of the Suzuki-Trotter expansion to be implimented in \(O(\textrm{dim}^2)\) time with matrix multiplication and only scalar exponentiation opposed to matrix exponentiation which takes \(O(\textrm{dim}^3)\) time.

Parameters:
  • drift_hamiltonian (ArrayLike) – The drift Hamiltonian. Must be a square matrix of dimension dim.

  • control_hamiltonians (ArrayLike) – The control Hamiltonians. Can either by a 3D array with shape (n_ctrl, dim, dim) representing a stack of control Hamiltonians indexed by the first axis. Alternatively a 3D array with shape (n_ctrl * dim, dim) can be passed with the control Hamiltonians being concatenated along the first axis.

  • sparse (bool, optional) – Whether to use sparse matrices for the evolution. The default is False.

  • force_dynamic (bool, optional) – Whether to force the use of dynamically sized matrices for the evolution. The default is False.

Returns:

An instance of a child class of evolvers.UnitaryEvolver. If sparse == False then the returned instance will be a child class of evolvers.DenseUnitaryEvolver else evolvers.SparseUnitaryEvolver is returned. Both evolvers.DenseUnitaryEvolver and evolvers.SparseUnitaryEvolver are dynamic evolvers: evolvers for which the number of control Hamiltonians and the vector space dimension are determined at runtime based on the shapes of drift_hamiltonian and control_hamiltonians. If possible get_unitary_evolver() will return an instance of evolvers.DenseUnitaryEvolver_nctrl_dim or evolvers.SparseUnitaryEvolver_nctrl_dim, where nctrl and dim are substituted for their corresponding values. These are fixed evolvers where the number of controls (nctrl) and the vector space dimension (dim) are know at the C++ compile time allowing for more efficient C++ methods to be compiled.

Note

An instance of evolvers.UnitaryEvolver itself will never be returned. evolvers.UnitaryEvolver is simply a base class for all evolvers allowing for checks such as:

isinstance(evolver, evolvers.UnitaryEvolver)

Return type:

evolvers.UnitaryEvolver

Raises:
  • ValueErrordrift_hamiltonian must be 2D.

  • ValueErrordrift_hamiltonian must be square.

  • ValueError – The control Hamiltonians (control_hamiltonians) must have the same number of columns as drift_hamiltonian.

  • ValueErrorcontrol_hamiltonians must be 2D or 3D.

  • ValueError – Each control Hamiltonian in control_hamiltonians must have the same dimension as drift_hamiltonian.