function value = r8utp_size ( m, n )

%*****************************************************************************80
%
%% r8utp_size() returns the size of an M x N R8UTP matrix.
%
%  Discussion:
%
%    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 number of rows and columns.
%
%  Output:
%
%    integer VALUE: the length of the array needed to store the matrix.
%
  if ( n < m )
    value = ( n * ( n + 1 ) ) / 2;
  elseif ( m == n )
    value = ( m * ( m + 1 ) ) / 2;
  else
    value = ( m * ( m + 1 ) / 2 ) + ( n - m ) * m;
  end

  return
end

