function i4mat_rank_test ( )

%*****************************************************************************80
%
%% i4mat_rank_test() tests i4mat_rank().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 August 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'i4mat_rank_test():\n' );
  fprintf ( 1, '  i4mat_rank() computes the rank of an integer matrix.\n' );

  m = 3;
  n = 3;
  a1 = [ ...
    1, 2, 3; ...
    4, 5, 6; ...
    7, 8, 9 ];

  i4mat_print ( m, n, a1, '  Matrix A1:' );

  rank_a = i4mat_rank ( m, n, a1 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The rank is %d\n', rank_a );

  m = 3;
  n = 3;
  a2 = [ ...
    1, 2, 3; ...
    4, 5, 6; ...
    7, 8, 0 ];

  i4mat_print ( m, n, a2, '  Matrix A2:' );

  rank_a = i4mat_rank ( m, n, a2 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The rank is %d\n', rank_a );

  m = 4;
  n = 3;
  a3 = [ ...
    1,  2,  3; ...
    4,  5,  6; ...
    7,  8,  0; ...
   10, 11, 12 ];

  i4mat_print ( m, n, a3, '  Matrix A3:' );

  rank_a = i4mat_rank ( m, n, a3 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The rank is %d\n', rank_a );

  m = 3;
  n = 4;
  a4 = [ ...
    1, 2, 3, 7; ...
    4, 5, 6, 8; ...
    7, 8, 0, 3 ];

  i4mat_print ( m, n, a4, '  Matrix A4:' );

  rank_a = i4mat_rank ( m, n, a4 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The rank is %d\n', rank_a );

  m = 5;
  n = 3;
  a5 = [ ...
    1,  2,  3; ...
    4,  5,  6; ...
    7,  8,  9; ...
   10, 11, 12; ...
    3,  3,  3 ];

  i4mat_print ( m, n, a5, '  Matrix A5:' );

  rank_a = i4mat_rank ( m, n, a5 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The rank is %d\n', rank_a );

  m = 3;
  n = 2;
  a6 = [ ...
    0,  0; ...
    0,  0; ...
    0,  0 ];

  i4mat_print ( m, n, a6, '  Matrix A6:' );

  rank_a = i4mat_rank ( m, n, a6 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  The rank is %d\n', rank_a );

  return
end
