function cycle_check_test ( )

%*****************************************************************************80
%
%% cycle_check_test() tests cycle_check().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 December 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'cycle_check test():\n' );
  fprintf ( 1, '  cycle_check() checks a permutation in cycle form.\n' );
  
  for test = 1 : 6

    if ( test == 1 )
      n = 0;
      ncycle = 3;
      t = [ 5, 1, 3, 8, 6, 2, 4, 7 ];
      index = [ 1, 4, 3 ];
    elseif ( test == 2 )
      n = 8;
      ncycle = 0;
      t = [ 5, 1, 3, 8, 6, 2, 4, 7 ];
      index = [ 1, 4, 3 ];
    elseif ( test == 3 )
      n = 8;
      ncycle = 3;
      t = [ 5, 1, 3, 8, 6, 2, 4, 7 ];
      index = [ 1, 4, 2 ];
    elseif ( test == 4 )
      n = 8;
      ncycle = 3;
      t = [ 5, 1, 3, 12, 6, 2, 4, 7 ];
      index = [ 1, 4, 3 ];
    elseif ( test == 5 )
      n = 8;
      ncycle = 3;
      t = [ 5, 1, 3, 8, 5, 2, 4, 7 ];
      index = [ 1, 4, 3 ];
    elseif ( test == 6 )
      n = 8;
      ncycle = 3;
      t = [ 5, 1, 3, 8, 6, 2, 4, 7 ];
      index = [ 1, 4, 3 ];
    end

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Permutation in cycle form:\n' );
    fprintf ( 1, '  Number of cycles is %d\n', ncycle );
    fprintf ( 1, '\n' );
    jlo = 0;
    for i = 1 : ncycle
      fprintf ( 1, '    ' );
      for j = jlo + 1 : jlo + index(i)
        fprintf ( 1, '%4d', t(j) );
      end
      fprintf ( 1, '\n' );
      jlo = jlo + index(i);
    end

    check = cycle_check ( n, ncycle, t, index );
    fprintf ( 1, '  Check = %5s\n', mat2str ( check ) );
    
  end

  return
end
