function data_bracket_test ( )

%*****************************************************************************80
%
%% data_bracket_test() tests data_bracket().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 May 2019
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'data_bracket_test():\n' );
  fprintf ( 1, '  data_bracket() finds a pair of entries in a\n' );
  fprintf ( 1, '  sorted real array which bracket a value.\n' );

  node_num = 11;
  node_x = 1 : node_num;
  node_x = node_x - 0.25;
  node_x(6) = node_x(5);
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Sorted array:\n' );
  fprintf ( 1, '\n' );
  for i = 1 : node_num
    fprintf ( 1, '  %2d  %f\n', i, node_x(i) );
  end

  data_num = 6;
  data_x(1:6) = [ -10.1, 1.2, 4.75, 5.2, 10.4, 12.5 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Values to be bracketed:\n' );
  fprintf ( 1, '\n' );
  for i = 1 : data_num
    fprintf ( 1, '  %2d  %f\n', i, data_x(i) );
  end

  [ data_l, data_r ] = data_bracket ( node_num, node_x, data_num, data_x );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Bracketing:\n' );
  for i = 1 : data_num
    fprintf ( 1, '\n' );
    if ( data_l(i) == -1 )
      fprintf ( 1, '               data_x(%d) = %6.2f  Outside the interval\n', i, data_x(i) );
    else
      fprintf ( 1, '  node_x(%d) <= data_x(%d) <= node_x(%d)\n', data_l(i), i, data_r(i) );
      fprintf ( 1, '  %f  <= %f <= %f\n', node_x(data_l(i)), data_x(i), node_x(data_r(i)) );
    end
  end

  return
end
