function haar_test ( )

%*****************************************************************************80
%
%% haar_test() tests haar(), haarin() and hnorm().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 March 2011
%
%  Author:
%
%    John Burkardt
%
  n = 16;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'haar_test():\n' );
  fprintf ( 1, '  haar() computes a Haar transform.\n' );
  fprintf ( 1, '  hnorm() normalizes the transformed data.\n' );
  fprintf ( 1, '  haarin() computes an inverse Haar transform.\n' );

  for j = 1 : 2

    if ( j == 1 )
      w = rand ( 1, n );
    else
      w(1:n) = 1 : n;
    end

    x(1:n) = w(1:n);

    w = haar ( n, w );

    y(1:n) = w(1:n);

    w = hnorm ( n, w );

    z(1:n) = w(1:n);

    w = haarin ( n, w );

    fprintf ( 1, '\n' );
    fprintf ( 1, '     I        X(I)    Y=HAAR(X)  Z=HNORM(Y)  W=HAARIN(Z)\n' );
    fprintf ( 1, '\n' );
    for i = 1 : n
      fprintf ( 1, '  %4d  %10f  %10f  %10f  %10f\n', i, x(i), y(i), z(i), w(i) );
    end

  end

  return
end
