function a = oto_matrix ( m, n )

%*****************************************************************************80
%
%% oto_matrix() returns the OTO matrix.
%
%  Example:
%
%    N = 5
%
%    2  1  .  .  .
%    1  2  1  .  .
%    .  1  2  1  .
%    .  .  1  2  1
%    .  .  .  1  2
%
%  Properties:
%
%    A is banded, with bandwidth 3.
%
%    A is tridiagonal.
%
%    Because A is tridiagonal, it has property A (bipartite).
%
%    A is integral: int ( A ) = A.
%
%    A is Toeplitz: constant along diagonals.
%
%    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 is persymmetric: A(I,J) = A(N+1-J,N+1-I).
%
%    A is weakly diagonally dominant.
%
%    A is not strictly diagonally dominant.
%
%    The family of matrices is nested as a function of N.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 November 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 ( j == i - 1 )
        a(i,j) = 1.0;
      elseif ( j == i )
        a(i,j) = 2.0;
      elseif ( j == i + 1 )
        a(i,j) = 1.0;
      else
        a(i,j) = 0.0;
      end

    end
  end

  return
end
