Home > K25104 > LinearSystems > QR_Givens_zeros.m

QR_Givens_zeros

PURPOSE ^

Computes the QR factorization of A via Givens rotations

SYNOPSIS ^

function [ Q,R ] = QR_Givens_zeros( A,v )

DESCRIPTION ^

 Computes the QR factorization of A via Givens rotations
   using knowledge about leading zeros
 Input arguments:
   A, matrix
   v, vector giving number of leading zeros in each row of A
 Output arguments:
   Q, square orthogonal matrix
   R, upper triangular

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ Q,R ] = QR_Givens_zeros( A,v )
0002 % Computes the QR factorization of A via Givens rotations
0003 %   using knowledge about leading zeros
0004 % Input arguments:
0005 %   A, matrix
0006 %   v, vector giving number of leading zeros in each row of A
0007 % Output arguments:
0008 %   Q, square orthogonal matrix
0009 %   R, upper triangular
0010 
0011 [n,~]=size(A);  % finding the size of A
0012 
0013 if size(v,1)~=n;
0014     error('dimensions of vector are not consistent');
0015 end
0016 
0017 R=A; Q=eye(n);  % initializing matrices
0018 
0019 for i=2:n;              % considering the rows in turn
0020     for j=v(i)+1:i-1    % ignore the first v(i) entries in the row, since
0021                         % we know they are all zero
0022         if R(i,j)~=0;   % if the element is non-zero
0023             [R,G]=Givens(R,i,j);    % call function which introduces a
0024                 % zero in the (i,j)th entry of R using a Givens rotation.
0025             Q=Q*G';     % keep track of Q
0026         end
0027     end
0028 end

Generated on Mon 18-Jan-2016 10:25:49 by m2html © 2005