function polyomino_condense_test ( )

%*****************************************************************************80
%
%% POLYOMINO_CONDENSE_TEST tests POLYOMINO_CONDENSE.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    14 May 2018
%
%  Author:
%
%    John Burkardt
%
%  Local parameters:
%
%    Local, integer MP, NP, the number of rows and columns in the representation
%    of the polyomino P.
%
%    Local, integer P(MP,NP), a matrix representing the polyomino.  
%
  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'POLYOMINO_CONDENSE_TEST:\n' );
  fprintf ( 1, '  MATLAB version\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 );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'POLYOMINO_CONDENSE_TEST:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  return
end
function condense_demo ( mp, np, p )

%*****************************************************************************80
%
%% CONDENSE_DEMO demonstrates the result of calling POLYOMINO_CONDENSE.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    13 April 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    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, 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) polynomino P:\n', mp, np );
  polyomino_print ( mp, np, p, label );

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

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

  return
end
