%hilbert  - Krsek: Produce N-by-N Hilbert matrix
%
%    function [h, sz] = hilbert (n)
%
%    The function produce N-by-N hilbert matrix.
%
%    Input:
%      N  ... Size of produced matrix.
%    Output:
%      h  ... N-by-N hilbert matrix.
%      sz ... size of outpub hilbert matrix.
%
% See also:  ONES, ZEROS.


function [h, sz] = hilbert(n)

if exist('n','var'),
  n = n(1);
  %h = ones(n,1)*[1:n] + [1:n]'*ones(1,n) - 1;
  h = getxy(n);
  h = 1./h;
else
  h = [];   
end

if (nargout > 1),
  sz = size(h);
end;

return

function x = getxy(n)
  
x = ones(n,1)*(1:n) + (1:n)'*ones(1,n) - 1;

return