function a_ge = r83_to_r8ge ( m, n, a_83 )

%*****************************************************************************80
%
%% r83_to_r8ge() copies an R83 matrix to a R8GE matrix.
%
%  Discussion:
%
%    The R83 storage format is used for a tridiagonal matrix.
%    The superdiagonal is stored in entries (1,2:min(M+1,N)).
%    The diagonal in entries (2,1:min(M,N)).
%    The subdiagonal in (3,min(M-1,N)).  
%    R8GE A(I,J) = R83 A(I-J+2,J). 
%
%    The original matrix is "collapsed" vertically into the array.
%
%  Example:
%
%    An R83 matrix of order 3x5 would be stored:
%
%       *  A12 A23 A34  *
%      A11 A22 A33  *   *
%      A21 A32  *   *   *
%
%    An R83 matrix of order 5x5 would be stored:
%
%       *  A12 A23 A34 A45
%      A11 A22 A33 A44 A55
%      A21 A32 A43 A54  *
%
%    An R83 matrix of order 5x3 would be stored:
%
%       *  A12 A23
%      A11 A22 A33
%      A21 A32 A43
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    30 January 2004
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the order of the matrix.
%    N must be at least 2.
%
%    real A_83(3,N), the R83 matrix.
%
%  Output:
%
%    real A_GE(M,N), the R8GE matrix.
%
  a_ge = zeros ( m, n );

  for j = 1 : n
    for i = max ( 1, j - 1 ) : min ( m, j + 1 )
 
      a_ge(i,j) = a_83(i-j+2,j);

    end
  end

  return
end
