function vec_gray_next_test ( )

%*****************************************************************************80
%
%% VEC_GRAY_NEXT_TEST tests VEC_GRAY_NEXT.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL 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_NEXT_TEST\n' );
  fprintf ( 1, '  VEC_GRAY_NEXT generates 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.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Rank Change     ' );
  for i = 1 : n
    fprintf ( 1, '  %4d', base(i) );
  end
  fprintf ( 1, '\n' );
  fprintf ( 1, '\n' );
  rank = 0;
  
  a = [];
  done = 1;
  active = zeros ( n, 1 );
  dir = zeros ( n, 1 );
 
  while ( true )
 
    rank = rank + 1;
 
    [ a, done, active, dir, change ] = vec_gray_next ( n, base, a, ...
      done, active, dir );
 
    if ( done )
      break
    end

    fprintf ( 1, '  %4d  %4d      ', rank, change );
    for i = 1 : n
      fprintf ( 1, '  %4d', a(i) );
    end
    fprintf ( 1, '\n' );

  end

  return
end
