function [t,w,gamma,B,b]=incremental2(A,d,nu,B,b,flag);

%[t,w,gamma,B]=incremental2(A,d,nu,B,flag);
%for the first time  [t,w,gamma,B]=incremental2(A,d,nu);
%for one increment flag=0;
%for final increment flag=1;

tic;
[m,n]=size(A);e=ones(m,1);
H=[A -e];
w=0;gamma=0;
if nargin==3

    B=H'*H;
    b=(d'*H)';
    t=toc;
    
else   
   
    B=B+H'*H;
    b=b+(d'*H)';
    if flag~=0
        
        
        B=(speye(n+1)/nu+B);
        v=B\b;
        w=v(1:n);gamma=v(n+1);
    end
    t=toc;
end

return
        
        
        
       





w=v(1:n);
gamma=v(n+1);
t=toc;



return