function ret = D(w, h)
  function ret = d(x1, y1, x2, y2)
    ret = abs(x1 - x2) + abs(y1 - y2);
  endfunction

  function ret = r(x, y)
    a = [];
    for ig = (1:w)
      for jg = (1:h)
        a = [a, d(x, y, ig, jg)];
      endfor
    endfor
    ret = a;
  endfunction

   k = [];
   for i = (1:w)
     for j = (1:h)
       k = [k; r(i, j)];
     endfor
   endfor
   ret = k;
endfunction
