function polyomino_condense_test ( )

%*****************************************************************************80
%
%% polyomino_condense_test() tests polyomino_condense().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 May 2018
%
%  Author:
%
%    John Burkardt
%
%  Local:
%
%    integer MP, NP, the number of rows and columns in the representation
%    of the polyomino P.
%
%    integer P(MP,NP), a matrix representing the polyomino.  
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'polyomino_condense_test():\n' );
  fprintf ( 1, '  polyomino_condense() "cleans up" a matrix that is supposed\n' );
  fprintf ( 1, '  to represent a polyomino:\n' );
  fprintf ( 1, '  * nonzero entries are set to 1;:\n' );
  fprintf ( 1, '  * initial and final zero rows and columns are deleted.\n' );
%
%  Nothing happens:
%
  mp = 3;
  np = 3;
  p = [ 0, 1, 1; 1, 1, 0; 0, 1, 0 ];
  condense_demo ( mp, np, p );
%
%  Nonzero, but non-one entries are set to 1.
%
  mp = 3;
  np = 3;
  p = [ 0, 1, 2; 1, 3, 0; 0, -9, 0 ];
  condense_demo ( mp, np, p );
%
%  Extraneous zero rows and columns are removed.
%
  mp = 3;
  np = 4;
  p = [ 0, 0, 0, 0; 1, 3, 0, 0; 0, 0, 0, 0 ];
  condense_demo ( mp, np, p );
%
%  Null matrices are detected.
%
  mp = 2;
  np = 4;
  p = [ 0, 0, 0, 0; 0, 0, 0, 0 ];
  condense_demo ( mp, np, p );

  return
end
function condense_demo ( mp, np, p )

%*****************************************************************************80
%
%% condense_demo() tests polyomino_condense().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 April 2018
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    Input, integer MP, NP, the number of rows and columns in the representation
%    of the polyomino P.
%
%    Input, integer P(MP,NP), a matrix representing the polyomino.  
%
%  Local:
%
%    Local, integer MQ, NQ, the number of rows and columns in the representation
%    of the condensed polyomino Q.
%
%    Local, integer Q(MQ,NQ), a matrix representing the condensed polyomino.  
%
  label = sprintf ( '  The initial (%d,%d) polyomino P:\n', mp, np );
  polyomino_print ( p, label );

  [ mq, nq, q ] = polyomino_condense ( mp, np, p );

  label = sprintf ( '  The condensed (%d,%d) polyomino Q:\n', mq, nq );
  polyomino_print ( q, label );

  return
end
 
