function d = decompose_array (ar)
%
% decompose_array: decomposes a row/col in a Haar wavelet decomposition
% On input:
%     ar: 2D array
% On output:
%     d: decomposition
% Call:
%     d = decompose_array (ar)
%

h = length(ar);

ar = ar / sqrt(h);

while h > 1
  h = h / 2;
  for i1 = 1:h
    ar2(i1) = (ar(2*i1-1) + ar(2*i1)) / sqrt(2); 
    ar2(h+i1) = (ar(2*i1-1) - ar(2*i1)) / sqrt(2);
  end
  ar = ar2;
end
	
     