function a = summation_matrix ( m, n )

%*****************************************************************************80
%
%% summation_matrix() returns the SUMMATION matrix.
%
%  Example:
%
%    M = 5, N = 5
%
%    1  0  0  0  0
%    1  1  0  0  0
%    1  1  1  0  0
%    1  1  1  1  0
%    1  1  1  1  1
%
%  Properties:
%
%    A is generally not symmetric: A' /= A.
%
%    A is lower triangular.
%
%    A is a 0/1 matrix.
%
%    The vector Y = A * X contains the partial sums of the vector X.
%
%    A is Toeplitz: constant along diagonals.
%
%    A is nonsingular.
%
%    det ( A ) = 1.
%
%    A is unimodular.
%
%    LAMBDA(1:N) = 1.
%
%    A is persymmetric: A(I,J) = A(N+1-J,N+1-I).
%
%    The family of matrices is nested as a function of N.
%
%    A is not diagonally dominant.
%
%    A is the Cholesky factor of the MINIJ matrix.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 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 : n
    for j = 1 : n
      if ( j <= i )
        a(i,j) = 1.0;
      else
        a(i,j) = 0.0;
      end
    end
  end

  return
end
