function a_utp = r8ge_to_r8utp ( m, n, a_ge )

%*****************************************************************************80
%
%% r8ge_to_r8utp() copies an R8GE matrix to an R8UTP matrix.
%
%  Discussion:
%
%    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.
%
%    The R8UTP storage format is appropriate for an upper triangular
%    matrix.  Only the upper triangle of the matrix is stored,
%    by successive partial columns, in an array which contains
%    (A11,A12,A22,A13,A23,A33,A14,...,AMN).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 August 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the order of the matrix.
%
%    real A_GE(M,N), the R8GE matrix.
%
%  Output:
%
%    real A_UTP(*), the R8UTP matrix.
%
  a_utp = r8utp_zeros ( m, n );

  k = 0;
  for j = 1 : n
    for i = 1 : min ( j, m )
      k = k + 1;
      a_utp(k) = a_ge(i,j);
    end
  end

  return
end
