function error_frobenius = r8mat_is_persymmetric ( m, n, a )

%*****************************************************************************80
%
%% R8MAT_IS_PERSYMMETRIC checks an R8MAT for persymmetry.
%
%  Discussion:
%
%    An R8MAT is a matrix of real values.
%
%    A is persymmetric if A(I,J) = A(N+1-J,M+1-I).
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    17 April 2017
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer M, N, the row and column dimensions of 
%    the matrix.  M and N must be positive.
%
%    Input, real A(M,N), the matrix.
%
%    Output, real ERROR_FROBENIUS, the Frobenius error
%    in persymmetry, which will be 0 if the matrix is exactly
%    persymmetric.
%
  if ( ~ r8mat_is_square ( m, n, a ) )
    error_frobenius = Inf;
    return
  end

  error_frobenius = 0.0;

  for i = 1 : m
    for j = n : -1 : 1
      error_frobenius = error_frobenius + ( a(i,j) - a(n+1-j,m+1-i) )^2;
    end
  end

  error_frobenius = sqrt ( error_frobenius );

  return
end
