function ubvec_unrank_grlex_test ( )

%*****************************************************************************80
%
%% ubvec_unrank_grlex_test() tests ubvec_unrank_grlex().
%
%  Licensing:
%
%    This code is distributed under the MIT 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
