#### Previous topic

scipy.linalg.qr_update

#### Next topic

scipy.linalg.qr_insert

# scipy.linalg.qr_delete

`scipy.linalg.``qr_delete`(Q, R, k, p=1, which='row', overwrite_qr=False, check_finite=True)

  QR downdate on row or column deletions

  If `A = Q R` is the QR factorization of `A`, return the QR factorization of `A` where `p` rows or columns have been removed starting at row or column `k`.

  Parameters: | Q : (M, M) or (M, N) array_like Unitary/orthogonal matrix from QR decomposition. R : (M, N) or (N, N) array_like Upper triangular matrix from QR decomposition. k : int Index of the first row or column to delete. p : int, optional Number of rows or columns to delete, defaults to 1. which: {‘row’, ‘col’}, optional Determines if rows or columns will be deleted, defaults to ‘row’ overwrite_qr : bool, optional If True, consume Q and R, overwriting their contents with their downdated versions, and returning approriately sized views. Defaults to False. 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. Default is True.
  Returns: | Q1 : ndarray Updated unitary/orthogonal factor R1 : ndarray Updated upper triangular factor

  See also

  `qr`, `qr_multiply`, `qr_insert`, `qr_update`

  Notes

  This routine does not guarantee that the diagonal entries of `R1` are positive.

  New in version 0.16.0.

  References

  [R90] | Golub, G. H. & Van Loan, C. F. Matrix Computations, 3rd Ed. (Johns Hopkins University Press, 1996).

  [R91] | Daniel, J. W., Gragg, W. B., Kaufman, L. & Stewart, G. W. Reorthogonalization and stable algorithms for updating the Gram-Schmidt QR factorization. Math. Comput. 30, 772-795 (1976).

  [R92] | Reichel, L. & Gragg, W. B. Algorithm 686: FORTRAN Subroutines for Updating the QR Decomposition. ACM Trans. Math. Softw. 16, 369-377 (1990).

  Examples

      >>> from scipy import linalg
      >>> a = np.array([[  3.,  -2.,  -2.],
      ...               [  6.,  -9.,  -3.],
      ...               [ -3.,  10.,   1.],
      ...               [  6.,  -7.,   4.],
      ...               [  7.,   8.,  -6.]])
      >>> q, r = linalg.qr(a)

  Given this QR decomposition, update q and r when 2 rows are removed.

      >>> q1, r1 = linalg.qr_delete(q, r, 2, 2, 'row', False)
      >>> q1
      array([[ 0.30942637,  0.15347579,  0.93845645],
             [ 0.61885275,  0.71680171, -0.32127338],
             [ 0.72199487, -0.68017681, -0.12681844]])
      >>> r1
      array([[  9.69535971,  -0.4125685 ,  -6.80738023],
             [  0.        , -12.19958144,   1.62370412],
             [  0.        ,   0.        ,  -0.15218213]])

  The update is equivalent, but faster than the following.

      >>> a1 = np.delete(a, slice(2,4), 0)
      >>> a1
      array([[ 3., -2., -2.],
             [ 6., -9., -3.],
             [ 7.,  8., -6.]])
      >>> q_direct, r_direct = linalg.qr(a1)

  Check that we have equivalent results:

      >>> np.dot(q1, r1)
      array([[ 3., -2., -2.],
             [ 6., -9., -3.],
             [ 7.,  8., -6.]])
      >>> np.allclose(np.dot(q1, r1), a1)
      True

  And the updated Q is still unitary:

      >>> np.allclose(np.dot(q1.T, q1), np.eye(3))
      True