function ubvec_unrank_grlex_test ( )

%*****************************************************************************80
%
%% UBVEC_UNRANK_GRLEX_TEST tests UBVEC_UNRANK_GRLEX.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    19 November 2015
%
%  Author:
%
%    John Burkardt
%
  n = 4;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'UBVEC_UNRANK_GRLEX_TEST\n' );
  fprintf ( 1, '  UBVEC_UNRANK_GRLEX returns the UBVEC of given rank\n' );
  fprintf ( 1, '  in the graded lexicographical ordering.\n' );

  s = -1;

  for rank = 0 : 15
    b = ubvec_unrank_grlex ( rank, n );
    if ( s < sum ( b(1:n) ) )
      fprintf ( 1, '  --  --------\n' );
      s = sum ( b(1:n) );
    end
    fprintf ( 1, '  %2d  ', rank );
    for j = 1 : n
      fprintf ( 1, '%2d', b(j) );
    end
    fprintf ( 1, '\n' );
  end

  return
end
