function [ A, v ] = reflection_random_matrix ( n, key )

%*****************************************************************************80
%
%% reflection_random_matrix() returns the REFLECTION_RANDOM matrix.
%
%  Properties:
%
%    A has determinant -1.
%
%    A will have a single eigenvalue of -1.   All other eigenvalues
%    will be +1.
%
%    A is an orthogonal matrix.
%
%    A*v = -v.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 March 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the order of A (default = 5 ).
%
%    integer KEY, a positive integer that selects the data.
%    (default = 123456789).
%
%  Output:
%
%    real A(N,N), the matrix.
%
%    real V(N): the vector that is exactly reflected by A.
%
  if ( nargin < 2 )
    key = 123456789;
  end

  if ( nargin < 1 )
    n = 5;
  end

  rng ( key );
%
%  Get a random vector v.
%
  v = randn ( n, 1 );
%
%  Normalize.
%
  v = v / norm ( v );
%
%  A = I - 2 * v v'
%
  A = eye ( n, n ) - 2.0 * v * v';

  return
end
