function a = r8bb_dif2 ( n1, n2, ml, mu )

%*****************************************************************************80
%
%% R8BB_DIF2 sets up an R8BB second difference matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    10 July 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N1, N2, the order of the banded and dense 
%    blocks.  N1 and N2 must be nonnegative, and at least one must be positive.
%
%    Input, integer ML, MU, the lower and upper bandwidths.
%    1 <= ML, 1 <= MU.
%
%    Output, real A((2*ML+MU+1)*N1+2*N1*N2+N2*N2), the R8BB matrix.
%
  a = zeros ( (2*ml+mu+1)*n1+2*n1*n2+n2*n2,1);

  if ( ml < 1 || mu < 1 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'R8BB - Fatal error!\n' );
    fprintf ( 1, '  1 <= ML and 1 <= MU required.\n' );
    error ( 'R8BB_DIF2 - Fatal error!' );
  end

  for i = 2 : n1 + n2
    j = i - 1;
    value = - 1.0;
    a = r8bb_set ( n1, n2, ml, mu, a, i, j, value );
  end

  for i = 1 : n1 + n2
    j = i;
    value = 2.0;
    a = r8bb_set ( n1, n2, ml, mu, a, i, j, value );
  end

  for i = 1 : n1 + n2 - 1
    j = i + 1;
    value = - 1.0;
    a = r8bb_set ( n1, n2, ml, mu, a, i, j, value );
  end

  return
end
