MCPcopy Index your code
hub / github.com/numpy/numpy / qr

Function qr

numpy/linalg/_linalg.py:977–1176  ·  view source on GitHub ↗

Compute the qr factorization of a matrix. 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',

(a, mode='reduced')

Source from the content-addressed store, hash-verified

975
976@array_function_dispatch(_qr_dispatcher)
977def qr(a, mode='reduced'):
978 """
979 Compute the qr factorization of a matrix.
980
981 Factor the matrix `a` as *qr*, where `q` is orthonormal and `r` is
982 upper-triangular.
983
984 Parameters
985 ----------
986 a : array_like, shape (..., M, N)
987 An array-like object with the dimensionality of at least 2.
988 mode : {'reduced', 'complete', 'r', 'raw'}, optional, default: 'reduced'
989 If K = min(M, N), then
990
991 * 'reduced' : returns Q, R with dimensions (..., M, K), (..., K, N)
992 * 'complete' : returns Q, R with dimensions (..., M, M), (..., M, N)
993 * 'r' : returns R only with dimensions (..., K, N)
994 * 'raw' : returns h, tau with dimensions (..., N, M), (..., K,)
995
996 The options 'reduced', 'complete, and 'raw' are new in numpy 1.8,
997 see the notes for more information. The default is 'reduced', and to
998 maintain backward compatibility with earlier versions of numpy both
999 it and the old default 'full' can be omitted. Note that array h
1000 returned in 'raw' mode is transposed for calling Fortran. The
1001 'economic' mode is deprecated. The modes 'full' and 'economic' may
1002 be passed using only the first letter for backwards compatibility,
1003 but all others must be spelled out. See the Notes for more
1004 explanation.
1005
1006
1007 Returns
1008 -------
1009 Q : ndarray of float or complex, optional
1010 A matrix with orthonormal columns. When mode = 'complete' the
1011 result is an orthogonal/unitary matrix depending on whether or not
1012 a is real/complex. The determinant may be either +/- 1 in that
1013 case. In case the number of dimensions in the input array is
1014 greater than 2 then a stack of the matrices with above properties
1015 is returned.
1016 R : ndarray of float or complex, optional
1017 The upper-triangular matrix or a stack of upper-triangular
1018 matrices if the number of dimensions in the input array is greater
1019 than 2.
1020 (h, tau) : ndarrays of np.double or np.cdouble, optional
1021 The array h contains the Householder reflectors that generate q
1022 along with r. The tau array contains scaling factors for the
1023 reflectors. In the deprecated 'economic' mode only h is returned.
1024
1025 Raises
1026 ------
1027 LinAlgError
1028 If factoring fails.
1029
1030 See Also
1031 --------
1032 scipy.linalg.qr : Similar function in SciPy.
1033 scipy.linalg.rq : Compute RQ decomposition of a matrix.
1034

Callers

nothing calls this directly

Calls 12

errstateClass · 0.90
triuFunction · 0.90
_makearrayFunction · 0.85
_assert_stacked_2dFunction · 0.85
_commonTypeFunction · 0.85
_to_native_byte_orderFunction · 0.85
isComplexTypeFunction · 0.85
wrapFunction · 0.85
QRResultClass · 0.85
astypeMethod · 0.80
transposeFunction · 0.70
minFunction · 0.50

Tested by

no test coverage detected