function a = r83_random ( m, n )

%*****************************************************************************80
%
%% r83_random() randomizes a R83 matrix.
%
%  Discussion:
%
%    The R83 storage format is used for a tridiagonal matrix.
%    The superdiagonal is stored in entries (1,2:min(M+1,N)).
%    The diagonal in entries (2,1:min(M,N)).
%    The subdiagonal in (3,min(M-1,N)).
%    R8GE A(I,J) = R83 A(I-J+2,J).   
%
%    The original matrix is "collapsed" vertically into the array.
%
%  Example:
%
%    An R83 matrix of order 3x5 would be stored:
%
%       *  A12 A23 A34  *
%      A11 A22 A33  *   *
%      A21 A32  *   *   *
%
%    An R83 matrix of order 5x5 would be stored:
%
%       *  A12 A23 A34 A45
%      A11 A22 A33 A44 A55
%      A21 A32 A43 A54  *
%
%    An R83 matrix of order 5x3 would be stored:
%
%       *  A12 A23
%      A11 A22 A33
%      A21 A32 A43
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 August 2015
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, N, the order of the matrix.
%
%  Output:
%
%    real A(3,N), the R83 matrix.
%
  a = zeros ( 3, n );

  for j = 1 : n
    for i = max ( 1, j - 1 ) : min ( m, j + 1 )
      r = rand ( 1, 1 );
      a(i-j+2,j) = r;
    end
  end

  return
end
