from os.path import abspath
from site import addsitedir
addsitedir(abspath('../../'))
-from mjo.cone.symmetric_psd import factor_psd
+from mjo.cone.symmetric_psd import factor_psd, is_symmetric_psd
"""
if A.base_ring() == SR:
- msg = 'The base ring of ``A`` cannot be the Symbolic Ring'
+ msg = 'The matrix ``A`` cannot be the symbolic.'
raise ValueError.new(msg)
- # First make sure that ``A`` is symmetric.
- if not A.is_symmetric():
- return False
-
# Check that all of the entries of ``A`` are nonnegative.
if not all([ a >= 0 for a in A.list() ]):
return False
- # If ``A`` is symmetric and non-negative, 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
+ # It's nonnegative, so all we need to do is check that it's
+ # symmetric positive-semidefinite.
+ return is_symmetric_psd(A)