function variomino_matrix_test ( )

%*****************************************************************************80
%
%% variomino_matrix_test() tests variomino_matrix().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 May 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'variomino_matrix_test():\n' );
  fprintf ( 1, '  variomino_matrix() sets up the linear system\n' );
  fprintf ( 1, '  associated with a variomino tiling problem.\n' );
%
%  Define R.
%
  shape_r = [ ...
     3,  1,  0; ...
     2,  3,  1; ...
     1,  2,  3 ];
  [ m_r, n_r ] = size ( shape_r );
  variomino_print ( shape_r, '  Region R:' );
%
%  Define N, O, P
%
  shape_n = [ ...
    1, 2 ];
  [ m_n, n_n ] = size ( shape_n );
  variomino_print ( shape_n, '  variomino N:' );

  shape_o = [ ...
    2, 3 ];
  [ m_o, n_o ] = size ( shape_o );
  variomino_print ( shape_o, '  variomino O:' );

  shape_p = [ ...
     1, 3 ];
  [ m_p, n_p ] = size ( shape_p );
  variomino_print ( shape_p, '  variomino 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);
%
%  D indicates how many copies of each variomino we can use.
%
  d = [ 1, 1, 2 ];
%
%  Compute the system matrix.
%
  [ A, b, parent ] = variomino_matrix ( shape_r, p_num, p, d );
  [ m, n ] = size ( A );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Linear system has order (%d,%d) = ', m, n );
%
%  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, '  %2d:  ', i );
    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 = 'reid.lp';
  label = '\ LP file for the Reid example, created by variomino_lp_write.';
  variomino_lp_write ( filename, label, A, b );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Linear system saved in LP file:"%s"\n', filename );

  return
end
