function [x,F]=centralpas(A,b,c,x_vn,tau,kk)
% riesenie linearneho programovania min c.x pri Ax=b, x>=0;A=mxn
%metodou centralpass, x_vn  je vutornym bodom nejakym (Ax_vn=b,x>0);
%k-pocet iteracii Newton-Gauss metodou;Z=nx(n-m)
[m,n]=size(A);
p_r=A\b;
Z=null(A,'3');
G=Z'*c';
r=n-m;d=zeros(r,1);d=zeros(r,1);x=zeros(n,kk);

q=zeros(r,kk);x=zeros(n,kk); vn=x_vn([1:n]);F=zeros(1,kk);
f=log(x_vn([1:n]));
F(1)=c*vn-tau*sum(f);
x([1:n],1)=x_vn([1:n]);
for k=1:kk
    R=Z*q(:,k);qq=0;
    for jj=1:r
    for i=1:n
   qq=qq+Z(i,jj)/(R(i)+x_vn(i));
    end
    Grad(jj)=G(jj)- tau*qq;
    end
    
    for ii=1:r
        for jj=1:r
            qh=0;
            for i=1:n
   qh=qh+Z(i,ii)*Z(i,jj)/(R(i)+x_vn(i))^2;
            end  
            Hes(ii,jj)=tau*qh;
        end
    end
    
    Delta_q=Hes\Grad';nm=norm(Delta_q,2);
    Delta_q=Delta_q/nm ;
    vv=Z*Delta_q;
    
    %vypocet pripustnosti
    v=x([1:n],k); gama=min(v);v=v-gama/4;
    alfa=1;
    for i=1:n
        if vv(i)>0
            alfa=min(alfa,v(i)/vv(i));
        end
    end
    
    q(:,k+1)=q(:,k)-alfa*Delta_q;x(:,k+1)=x_vn+Z*q(:,k+1);
    ff=log(x(:,k+1));
   F(:,k+1)= c*x(:,k+1)-tau*sum(ff);
end
