function a = r8cb_dif2 ( m, n )

%*****************************************************************************80
%
%% r8cb_dif2() sets up an R8CB second difference matrix.
%
%  Discussion:
%
%    The R8CB storage format is appropriate for a compact banded matrix.
%    It is assumed that the matrix has lower and upper bandwidths ML and MU,
%    respectively.  The matrix is stored in a way similar to that used
%    by LINPACK and LAPACK for a general banded matrix, except that in
%    this mode, no extra rows are set aside for possible fillin during pivoting.
%    Thus, this storage mode is suitable if you do not intend to factor
%    the matrix, or if you can guarantee that the matrix can be factored
%    without pivoting.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 August 2022
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer M, the number of rows of the matrix.
%    M must be positive.
%
%    Input, integer N, the number of columns of the matrix.
%    N must be positive.
%
%    Output, real A(3,N), the R8CB matrix.
%
  ml = 1;
  mu = 1;
  a = zeros ( ml + mu + 1, n );

  for j = 1 : n

    for diag = 1 : ml + mu + 1

      i = diag + j - mu - 1;

      if ( i == j )
        a(diag,j) = 2.0;
      elseif ( i == j - 1 )
        if ( 1 < j )
          a(diag,j) = -1.0;
        end
      elseif ( i == j + 1 )
        if ( j < n )
          a(diag,j) = -1.0;
        end
      end

    end
  end

  return
end
