function ival = r8mat_is_pds ( m, n, a )

%*****************************************************************************80
%
%% R8MAT_IS_PDS checks for if an R8MAT is positive definite symmetric.
%
%  Discussion:
%
%    An R8MAT is a matrix of real values.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    04 November 2007
%
%  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, integer IVAL:
%    -1, the matrix is not square.
%    -2, the matrix is not symmetric.
%    -3, the matrix is symmetric, but not positive definite.
%    0, the matrix is positive semi-definite symmetric.
%    1, the matrix is positive definite symmetric.
%
  if ( ~ r8mat_is_square ( m, n, a ) )
    ival = -1;
    return
  end

  for i = 1 : n
    for j = 1 : i - 1
      if ( a(i,j) ~= a(j,i) )
        ival = -2;
        return
      end
    end
  end

  [ c, ierror ] = r8mat_cholesky_factor ( n, a );

  if ( ierror == 2 )
    ival = -3;
  elseif ( ierror == 1 )
    ival = 0;
  else
    ival = 1;
  end

  return
end
