function haar_test02 ( )

%*****************************************************************************80
%
%% haar_test02() tests haar_2d() and haar_2d_inverse().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 January 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'haar_test02():\n' );
  fprintf ( 1, '  HAAR_2D computes the Haar transform of an array.\n' );
  fprintf ( 1, '  HAAR_2D_INVERSE inverts the transform.\n' );
%
%  Demonstrate successful inversion.
%
  m = 16;
  n = 4;
  u = rand ( m, n );

  r8mat_print ( m, n, u, '  Input array U:' );

  v = haar_2d ( u );

  r8mat_print ( m, n, v, '  Transformed array V:' );

  w = haar_2d_inverse ( v );

  r8mat_print ( m, n, w, '  Recovered array W:' );
%
%  M, N not powers of 2.
%
  m = 37;
  n = 53;
  u = rand ( m, n );
  v = haar_2d ( u );
  w = haar_2d_inverse ( v );
  err = norm ( u - w );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  M = %d, N = %d, |haar_2d_inverse(haar_2d(u))-u| = %g\n', m, n, err );

  return
end
