function r8vec2_sorted_unique_index_test ( )

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

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8VEC2_SORTED_UNIQUE_INDEX_TEST\n' );
  fprintf ( 1, '  For a pair of R8VEC''s:\n' );
  fprintf ( 1, '  R8VEC2_SORTED_UNIQUE_INDEX indexes unique entries.\n' );

  b = 1.0;
  c = 3.0;
  a1 = b + ( c - b ) * rand ( n, 1 );

  b = 5.0;
  c = 10.0;
  a2 = b + ( c - b ) * rand ( n, 1 );

  a1(3) = a1(1);
  a2(3) = a2(1);

  a1(6) = a1(2);
  a2(6) = a2(2);

  a1(9) = a1(1);
  a2(9) = a2(1);

  [ a1, a2 ] = r8vec2_sort_a ( n, a1, a2 );

  r8vec2_print ( a1, a2, '  Sorted arrays:' );

  [ unique_num, indx ] = r8vec2_sorted_unique_index ( n, a1, a2 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The number of unique elements is %d\n', unique_num );

  i4vec_print ( unique_num, indx, '  Index of Unique Elements:' );

  b1 = r8vec_index_order ( unique_num, a1, indx );
  b2 = r8vec_index_order ( unique_num, a2, indx );

  r8vec2_print ( b1, b2, '  After Indexed Nonunique Deletion.' );

  return
end
