qr

Contents

qr#

class saiunit.lax.qr(x)#

QR decomposition.

Compute the QR decomposition \(A = Q \cdot R\) where \(Q\) is a unitary (orthogonal) matrix and \(R\) is upper-triangular.

Parameters:

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

Return type:

tuple[Array, saiunit.Quantity | Array]

Returns:

  • q (jax.Array) – The unitary factor (unitless) with shape [..., m, min(m, n)].

  • r (jax.Array or Quantity) – The upper-triangular factor with shape [..., min(m, n), n]. If x has a unit, r preserves that unit.

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.meter
>>> q, r = sulax.qr(A)
>>> u.get_unit(r) == u.meter
True