Home > K25104 > LinearSystems > deflation_Householder_2.m

deflation_Householder_2

PURPOSE ^

Given an nxn matrix A which has a 2-dimensional eigenspace

SYNOPSIS ^

function [ D ] = deflation_Householder_2( A,v1,v2 )

DESCRIPTION ^

 Given an nxn matrix A which has a 2-dimensional eigenspace 
   spanned by v1 and v2, the function performs deflation creating 
   an nxn matrix which is similar to A. That is it has the same 
   eigenvalues as A. Householder reflections are used.
 Input arguments:
   A, square matrix
   v1,v2, two vectors which span a known eigenspace of A
 Output arguments:
   D, deflated matrix. If A is symmetric, then D will also be symmetric

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ D ] = deflation_Householder_2( A,v1,v2 )
0002 % Given an nxn matrix A which has a 2-dimensional eigenspace
0003 %   spanned by v1 and v2, the function performs deflation creating
0004 %   an nxn matrix which is similar to A. That is it has the same
0005 %   eigenvalues as A. Householder reflections are used.
0006 % Input arguments:
0007 %   A, square matrix
0008 %   v1,v2, two vectors which span a known eigenspace of A
0009 % Output arguments:
0010 %   D, deflated matrix. If A is symmetric, then D will also be symmetric
0011 
0012 [n,m]=size(A);  % finding the size of A
0013 [p,q]=size(v1); % finding the size of v1
0014 [r,s]=size(v2); % finding the size of v2
0015 if n~= m;
0016     error('input is not a square matrix');
0017 elseif p~=n || q~=1 || r~=n || s~=1;
0018     error('input dimensions do not agree');
0019 end
0020 
0021 u1=v1;              % initializing u1 to v1
0022 if v1(1)==0         % adjusting the first entry of u1
0023     u1(1)=u1(1)+sqrt(v1'*v1);
0024 else
0025     u1(1)=u1(1)+sign(v1(1))*sqrt(v1'*v1);    
0026 end
0027 S1=eye(n)-2*(u1*u1')/(u1'*u1);  % assembling S1, a householder reflection
0028                                 % which maps the bottom n-1 elements of v1
0029                                 % to zero
0030 
0031 v_hat=S1*v2;        % initializing v_hat to S1*v2
0032 v_hat=v_hat(2:n);   % letting v_hat be the lower n-1 entries of S1*v2
0033 u2=v_hat;           % initializing u2 to v_hat
0034 if v_hat(1) == 0    % adjusting the first entry of u2
0035     u2(1)=u2(1)+sqrt(v_hat'*v_hat);
0036 else
0037     u2(1)=u2(1)+sign(v_hat(1))*sqrt(v_hat'*v_hat);  
0038 end
0039 S_hat=eye(n-1)-2*(u2*u2')/(u2'*u2); % assembing S_hat, a householder
0040                     % reflection which maps the bottom n-2 elements of
0041                     % v_hat to zero
0042                     
0043 S2=eye(n);          % initializing S2 to the identity
0044 S2(2:n,2:n)=S_hat;  % setting the bottom-right (n-1)x(n-1) submatrix of S2
0045                     % to S_hat, so that S2*(S1*v2) is a linear combination
0046                     % of the first two standard basis vectors.
0047                     
0048 D=S2*S1*A*S1*S2;    % generating deflated matrix
0049 
0050 end
0051

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