function value = r8mat_trace ( n, a )

%*****************************************************************************80
%
%% r8mat_trace() computes the trace of an R8MAT.
%
%  Discussion:
%
%    The trace of a square matrix is the sum of the diagonal elements.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 April 2005
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the order of the matrix A.
%
%    real A(N,N), the matrix whose trace is desired.
%
%  Output:
%
%    real VALUE, the trace of the matrix.
%
  value = 0.0;
  for i = 1 : n
    value = value + a(i,i);
  end

  return
end
