Skip to content

qrinsert

linear-algebra · scripts/linear-algebra/qrinsert.m

: [Q1, R1] = qrinsert (Q, R, j, x)
: [Q1, R1] = qrinsert (Q, R, j, x, orient)

Update a QR factorization after inserting a column or row into the factored matrix.

The inputs Q and R are the factors of some matrix A = Q*R, as produced by qr. With orient omitted or equal to "col", return the factorization of the matrix obtained by inserting the vector x as a new column of A before position j; x must then have as many elements as A has rows. With orient equal to "row", insert x as a new row before row j instead; x must then have as many elements as A has columns.

On return, Q1 has orthonormal columns and R1 is upper trapezoidal, so that Q1*R1 equals A with x inserted.

The index j must be a positive integer no larger than one plus the number of columns (respectively rows) of A; passing that largest value appends x after the existing columns (rows).