%% .... This function evaluates vector kx (resp kx-kx') ....
function y = fkxi(x)
  global nr nc mnu n0 p kx
  summol = 0;   % sum mol.
  kxi = zeros(nr,1);
  y   = zeros(1,nr);
  smnu= zeros(nr,1);
  %%.... Composition (mol)
  %% ... old fashion way :-)
  %  for i = 1:nc
  %    ni(i) = 0;
  %    for j = 1:nr
  %      ni(i) = ni(i) + mnu(j,i)*x(j);
  %    end
  %    ni(i) = n0(i) +  ni(i);
  %  end
  ni = n0 + (x'*mnu)';
  
  %%.... Sum of mols and stech. coef.
  summol = sum(ni);
  
  for i = 1:nr
      smnu(i) =sum(mnu(i,:));
  end
  
  %%.... Vypocet rovnovaznych konstant reakci
  for i = 1:nr
      kxi(i) = 1;
      for j = 1:nc
          kxi(i) = kxi(i)*ni(j)^mnu(i,j);
      end
      kxi(i) = kxi(i)*(p/summol)^smnu(i);
  end
%  for i = 1:nr
      y = kxi - kx;
%  end
end   %% function fkxi
