function [ P, L, U ] = golub_plu ( n, key )

%*****************************************************************************80
%
%% golub_plu() returns the PLU factors of a golub matrix.
%
%  Discussion:
%
%    These matrices are the product of random unit lower and unit upper 
%    triangular matrices.
%
%    These matrices tend to be badly conditioned.
%
%  Properties:
%
%    A can be LU factored without pivoting.
%
%    det(A) = 1.
%
%    For values of n greater than 10, the determinant cannot may not be 
%    reliably computed.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 January 2020
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Cleve Moler,
%    Numerical Computing with MATLAB,
%    SIAM, 2004,
%    ISBN13: 978-0-898716-60-3,
%    LC: QA297.M625
%
%  Input:
%
%    integer N, the order of the matrix.
%
%    integer KEY, a key for the random number generator.
%
%  Output:
%
%    real P(N,N), L(N,N), U(N,N), the LU factors.
%
  rng ( key );

  P = eye ( n );

  s = 10.0;

  L = eye ( n, n );
  for i = 1 : n
    for j = 1 : i - 1
      v = randn ( 1, 1 );
      L(i,j) = s * v;
    end
  end

  U = eye ( n, n );
  for i = 1 : n
    for j = i + 1 : n
      v = randn ( 1, 1 );
      U(i,j) = s * v;
    end
  end

  return
end

