eigh

Contents

eigh#

class brainunit.lax.eigh(x, lower=True, symmetrize_input=True, sort_eigenvalues=True, subset_by_index=None)#

Eigendecomposition of a Hermitian matrix.

Compute the eigenvectors and eigenvalues of a complex Hermitian or real symmetric square matrix.

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

  • lower (bool) – When symmetrize_input is False, selects which triangle of the input to use. Default is True.

  • symmetrize_input (bool) – If True, the matrix is symmetrized before the eigendecomposition by computing \(\frac{1}{2}(x + x^H)\). Default is True.

  • sort_eigenvalues (bool) – If True, eigenvalues are sorted in ascending order. Default is True.

  • subset_by_index (tuple[int, int] | None) – A (start, end) pair selecting a range of eigenvalue indices to compute. None means all eigenvalues. Default is None.

Return type:

tuple[saiunit.Quantity | Array, Array]

Returns:

  • v (jax.Array) – Eigenvectors (unitless). v[..., :, i] is the normalised eigenvector for eigenvalue w[..., i].

  • w (jax.Array or Quantity) – Eigenvalues in ascending order. If x has a unit, w preserves that unit.

Examples

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