]> gitweb.michael.orlitzky.com - sage.d.git/blobdiff - mjo/cone/completely_positive.py
mjo/cone: drop is_symmetric_p{s,}d() methods.
[sage.d.git] / mjo / cone / completely_positive.py
index ac5f14435713b4b524c53a2e1c73607ee004b323..3dc66b454dfb8a85a4aa2ba4a4be03978a5b3690 100644 (file)
@@ -1,18 +1,14 @@
-"""
+r"""
 The completely positive cone `$\mathcal{K}$` over `\mathbb{R}^{n}$` is
 the set of all matrices `$A$`of the form `$\sum uu^{T}$` for `$u \in
 \mathbb{R}^{n}_{+}$`. Equivalently, `$A = XX{T}$` where all entries of
 `$X$` are nonnegative.
 """
 
-# Sage doesn't load ~/.sage/init.sage during testing (sage -t), so we
-# have to explicitly mangle our sitedir here so that "mjo.cone"
-# resolves.
-from os.path import abspath
-from site import addsitedir
-addsitedir(abspath('../../'))
-from mjo.cone.symmetric_psd import factor_psd, is_symmetric_psd
-from mjo.cone.doubly_nonnegative import is_doubly_nonnegative, is_extreme_doubly_nonnegative
+from sage.all import *
+from mjo.cone.symmetric_psd import factor_psd
+from mjo.cone.doubly_nonnegative import (is_doubly_nonnegative,
+                                         is_extreme_doubly_nonnegative)
 
 def is_completely_positive(A):
     """
@@ -30,6 +26,10 @@ def is_completely_positive(A):
     Either ``True`` if ``A`` is completely positive, or ``False``
     otherwise.
 
+    SETUP::
+
+        sage: from mjo.cone.completely_positive import is_completely_positive
+
     EXAMPLES:
 
     Generate an extreme completely positive matrix and check that we
@@ -89,7 +89,7 @@ def is_completely_positive(A):
         msg = 'The matrix ``A`` cannot be symbolic.'
         raise ValueError.new(msg)
 
-    if not is_symmetric_psd(A):
+    if not A.is_positive_semidefinite():
         return False
 
     n = A.nrows() # Makes sense since ``A`` is symmetric.
@@ -124,6 +124,10 @@ def is_extreme_completely_positive(A):
     1. Berman, Abraham and Shaked-Monderer, Naomi. Completely Positive
        Matrices. World Scientific, 2003.
 
+    SETUP::
+
+        sage: from mjo.cone.completely_positive import is_extreme_completely_positive
+
     EXAMPLES:
 
     Generate an extreme completely positive matrix and check that we
@@ -172,7 +176,7 @@ def is_extreme_completely_positive(A):
         msg = 'The matrix ``A`` cannot be symbolic.'
         raise ValueError(msg)
 
-    if not is_symmetric_psd(A):
+    if not A.is_positive_semidefinite():
         return False
 
     n = A.nrows() # Makes sense since ``A`` is symmetric.