eig#
- class saiunit.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) – IfTrue, compute the left eigenvectors. Default isTrue.compute_right_eigenvectors (
bool) – IfTrue, compute the right eigenvectors. Default isTrue.
- 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
xhas a unit,wpreserves that unit.vl (jax.Array, optional) – The left eigenvectors (unitless). Only returned when
compute_left_eigenvectorsisTrue.vr (jax.Array, optional) – The right eigenvectors (unitless). Only returned when
compute_right_eigenvectorsisTrue.
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