eig

Contents

eig#

class brainunit.lax.eig(x, compute_left_eigenvectors=True, compute_right_eigenvectors=True)#

Eigendecomposition of a general matrix.

Compute the eigenvalues and (optionally) left/right eigenvectors of a general square matrix. Non-symmetric eigendecomposition is currently only implemented on CPU.

Parameters:
  • x (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – A batch of square matrices with shape [..., n, n].

  • compute_left_eigenvectors (bool) – If True, compute the left eigenvectors. Default is True.

  • compute_right_eigenvectors (bool) – If True, compute the right eigenvectors. Default is True.

Return type:

tuple[Array | saiunit.Quantity, Array, Array] | list[Array] | tuple[Array | saiunit.Quantity, Array] | tuple[Array | saiunit.Quantity]

Returns:

  • w (jax.Array or Quantity) – The eigenvalues. If x has a unit, w preserves that unit.

  • vl (jax.Array, optional) – The left eigenvectors (unitless). Only returned when compute_left_eigenvectors is True.

  • vr (jax.Array, optional) – The right eigenvectors (unitless). Only returned when compute_right_eigenvectors is True.

Notes

If the eigendecomposition fails, arrays full of NaNs are returned for that batch element.

Examples

>>> import jax.numpy as jnp
>>> import saiunit as u
>>> import saiunit.lax as sulax
>>> A = jnp.array([[1.0, 2.0], [3.0, 4.0]]) * u.second
>>> w, vl, vr = sulax.eig(A)
>>> u.get_unit(w) == u.second
True