function r8vec_search_binary_a_test ( )

%*****************************************************************************80
%
%% r8vec_search_binary_a_test() tests r8vec_search_binary_a();
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 April 2009
%
%  Author:
%
%    John Burkardt
%
  n = 10;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8VEC_SEARCH_BINARY_A_TEST\n' );
  fprintf ( 1, '  For ascending order:\n' );
  fprintf ( 1, '  R8VEC_SEARCH_BINARY_A searches a sorted array;\n' );
  fprintf ( 1, '\n' );
  a = rand ( n, 1 );

  search_val = a(1);
 
  a = r8vec_sort_heap_a ( n, a );
 
  r8vec_print ( n, a, '  Sorted vector A:' );
%
%  Now search the sorted array for a given value.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Search the array for the value %f\n', search_val );

  index = r8vec_search_binary_a ( n, a, search_val );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  SEARCH RESULT:\n' );
  fprintf ( 1, '\n' );

  if ( 0 < index )
    fprintf ( 1, '    The value occurs in index %d\n', index );
  else
    fprintf ( 1, '    The value does not occur in the array.\n' );
  end

  return
end
