+def has_admissible_extreme_rank(A):
+ """
+ The extreme matrices of the doubly-nonnegative cone have some
+ restrictions on their ranks. This function checks to see whether or
+ not ``A`` could be extreme based on its rank.
+
+ INPUT:
+
+ - ``A`` - The matrix in question
+
+ OUTPUT:
+
+ ``False`` if the rank of ``A`` precludes it from being an extreme
+ matrix of the doubly-nonnegative cone, ``True`` otherwise.
+
+ REFERENCE:
+
+ Hamilton-Jester, Crista Lee; Li, Chi-Kwong. Extreme Vectors of
+ Doubly Nonnegative Matrices. Rocky Mountain Journal of Mathematics
+ 26 (1996), no. 4, 1371--1383. doi:10.1216/rmjm/1181071993.
+ http://projecteuclid.org/euclid.rmjm/1181071993.
+
+ EXAMPLES:
+
+ The zero matrix has rank zero, which is admissible::
+
+ sage: A = zero_matrix(QQ, 5, 5)
+ sage: has_admissible_extreme_rank(A)
+ True
+
+ """
+ if not A.is_symmetric():
+ raise ValueError('The matrix ``A`` must be symmetric.')
+
+ r = rank(A)
+ n = A.nrows() # Columns would work, too, since ``A`` is symmetric.
+
+ if r == 0:
+ # Zero is in the doubly-nonnegative cone.
+ return True
+
+ # See Theorem 3.1 in the cited reference.
+ if r == 2:
+ return False
+
+ if n.mod(2) == 0:
+ # n is even
+ return r <= max(1, n-3)
+ else:
+ # n is odd
+ return r <= max(1, n-2)