+def is_symmetric_psd(A):
+ """
+ Determine whether or not the matrix ``A`` is symmetric
+ positive-semidefinite.
+
+ INPUT:
+
+ - ``A`` - The matrix in question
+
+ OUTPUT:
+
+ Either ``True`` if ``A`` is symmetric positive-semidefinite, or
+ ``False`` otherwise.
+
+ EXAMPLES:
+
+ Every completely positive matrix is symmetric
+ positive-semidefinite::
+
+ sage: v = vector(map(abs, random_vector(ZZ, 10)))
+ sage: A = v.column() * v.row()
+ sage: is_symmetric_psd(A)
+ True
+
+ The following matrix is symmetric but not positive semidefinite::
+
+ sage: A = matrix(ZZ, [[1, 2], [2, 1]])
+ sage: is_symmetric_psd(A)
+ False
+
+ This matrix isn't even symmetric::
+
+ sage: A = matrix(ZZ, [[1, 2], [3, 4]])
+ sage: is_symmetric_psd(A)
+ False
+
+ """
+
+ if A.base_ring() == SR:
+ msg = 'The matrix ``A`` cannot be symbolic.'
+ raise ValueError.new(msg)
+
+ # First make sure that ``A`` is symmetric.
+ if not A.is_symmetric():
+ return False
+
+ # If ``A`` is symmetric, we only need to check that it is positive
+ # semidefinite. For that we can consult its minimum eigenvalue,
+ # which should be zero or greater. Since ``A`` is symmetric, its
+ # eigenvalues are guaranteed to be real.
+ return min(A.eigenvalues()) >= 0
+
+