function xyz_to_h_test ( )

%*****************************************************************************80
%
%% xyz_to_h_test() tests xyz_to_h().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 July 2024
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'xyz_to_h_test():\n' );
  fprintf ( 1, '  xyz_to_h() converts a 3D Hilbert curve lattice point\n' );
  fprintf ( 1, '  (x,y,z) to a linear coordinate H.\n' );

  r = 1;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  r = %d\n', r );
  fprintf ( 1, '   i   x   y   z   h\n' );
  fprintf ( 1, '\n' );

  hmax = 2^(3*r)-1;

  for h = 0 : hmax
    [ x, y, z ] = h_to_xyz ( h, r );
    h2 = xyz_to_h ( x, y, z, r );
    fprintf ( 1, '  %2d  %2d  %2d  %2d  %2d\n', h, x, y, z, h2 );
  end
%
%  Level 2.
%
  r = 2;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  r = %d\n', r );
  fprintf ( 1, '   i   x   y   z   h\n' );
  fprintf ( 1, '\n' );

  hmax = 2^(3*r)-1;

  for h = 0 : hmax
    [ x, y, z ] = h_to_xyz ( h, r );
    h2 = xyz_to_h ( x, y, z, r );
    fprintf ( 1, '  %2d  %2d  %2d  %2d  %2d\n', h, x, y, z, h2 );
  end

  return
end

