Exponentiation backend

Exponentiation backend#

phasegen makes heavy use of matrix exponentiation to compute quantities of interest. You can choose between different exponentiation backends for this purpose. The default is SciPyExpmBackend which uses SciPy’s expm function. One alternative, which is often faster, especially when parallelization is enabled, is TensorFlowExpmBackend. To switch to the TensorFlow backend, you need to install TensorFlow which is an optional dependency of phasegen due to its heavy weight. To install everything in one go, you can use the following conda environment file:

name: phasegen
channels:
  - defaults
dependencies:
  - python>=3.10,<3.13
  - tensorflow
  - pip
  - pip:
      - phasegen

After installation you can use register the backend as follows:

import phasegen as pg

pg.Backend.register(pg.TensorFlowExpmBackend())