function b = r8pbl_to_r8ge ( n, ml, a )

%*****************************************************************************80
%
%% R8PBL_TO_R8GE copies a R8PBL matrix to a R8GE matrix.
%
%  Discussion:
%
%    The R8PBL storage format is for a symmetric positive definite band matrix.
%
%    To save storage, only the diagonal and lower triangle of A is stored,
%    in a compact diagonal format that preserves columns.
%
%    The diagonal is stored in row 1 of the array.
%    The first subdiagonal in row 2, columns 1 through ML.
%    The second subdiagonal in row 3, columns 1 through ML-1.
%    The ML-th subdiagonal in row ML+1, columns 1 through 1.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 July 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the order of the matrices.
%    N must be positive.
%
%    Input, integer ML, the upper bandwidth of A.
%    ML must be nonnegative, and no greater than N-1.
%
%    Input, real A(ML+1,N), the R8PBL matrix.
%
%    Output, real B(N,N), the R8GE matrix.
%
  b = zeros ( n, n );

  for i = 1 : n
    for j = 1 : n
      if ( i <= j && j <= i + ml )
        b(i,j) = a(j-i+1,i);
      elseif ( i - ml <= j && j < i )
        b(i,j) = a(i-j+1,j);
      end
    end
  end

  return
end
