# scipy 1.18.1 (BSD-3-Clause), harvested by tools/harvest_corpus.py
=== input

    Compute RQ decomposition of a matrix.

    Calculate the decomposition ``A = R Q`` where Q is unitary/orthogonal
    and R upper triangular.

    Parameters
    ----------
    a : (M, N) array_like
        Matrix to be decomposed
    overwrite_a : bool, optional
        Whether to overwrite data in `a` (may improve performance). Default is False.
        See :ref:`tutorial_linalg_overwrite` for details.
    lwork : int, optional
        Work array size, lwork >= a.shape[1]. If None or -1, an optimal size
        is computed.
    mode : {'full', 'r', 'economic'}, optional
        Determines what information is to be returned: either both Q and R
        ('full', default), only R ('r') or both Q and R but computed in
        economy-size ('economic', see Notes).
    check_finite : bool, optional
        Whether to check that the input matrix contains only finite numbers.
        Disabling may give a performance gain, but may result in problems
        (crashes, non-termination) if the inputs do contain infinities or NaNs.

    Returns
    -------
    R : float or complex ndarray
        Of shape (M, N) or (M, K) for ``mode='economic'``. ``K = min(M, N)``.
    Q : float or complex ndarray
        Of shape (N, N) or (K, N) for ``mode='economic'``. Not returned
        if ``mode='r'``.

    Raises
    ------
    LinAlgError
        If decomposition fails.

    Notes
    -----
    This is an interface to the LAPACK routines sgerqf, dgerqf, cgerqf, zgerqf,
    sorgrq, dorgrq, cungrq and zungrq.

    If ``mode=economic``, the shapes of Q and R are (K, N) and (M, K) instead
    of (N,N) and (M,N), with ``K=min(M,N)``.

    Examples
    --------
    >>> import numpy as np
    >>> from scipy import linalg
    >>> rng = np.random.default_rng()
    >>> a = rng.standard_normal((6, 9))
    >>> r, q = linalg.rq(a)
    >>> np.allclose(a, r @ q)
    True
    >>> r.shape, q.shape
    ((6, 9), (9, 9))
    >>> r2 = linalg.rq(a, mode='r')
    >>> np.allclose(r, r2)
    True
    >>> r3, q3 = linalg.rq(a, mode='economic')
    >>> r3.shape, q3.shape
    ((6, 6), (6, 9))

    
=== parse numpydoc
short_description: 'Compute RQ decomposition of a matrix.'
long_description: |
  Calculate the decomposition ``A = R Q`` where Q is unitary/orthogonal
  and R upper triangular.
blank_after_short_description: True
blank_after_long_description: True
style: numpydoc
- DocstringParam
  description: 'Matrix to be decomposed'
  kind: param
  key: 'param'
  arg_name: 'a'
  type_name: '(M, N) array_like'
  is_optional: False
- DocstringParam
  description: |
    Whether to overwrite data in `a` (may improve performance). Default is False.
    See :ref:`tutorial_linalg_overwrite` for details.
  kind: param
  key: 'param'
  arg_name: 'overwrite_a'
  type_name: 'bool'
  is_optional: True
  default: 'False'
  raw_type_name: 'bool, optional'
- DocstringParam
  description: |
    Work array size, lwork >= a.shape[1]. If None or -1, an optimal size
    is computed.
  kind: param
  key: 'param'
  arg_name: 'lwork'
  type_name: 'int'
  is_optional: True
  raw_type_name: 'int, optional'
- DocstringParam
  description: |
    Determines what information is to be returned: either both Q and R
    ('full', default), only R ('r') or both Q and R but computed in
    economy-size ('economic', see Notes).
  kind: param
  key: 'param'
  arg_name: 'mode'
  type_name: "{'full', 'r', 'economic'}"
  is_optional: True
  raw_type_name: "{'full', 'r', 'economic'}, optional"
