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_likeUnitary/orthogonal matrix from QR decomposition.
R: (M, N) or (N, N) array_likeUpper triangular matrix from QR decomposition.
k: intIndex of the first row or column to delete.
p: int, optionalNumber of rows or columns to delete, defaults to 1.
which: {'row', 'col'}, optionalDetermines if rows or columns will be deleted, defaults to 'row'
overwrite_qr: bool, optionalIf True, consume Q and R, overwriting their contents with their downdated versions, and returning appropriately sized views. Defaults to False.
check_finite: bool, optionalWhether 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: ndarrayUpdated unitary/orthogonal factor
R1: ndarrayUpdated 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)✓
q1, r1 = linalg.qr_delete(q, r, 2, 2, 'row', False)
✓q1 r1✗
a1 = np.delete(a, slice(2,4), 0) a1 q_direct, r_direct = linalg.qr(a1)✓
np.dot(q1, r1) np.allclose(np.dot(q1, r1), a1)✓
np.allclose(np.dot(q1.T, q1), np.eye(3))
✓See also
Aliases
-
scipy.linalg.qr_delete