function [xls_new, Pinvsr_new ] = bqr_rls( Pinvsr, xls, a, y ) % function [xls_new, Pinvsr_new ] = bqr_rls( Pinvsr, xls, a, y ) % % Block QR version of recursive least-squares estimator for solving y=Px. % 'a' are new rows of matrix P, and 'y' are the associated target values. % % 'Pinvsr' is the square root of Pinv=(P'*P)^-1, % and should be LOWER triangular (Pinvsr*Pinvsr'=Pinv). % 'a' should be specified as a column vector. % 'y' may be a row vector, in which case 'xls' will be a matrix. % % This version does not include a forgetting factor. % % D. Wingate 5/12/2006 % err = y - a'*xls; n = size(Pinvsr,1); nrows = size( a, 2 ); M = [ eye(nrows), a'*Pinvsr ; zeros( n, nrows ), Pinvsr ]; % [Q,R] = qr( M ); R = triu( qr( M' ) ); Pinvsr_new = R( 1+nrows:nrows+n, 1+nrows:nrows+n )'; Kt = R(1:nrows, 1+nrows:nrows+n )' * inv( R(1:nrows,1:nrows)' ); xls_new = xls + Kt * err; return;