function table = r8mat_latinize ( m, n, table )

%*****************************************************************************80
%
%% r8mat_latinize() "Latinizes" a dataset.
%
%  Discussion:
%
%    On output, each row of the table will have the properties that:
%    1) the minimum and maximum row values are the same as on input;
%    2) the row contains N evenly spaced values between the
%       minimum and maximum;
%    3) in each row, the elements retain their ordering.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 October 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the number of points.
%
%    integer N, the spatial dimension.
%
%    real TABLE(M,N), the dataset to be "Latinized".
%
%  Output:
%
%    real TABLE(M,N), the Latinized dataset.
%
  if ( m <= 2 )
    return
  end

  for j = 1 : n

    v_min = min ( table(1:m,j) );
    v_max = max ( table(1:m,j) );

    indx = r8vec_sort_heap_index_a ( m, table(1:m,j) );

    for i = 1 : m
      table(indx(i),j) =  ( ( m - i     ) * v_min   ...
                          + (     i - 1 ) * v_max ) ...
                          / ( m     - 1 );
    end

  end

  return
end
