function determ = permutation_random_determinant ( n, key )

%*****************************************************************************80
%
%% permutation_random_determinant() returns determinant of PERMUTATION_RANDOM matrix.
%
%  Discussion:
%
%    This routine will only work properly if it is given as input the
%    same value of SEED that was given to PERMUTATION_RANDOM.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    27 October 2007
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the order of the matrix.
%
%    integer KEY, a positive value that selects the data.
%
%  Output:
%
%    Output, real DETERM, the determinant.
%
  rng ( key );

  p = i4vec_indicator ( n );

  for i = 1 : n

    j = randi ( [ i, n ], 1 );
 
    k    = p(j);
    p(j) = p(i);
    p(i) = k;

  end

  determ = perm_sign ( n, p );

  return
end
