function vec_gray_rank_test ( )

%*****************************************************************************80
%
%% vec_gray_rank_test() tests vec_gray_rank().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 April 2009
%
%  Author:
%
%    John Burkardt
%
  n = 4;
  base = [ 2, 2, 1, 4 ];
  number = prod ( base );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'vec_gray_rank_test():\n' );
  fprintf ( 1, '  vec_gray_rank() ranks product space elements.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The number of components is %d\n', n );
  fprintf ( 1, '  The number of elements is %d\n', number );
  fprintf ( 1, '  Each component has its own number of degrees of\n' );
  fprintf ( 1, '  freedom, which, for this example, are:\n' );

  a(1:n) = floor ( base(1:n) / 2 );

  rank = vec_gray_rank ( n, base, a );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  VEC_GRAY_RANK reports the element \n' );
  fprintf ( 1, '\n' );
  for i = 1 : n
    fprintf ( 1, '  %4d', a(i) );
  end
  fprintf ( 1, '\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  has rank %d\n', rank );

  return
end
