jax.numpy.linalg.qr

Contents

jax.numpy.linalg.qr#

jax.numpy.linalg.qr(a, mode='reduced')[source]#

Compute the qr factorization of a matrix.

LAX-backend implementation of numpy.linalg.qr().

Original docstring below.

Factor the matrix a as qr, where q is orthonormal and r is upper-triangular.

Parameters:
  • a (array_like, shape (..., M, N)) – An array-like object with the dimensionality of at least 2.

  • mode ({'reduced', 'complete', 'r', 'raw'}, optional) –

    If K = min(M, N), then

    • ’reduced’ : returns Q, R with dimensions (…, M, K), (…, K, N) (default)

    • ’complete’ : returns Q, R with dimensions (…, M, M), (…, M, N)

    • ’r’ : returns R only with dimensions (…, K, N)

    • ’raw’ : returns h, tau with dimensions (…, N, M), (…, K,)

    The options ‘reduced’, ‘complete, and ‘raw’ are new in numpy 1.8, see the notes for more information. The default is ‘reduced’, and to maintain backward compatibility with earlier versions of numpy both it and the old default ‘full’ can be omitted. Note that array h returned in ‘raw’ mode is transposed for calling Fortran. The ‘economic’ mode is deprecated. The modes ‘full’ and ‘economic’ may be passed using only the first letter for backwards compatibility, but all others must be spelled out. See the Notes for more explanation.

Return type:

Array | QRResult

Returns:

  • When mode is ‘reduced’ or ‘complete’, the result will be a namedtuple with

  • the attributes Q and R.

  • Q (ndarray of float or complex, optional) – A matrix with orthonormal columns. When mode = ‘complete’ the result is an orthogonal/unitary matrix depending on whether or not a is real/complex. The determinant may be either +/- 1 in that case. In case the number of dimensions in the input array is greater than 2 then a stack of the matrices with above properties is returned.

  • R (ndarray of float or complex, optional) – The upper-triangular matrix or a stack of upper-triangular matrices if the number of dimensions in the input array is greater than 2.

  • (h, tau) (ndarrays of np.double or np.cdouble, optional) – The array h contains the Householder reflectors that generate q along with r. The tau array contains scaling factors for the reflectors. In the deprecated ‘economic’ mode only h is returned.