qr#
- class brainunit.linalg.qr(a, mode='reduced', **kwargs)#
Compute the QR decomposition of a matrix.
SaiUnit implementation of
numpy.linalg.qr().The QR decomposition of a matrix A is:
\[A = QR\]where Q is a unitary matrix (\(Q^HQ=I\)) and R is upper-triangular. The unit of A is carried by R; Q is always dimensionless.
- Parameters:
a (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – Input of shape(..., M, N).mode (
str) –Computational mode (default:
"reduced")."reduced"– Q has shape(..., M, K), R has shape(..., K, N)withK = min(M, N)."complete"– Q has shape(..., M, M), R has shape(..., M, N)."r"– only R is returned.
- Return type:
Array| saiunit.Quantity- Returns:
Q (ndarray) – Orthogonal factor (omitted when
mode="r").R (ndarray or Quantity) – Upper-triangular factor carrying the unit of a.
Examples
>>> import saiunit as u >>> import jax.numpy as jnp >>> a = jnp.array([[1., 2., 3., 4.], ... [5., 4., 2., 1.], ... [6., 3., 1., 5.]]) * u.meter >>> Q, R = u.linalg.qr(a) >>> Q.shape (3, 3) >>> R.unit meter