function value = permutation_symbol ( n, ivec )

%*****************************************************************************80
%
%% PERMUTATION_SYMBOL evaluates the Levi-Civita permutation symbol.
%
%  Discussion:
%
%    Given a vector of N values I(), 
%
%      epsilon = product ( q < p ) ( i(p) - i(q) ) / abs ( i(p) - i(q) )
%
%    where epsilon is 0 if any pair of values are equal.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    17 September 2018
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer N, the number of entries.
%
%    Input, integer IVEC(N), the vector of values.
%
%    Output, integer VALUE, the value of the Levi-Civita permutation symbol,
%    which will be -1, 0, or 1.
%
  value = 1;

  for i = 1 : n
    for j = i + 1 : n
      if ( ivec(i) == ivec(j) )
        value = 0;
        return
      elseif ( ivec(i) < ivec(j) )
        value = - value;
      end
    end
  end

  return
end