- DocstringParam
  description: |
    Whether to check that the input matrix contains only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.
  kind: param
  key: 'param'
  arg_name: 'check_finite'
  type_name: 'bool'
  is_optional: True
  raw_type_name: 'bool, optional'
- DocstringReturns
  description: "Of shape (M, N) or (M, K) for ``mode='economic'``. ``K = min(M, N)``."
  kind: returns
  key: 'returns'
  type_name: 'float or complex ndarray'
  is_generator: False
  return_name: 'R'
- DocstringReturns
  description: |
    Of shape (N, N) or (K, N) for ``mode='economic'``. Not returned
    if ``mode='r'``.
  kind: returns
  key: 'returns'
  type_name: 'float or complex ndarray'
  is_generator: False
  return_name: 'Q'
- DocstringRaises
  description: 'If decomposition fails.'
  kind: raises
  key: 'raises'
  type_name: 'LinAlgError'
- DocstringMeta
  description: |
    This is an interface to the LAPACK routines sgerqf, dgerqf, cgerqf, zgerqf,
    sorgrq, dorgrq, cungrq and zungrq.
    
    If ``mode=economic``, the shapes of Q and R are (K, N) and (M, K) instead
    of (N,N) and (M,N), with ``K=min(M,N)``.
  kind: text
  key: 'notes'
  title: 'Notes'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> import numpy as np'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> from scipy import linalg'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> rng = np.random.default_rng()'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> a = rng.standard_normal((6, 9))'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> r, q = linalg.rq(a)'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> np.allclose(a, r @ q)
    True
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> r.shape, q.shape
    ((6, 9), (9, 9))
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: ">>> r2 = linalg.rq(a, mode='r')"
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> np.allclose(r, r2)
    True
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: ">>> r3, q3 = linalg.rq(a, mode='economic')"
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> r3.shape, q3.shape
    ((6, 6), (6, 9))
=== detect
numpydoc
=== compose numpydoc
Compute RQ decomposition of a matrix.

Calculate the decomposition ``A = R Q`` where Q is unitary/orthogonal
and R upper triangular.

Parameters
----------
a : (M, N) array_like
    Matrix to be decomposed
overwrite_a : bool, optional
    Whether to overwrite data in `a` (may improve performance). Default is False.
    See :ref:`tutorial_linalg_overwrite` for details.
lwork : int, optional
    Work array size, lwork >= a.shape[1]. If None or -1, an optimal size
    is computed.
mode : {'full', 'r', 'economic'}, optional
    Determines what information is to be returned: either both Q and R
    ('full', default), only R ('r') or both Q and R but computed in
    economy-size ('economic', see Notes).
check_finite : bool, optional
    Whether to check that the input matrix contains only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
R : float or complex ndarray
    Of shape (M, N) or (M, K) for ``mode='economic'``. ``K = min(M, N)``.
Q : float or complex ndarray
    Of shape (N, N) or (K, N) for ``mode='economic'``. Not returned
    if ``mode='r'``.

Raises
------
LinAlgError
    If decomposition fails.

Notes
-----
This is an interface to the LAPACK routines sgerqf, dgerqf, cgerqf, zgerqf,
sorgrq, dorgrq, cungrq and zungrq.

If ``mode=economic``, the shapes of Q and R are (K, N) and (M, K) instead
of (N,N) and (M,N), with ``K=min(M,N)``.

Examples
--------
>>> import numpy as np
>>> from scipy import linalg
>>> rng = np.random.default_rng()
>>> a = rng.standard_normal((6, 9))
>>> r, q = linalg.rq(a)
>>> np.allclose(a, r @ q)
True
>>> r.shape, q.shape
((6, 9), (9, 9))
>>> r2 = linalg.rq(a, mode='r')
>>> np.allclose(r, r2)
True
>>> r3, q3 = linalg.rq(a, mode='economic')
>>> r3.shape, q3.shape
((6, 6), (6, 9))
