function polyomino_multihedral_matrix_test ( )

%*****************************************************************************80
%
%% polyomino_multihedral_matrix_test tests polyomino_multihedral_matrix.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    07 March 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../polyomino_multihedral_matrix' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'polyomino_multihedral_matrix_test:\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Test polyomino_multihedral_matrix,\n' );
  fprintf ( 1, '  which sets up the linear system\n' );
  fprintf ( 1, '  associated with a multi-polyomino tiling problem.\n' );
%
%  Define R.
%
  shape_r = [ ...
    1, 1, 1, 1; ...
    1, 1, 1, 1 ];

  [ m_r, n_r ] = size ( shape_r );
  polyomino_print ( m_r, n_r, shape_r, '  Region R:' );
%
%  Define N, O, P
%
  shape_n = [ ...
    1 ];
  [ m_n, n_n ] = size ( shape_n );
  polyomino_print ( m_n, n_n, shape_n, '  Polyomino N:' );

  shape_o = [ ...
    1, 1, 1 ];
  [ m_o, n_o ] = size ( shape_o );
  polyomino_print ( m_o, n_o, shape_o, '  Polyomino O:' );

  shape_p = [ ...
    0, 0, 1;
    1, 1, 1 ];
  [ m_p, n_p ] = size ( shape_p );
  polyomino_print ( m_p, n_p, shape_p, '  Polyomino P:' );
%
%  Pack the arrays into P.
%
  p_num = 3;
  p = zeros ( m_r, n_r, p_num );
  p(1:m_n,1:n_n,1) = shape_n(1:m_n,1:n_n);
  p(1:m_o,1:n_o,2) = shape_o(1:m_o,1:n_o);
  p(1:m_p,1:n_p,3) = shape_p(1:m_p,1:n_p);
%
%  Set the vector D, which indicates how many copies of each polyomino
%  we can use.
%
  d = ones ( p_num, 1 );
%
%  Compute the system matrix.
%
  [ a, b, parent ] = polyomino_multihedral_matrix ( shape_r, p_num, p, d );
  [ m, n ] = size ( a );
%
%  Print the linear system.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  System matrix A and right hand side B:\n' );
  fprintf ( 1, '\n' );
  for i = 1 : m
    fprintf ( 1, '  ' );
    for j = 1 : n
      fprintf ( 1, '%2d', a(i,j) );
    end
    fprintf ( 1, '  %2d\n', b(i) );
  end
%
%  Write the linear system to an LP file.
%
  filename = '2x4.lp';
  label = '\ LP file for the 2x4 example, created by POLYOMINO_LP_WRITE.';
  polyomino_lp_write ( filename, label, m, n, a, b );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Linear system saved in LP file:"%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'polyomino_multihedral_matrix_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../polyomino_multihedral_matrix' );

  return
end
