function A = construct(m, n, f)
  %
  % Construct an m-by-n matrix with entries a_ij = f(i,j).
  %
  if ((m < 0) || (n < 0))
    A = NA;
    return;
  elseif ((m == 0) || (n == 0))
    A = NA;
    return;
  end

  A = zeros(m,n);

  for i = [ 1 : m ]
    for j = [ 1 : n ]
      A(i,j) = f(i,j);
    end
  end
end
