function [GG,gg] = Hsv(weights,N,dFa,NN,nn,xx,x0,lambda,bb)
%HESSIAN VECTOR product only relu and similar piecewise affine
gg=nn;GG=NN;
zz=xx;
%forward
i=1;
zz{i,1}=-dFa{i,1}.*(NN{i,1}*x0+nn{i,1}); 
for i=2:N
  w=weights{i,1};
  zz{i,1}=dFa{i,1}.*(w*zz{i-1})-dFa{i,1}.*(NN{i,1}*xx{i-1,1}+nn{i,1}); 
end

%backward
gam=bb;%init

gam{N,1}=-zz{N,1};
for i=N-1:-1:1
  w=weights{i+1,1};
  gam{i,1}=w'*(dFa{i+1,1}.*gam{i+1,1})-lambda*zz{i,1}-(NN{i+1,1})'*(dFa{i+1,1}.*bb{i+1,1});
end

    i=1;
    gg{i,1}=dFa{i,1}.*gam{i,1};
    GG{i,1}=(dFa{i,1}.*gam{i,1})*x0';

for i=2:N
    gg{i,1}=dFa{i,1}.*gam{i,1};
    GG{i,1}=(dFa{i,1}.*gam{i,1})*xx{i-1,1}'+(dFa{i,1}.*bb{i,1})*zz{i-1,1}';
end


end

