function value = polyomino_equal ( m1, n1, p1, m2, n2, p2 )

%*****************************************************************************80
%
%% POLYOMINO_EQUAL determines if polyominoes P1 and P2 are equal.
%
%  Discussion:
%
%    P1 and P2 should only contain 0 and 1 entries.
%
%    The matrix representations P1 and P2 should be "tight", that is, there 
%    should be a 1 in the first and last rows, and in the first and last 
%    columns.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    02 April 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer M1, N1, the number of rows and columns in the representation
%    of the polyomino P1.
%
%    Input, integer P1(M1,N1), the representation of polyonomial P1. 
%
%    Input, integer M2, N2, the number of rows and columns in the representation
%    of the polyomino P2.
%
%    Input, integer P2(M2,N2), the representation of polyonomial P2. 
%
%    Output, logical VALUE, is true if P1 and P2 represent the same polyomino.
%
  if ( m1 ~= m2 )
    value = false;
  elseif ( n1 ~= n2 )
    value = false;
  else
    s1 = sum ( sum ( p1(1:m1,1:n1) ) );
    s2 = sum ( sum ( p2(1:m2,1:n2) ) );
    if ( s1 ~= s2 )
      value = false;
    else
      s = sum ( sum ( p1(1:m1,1:n1) .* p2(1:m2,1:n2) ) );
      if ( s ~= s1 )
        value = false;
      else
        value = true;
      end
    end
  end

  return
end
