function compnz_to_ksub_test ( )

%*****************************************************************************80
%
%% compnz_to_ksub_test() tests compnz_to_ksub().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    01 July 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'compnz_to_ksub_test():\n' );
  fprintf ( 1, '  compnz_to_ksub() returns the K subset corresponding \n' );
  fprintf ( 1, '  to a nonzero composition.\n' );

  nc = 10;
  kc = 5;

  for i = 1 : 5

    fprintf ( 1, '\n' );

    ac = compnz_random ( nc, kc );
    fprintf ( '  COMPNZ:' );
    for j = 1 : kc
      fprintf ( 1, '  %2d', ac(j) );
    end
    fprintf ( 1, '\n' );

    [ ns, ks, as ] = compnz_to_ksub ( nc, kc, ac );
    fprintf ( '  KSUB:  ' );
    for j = 1 : ks
      fprintf ( 1, '  %2d', as(j) );
    end
    fprintf ( 1, '\n' );

    [ nc, kc, ac ] = ksub_to_compnz ( ns, ks, as );
    fprintf ( '  COMPNZ:' );
    for j = 1 : kc
      fprintf ( 1, '  %2d', ac(j) );
    end
    fprintf ( 1, '\n' );
    
  end

  return
end
