bundles / scipy 1.17.1 / scipy / linalg / _decomp_update / qr_update
function
scipy.linalg._decomp_update:qr_update
Signature
def qr_update ( Q , R , u , v , overwrite_qruv = False , check_finite = True ) Summary
Rank-k QR update
Extended Summary
If A = Q R is the QR factorization of A, return the QR factorization of A + u v**T for real A or A + u v**H for complex A.
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 the qr decomposition of A.
R: (M, N) or (N, N) array_likeUpper triangular matrix from the qr decomposition of A.
u: (M,) or (M, k) array_likeLeft update vector
v: (N,) or (N, k) array_likeRight update vector
overwrite_qruv: bool, optionalIf True, consume Q, R, u, and v, if possible, while performing the update, otherwise make copies as necessary. 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 real or 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)✓
u = np.array([7., -2., 4., 3., 5.]) v = np.array([1., 3., -5.]) q_up, r_up = linalg.qr_update(q, r, u, v, False)✓
q_up r_up✗
a_up = a + np.outer(u, v) q_direct, r_direct = linalg.qr(a_up)✓
np.allclose(np.dot(q_up, r_up), a_up)
✓np.allclose(np.dot(q_up.T, q_up), np.eye(5))
✓qe, re = linalg.qr(a, mode='economic') qe_up, re_up = linalg.qr_update(qe, re, u, v, False)✓
qe_up re_up✗
np.allclose(np.dot(qe_up, re_up), a_up) np.allclose(np.dot(qe_up.T, qe_up), np.eye(3))✓
u2 = np.array([[ 7., -1,], [-2., 4.], [ 4., 2.], [ 3., -6.], [ 5., 3.]]) v2 = np.array([[ 1., 2.], [ 3., 4.], [-5., 2]]) q_up2, r_up2 = linalg.qr_update(q, r, u2, v2, False)✓
q_up2 r_up2✗
a_up2 = a + np.dot(u2, v2.T) np.allclose(a_up2, np.dot(q_up2, r_up2)) np.allclose(np.dot(q_up2.T, q_up2), np.eye(5))✓
See also
Aliases
-
scipy.linalg.qr_update