qrinsert
Updates a QR factorization after a column or row is inserted into the matrix.
Category: Mathematics > Linear Algebra
Syntax
[Q1, R1] = qrinsert(Q, R, j, x)
Returns the factorization of A with the column x inserted before column j.
[Q1, R1] = qrinsert(Q, R, j, x, 'row')
Inserts the row x before row j.
Description
The new column is transformed by Q' and spliced into R; Givens rotations then remove the unwanted entries below the diagonal. The cost is much lower than refactoring the whole matrix.
It is the inverse operation of qrdelete: deleting the column just inserted gives back the original factors, up to signs.
Input arguments
Q, R- Factors of a QR factorization
A = Q*R. j- Position at which the new column or row goes.
x- The column (or row) vector to insert, with the matching length.
Output arguments
Q1, R1- Factors of the enlarged matrix.
Example
Insert a column
A = magic(3);
[Q, R] = qr(A);
x = [1; 2; 3];
[Q1, R1] = qrinsert(Q, R, 2, x);
A1 = [A(:,1) x A(:,2:3)];
norm(Q1*R1 - A1) < 1e-10
Output
ans = logical
1