function a = r8pp_dif2 ( n )

%*****************************************************************************80
%
%% R8PP_DIF2 sets up an R8PP second difference matrix.
%
%  Discussion:
%
%    The R8PP storage format is appropriate for a symmetric positive
%    definite matrix.  Only the upper triangle of the matrix is stored,
%    by successive partial columns, in an array of length (N*(N+1))/2,
%    which contains (A11,A12,A22,A13,A23,A33,A14,...,ANN)  
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    16 June 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the order of the matrix.
%    N must be positive.
%
%    Output, real A((N*(N+1))/2), the R8PP matrix.
%
  a = zeros ( ( n * ( n + 1 ) ) / 2 );

  k = 0;
  for j = 1 : n
    for i = 1 : j - 2
      k = k + 1;
      a(k) = 0.0;
    end
    if ( 1 < j )
      k = k + 1;
      a(k) = - 1.0;
    end
    k = k + 1;
    a(k) = 2.0;
  end

  return
end

