function a = moler3_matrix ( m, n )

%*****************************************************************************80
%
%% moler3_matrix() returns the MOLER3 matrix.
%
%  Formula:
%
%    if ( I == J )
%      A(I,J) = I
%    else
%      A(I,J) = min(I,J) - 2
%
%  Example:
%
%    M = N = 5
%
%     1 -1 -1 -1 -1
%    -1  2  0  0  0
%    -1  0  3  1  1
%    -1  0  1  4  2
%    -1  0  1  2  5
%
%  Properties when A is square:
%
%    A is integral, therefore det ( A ) is integral, and 
%    det ( A ) * inverse ( A ) is integral.
%
%    A is symmetric: A' = A.
%
%    A is positive definite.
%
%    A is symmetric positive definite.
%
%    Because A is symmetric, it is normal.
%
%    Because A is normal, it is diagonalizable.
%
%    A has a simple Cholesky factorization.
%
%    A has one small eigenvalue.
%
%    The family of matrices is nested as a function of N.
%
%    A is not diagonally dominant.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 October 2007
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M: the number of rows.
%
%    integer N: the number of columns.
%    If N is not specified, N = M is assumed.
%
%  Output:
%
%    real A(M,N), the matrix.
%
  if ( nargin == 1 )
    n = m;
  end

  a = zeros ( m, n );

  for i = 1 : m
    for j = 1 : n
      if ( i == j )
        a(i,j) = i;
      else
        a(i,j) = min ( i, j ) - 2;
      end
    end
  end

  return
end
