jax.lax.linalg.qr#
- jax.lax.linalg.qr(x: ArrayLike, *, pivoting: Literal[False], full_matrices: bool = True, use_magma: bool | None = None) tuple[Array, Array][source]#
- jax.lax.linalg.qr(x: ArrayLike, *, pivoting: Literal[True], full_matrices: bool = True, use_magma: bool | None = None) tuple[Array, Array, Array]
- jax.lax.linalg.qr(x: ArrayLike, *, pivoting: bool = False, full_matrices: bool = True, use_magma: bool | None = None) tuple[Array, Array] | tuple[Array, Array, Array]
QR decomposition.
Computes the QR decomposition
\[A = Q \, R\]of matrices \(A\), such that \(Q\) is a unitary (orthogonal) matrix, and \(R\) is an upper-triangular matrix.
- Parameters:
x – A batch of matrices with shape
[..., m, n].pivoting – Allows the QR decomposition to be rank-revealing. If
True, compute the column pivoted decompositionA[:, P] = Q @ R, wherePis chosen such that the diagonal ofRis non-increasing. Currently supported on CPU and GPU backends only.full_matrices – Determines if full or reduced matrices are returned; see below.
use_magma – Locally override the
jax_use_magmaflag. IfTrue, the pivoted qr factorization is computed using MAGMA. IfFalse, the computation is done using LAPACK on the host CPU. IfNone(default), the behavior is controlled by thejax_use_magmaflag. This argument is only used on GPU.
- Returns:
A pair of arrays
(q, r), ifpivoting=False, otherwise(q, r, p).Array
qis a unitary (orthogonal) matrix, with shape[..., m, m]iffull_matrices=True, or[..., m, min(m, n)]iffull_matrices=False.Array
ris an upper-triangular matrix with shape[..., m, n]iffull_matrices=True, or[..., min(m, n), n]iffull_matrices=False.Array
pis an index vector with shape […, n]
Notes
MAGMA support is experimental - see
jax.lax.linalg.eig()for further assumptions and limitations.If
jax_use_magmais set to"auto", the MAGMA implementation will be used if the library can be found, and the input matrix is sufficiently large (has at least 2048 columns).