function A = lo_matrix ( )

%*****************************************************************************80
%
%% lo_matrix() returns the 25x25 Lights Out matrix.
%
%  Discussion:
%
%    If A is the Lights Out matrix, and P is a vector of 0's and 1's,
%    such that P(k) is 1 if button k is to be pushed, then
%    A * P (modulo 2) returns a vector AP giving the lights that will 
%    be illuminated.
%
%    This matrix is singular.
%
%    However, using a least squares solver, it should be possible to
%    start with a given configuration AP, and determine the corresponding
%    button pushes that created it.  
%
%    These same button pushes can be used to solve the puzzle, because
%    repeating them extinguishes all the lights.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 November 2017
%
%  Author:
%
%    John Burkardt
%
%  Output:
%
%    integer A(25,25): the Lights Out matrix.
%
  mrow = 5;
  ncol = 5;
  A = zeros ( mrow * ncol, mrow * ncol );

  for i = 1 : mrow
    for j = 1 : ncol

      c = lo_matrix_index ( i,     j );
      n = lo_matrix_index ( i - 1, j );
      s = lo_matrix_index ( i + 1, j );
      e = lo_matrix_index ( i,     j + 1 );
      w = lo_matrix_index ( i,     j - 1 );

      A(c,c) = 1;
      if ( 1 < i )
        A(n,c) = 1;
      end
      if ( i < mrow )
        A(s,c) = 1;
      end
      if ( 1 < j )
        A(w,c) = 1;
      end
      if ( j < ncol )
        A(e,c) = 1;
      end

    end
  end

  return
end
