function a_r8ge = r83t_to_r8ge ( m, n, a_r83t )

%*****************************************************************************80
%
%% R83T_TO_R8GE copies an R83T matrix to an R8GE matrix.
%
%  Discussion:
%
%    The R83T storage format is used for an MxN tridiagonal matrix.
%    The superdiagonal is stored in entries (1:M-1,3), the diagonal in
%    entries (1:M,2), and the subdiagonal in (2:M,1).  Thus, the
%    the rows of the original matrix slide horizontally to form an
%    Mx3 stack of data.
%
%    An R83T matrix of order 3x5 would be stored:
%
%       *  A11 A12
%      A21 A22 A23
%      A32 A33 A34
%
%    An R83T matrix of order 5x5 would be stored:
%
%       *  A11 A12
%      A21 A22 A23
%      A32 A33 A34
%      A43 A44 A45
%      A54 A55  *
%
%    An R83T matrix of order 5x3 would be stored:
%
%       *  A11 A12
%      A21 A22 A23
%      A32 A33  *
%      A43  *   *
%       *   *   *
%
%    The R8GE storage format is used for a general M by N matrix.  A storage 
%    space is made for each entry.  The two dimensional logical
%    array can be thought of as a vector of M*N entries, starting with
%    the M entries in the column 1, then the M entries in column 2
%    and so on.  Considered as a vector, the entry A(I,J) is then stored
%    in vector location I+(J-1)*M.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    28 May 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer M, N, the order of the matrix.
%
%    Input, real A_R83T(M,3), the R83T matrix.
%
%    Output, real A_R8GE(M,N), the R8GE matrix.
%
  a_r8ge(1:m,1:n) = 0.0;

  for i = 1 : m
    for k = 1 : 3
      j = i - 2 + k;
      if ( 1 <= j && j <= n )
        a_r8ge(i,j) = a_r83t(i,k);
      end
    end
  end

  return
end

