function A = reflector ( v )
%
% function A = reflector ( v )
%
%  Discussion:
%
%    REFLECTOR sets the Householder reflector matrix for a vector V.
%
%  Example:
%
%    V = [ 1; 2; 3 ]
%
%    A = I - 2 * v * v' / ||v||^2
%
%      = [  6  -2  -3;
%          -2   3  -6;
%          -3  -6  -2 ] / 7.
%
%  Modified:
%
%    11 February 2000
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real V(N), the (nonzero) row or column vector.
%
%    Output, real A(N,N), the Householder elementary reflector matrix.
%
[m,n] = size ( v );

if ( m == 1 ) 
  A = eye ( n ) - 2 * v' * v / ( v * v' );
elseif ( n == 1 )
  A = eye ( m ) - 2 * v * v' / ( v' * v );
else
  printf ( '\n' );
  printf ( 'REFLECTOR - Fatal error!\n' );
  printf ( '  Input value V is not a vector.\n' )
  A = [];
end
