function value = i4vec_is_permutation ( A )

%*****************************************************************************80
%
%% i4vec_is_permutation() determines if an I4VEC is a permutation.
%
%  Discussion:
%
%    Actually, the input item can be a row or column vector, a matrix,
%    or any numeric array. 
%
%    The array is assumed to have N elements.
%
%    The array must contain only integer values.
%
%    Each integer from 1 to N must appear exactly once in A.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 February 2021
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer A(N), the array to be checked.
%
%  Output:
%
%    logical VALUE, is true if A represents a permutation.
%

%
%  Make A a column vector.
%
  n = numel ( A );
  A = reshape ( A, [ n, 1 ] );
%
%  All entries must be integers.
%  MATLAB's "isinteger()" only checks whether the array is of integer type.
%
  if ( A ~= round ( A ) )
    value = false;
    return
  end
%
%  The minimum value must be 1.
%
  A_min = min ( A );
  if ( A_min ~= 1 )
    value = false;
    return;
  end
%
%  The maximum value must be n.
%
  A_max = max ( A );
  if ( A_max ~= n )
    value = false;
    return;
  end
%
%  There must be A_numel unique entries.
%
  A = unique ( A );
  if ( numel ( A ) ~= n )
    value = false;
    return
  end
  
  value = true;

  return
end
