bundles / scipy 1.17.1 / scipy / linalg / _decomp_update / qr_insert
function
scipy.linalg._decomp_update:qr_insert
Signature
def qr_insert ( Q , R , u , k , which = row , rcond = None , overwrite_qru = False , check_finite = True ) Summary
QR update on row or column insertions
Extended Summary
If A = Q R is the QR factorization of A, return the QR factorization of A where rows or columns have been inserted 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) array_likeUnitary/orthogonal matrix from the QR decomposition of A.
R: (M, N) array_likeUpper triangular matrix from the QR decomposition of A.
u: (N,), (p, N), (M,), or (M, p) array_likeRows or columns to insert
k: intIndex before which
uis to be inserted.which: {'row', 'col'}, optionalDetermines if rows or columns will be inserted, defaults to 'row'
rcond: floatLower bound on the reciprocal condition number of
Qaugmented withu/||u||Only used when updating economic mode (thin, (M,N) (N,N)) decompositions. If None, machine precision is used. Defaults to None.overwrite_qru: bool, optionalIf True, consume Q, R, and u, if possible, while performing the update, otherwise make copies as necessary. Defaults to False.
check_finite: bool, optionalWhether to check that the input matrices contain 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
Raises
: LinAlgErrorIf updating a (M,N) (N,N) factorization and the reciprocal condition number of Q augmented with
u/||u||is smaller than rcond.
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., -7., 4.], [ 7., 8., -6.]]) q, r = linalg.qr(a)✓
u = np.array([[ 6., -9., -3.], [ -3., 10., 1.]]) q1, r1 = linalg.qr_insert(q, r, u, 2, 'row')✓
q1 r1✗
a1 = np.insert(a, 2, u, 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(5))
✓See also
Aliases
-
scipy.linalg.qr_insert