{ } Raw JSON

bundles / scipy 1.17.1 / scipy / linalg / _decomp_update / qr_delete

function

scipy.linalg._decomp_update:qr_delete

Summary

QR downdate on row or column deletions

Extended Summary

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.

The documentation is written assuming array arguments are of specified "core" shapes. However, array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details. Note that calls with zero-size batches are unsupported and will raise a ValueError.

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 appropriately 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

Notes

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

Examples

import numpy as np
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
r1
The update is equivalent, but faster than the following.
a1 = np.delete(a, slice(2,4), 0)
a1
q_direct, r_direct = linalg.qr(a1)
Check that we have equivalent results:
np.dot(q1, r1)
np.allclose(np.dot(q1, r1), a1)
And the updated Q is still unitary:
np.allclose(np.dot(q1.T, q1), np.eye(3))

See also

qr
qr_insert
qr_multiply
qr_update

Aliases

  • scipy.linalg.qr_delete

Referenced by

This package