function [u,b,v]=BiDiag(A)
[m,n]=size(A); n1=min(m,n);
u1=Householder(A(:,1));
b=u1*A; A1=b';
a=A1(2:n,1); v2=Householder(a);
v1(2:n,2:n)=v2';
v1(1,1)=1; b=b*v1; u=u1;v=v1;
for i=2:n1-2
    a=b(i:m,i); 
    clear u1;
    u1(1:i-1,1:i-1)=eye(i-1);
    u1(i:m,i:m)=Householder(a);
    b=u1*b; A1=b'; a1=A1(i+1:n,i);
    v2=Householder(a1);
    clear v1;
    v1(1:i,1:i)=eye(i);
    v1(i+1:n,i+1:n)=v2';
    b=b*v1; u=u*u1; v=v*v1;
end
a=b(n1-1:m,n1-1);
clear u1;
u1(1:n1-2,1:n1-2)=eye(n1-2);
u1(n1-1:m,n1-1:m)=Householder(a);
b=u1*b; u=u*u1;
if (m>n)
    a=b(n:m,n); 
    clear u1;
    u1(1:n-1,1:n-1)=eye(n-1);
    u1(n:m,n:m)=Householder(a);
    b=u1*b; u=u*u1;
end
if(m<n)
    A1=b'; a1=A1(n1:n,n1-1); v2=Householder(a1);
    clear v1;
    v1(1:n1-1,1:n1-1)=eye(n1-1);
    v1(n1:n,n1:n)=v2'; b=b*v1; v=v*v1;
    A1=b'; a1=A1(n1+1:n,n1); v2=Householder(a1);
    clear v1;
    v1(1:n1,1:n1)=eye(n1);
    v1(n1+1:n,n1+1:n)=v2'; b=b*v1;v=v*v1;
end
    

    
    
    
