]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
mjo/cone: rename random_psd() to random_symmetric_psd().
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 30 Nov 2018 16:00:57 +0000 (11:00 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 30 Nov 2018 16:00:57 +0000 (11:00 -0500)
mjo/cone/doubly_nonnegative.py
mjo/cone/symmetric_psd.py

index 92184d15c4133e33f04e877352787378ae3739df..a30a827d158f3b99d7d9df5d295096e7cc349e0f 100644 (file)
@@ -13,7 +13,9 @@ It is represented typically by either `\mathcal{D}^{n}` or
 
 from sage.all import *
 
-from mjo.cone.symmetric_psd import factor_psd, is_symmetric_psd, random_psd
+from mjo.cone.symmetric_psd import (factor_psd,
+                                    is_symmetric_psd,
+                                    random_symmetric_psd)
 from mjo.matrix_vector import isomorphism
 
 
@@ -458,10 +460,10 @@ def random_doubly_nonnegative(V, accept_zero=True, rank=None):
 
     # Generate random symmetric positive-semidefinite matrices until
     # one of them is nonnegative, then return that.
-    A = random_psd(V, accept_zero, rank)
+    A = random_symmetric_psd(V, accept_zero, rank)
 
     while not all( x >= 0 for x in A.list() ):
-        A = random_psd(V, accept_zero, rank)
+        A = random_symmetric_psd(V, accept_zero, rank)
 
     return A
 
index 1b3dd8ab6d8905a1af202eec3816c46ece906561..e75c152b86be407f2e235f7db7e2b4c51a42b8ad 100644 (file)
@@ -201,7 +201,7 @@ def factor_psd(A):
     return Q*root_D*Q.transpose()
 
 
-def random_psd(V, accept_zero=True, rank=None):
+def random_symmetric_psd(V, accept_zero=True, rank=None):
     """
     Generate a random symmetric positive-semidefinite matrix over the
     vector space ``V``. That is, the returned matrix will be a linear
@@ -242,14 +242,15 @@ def random_psd(V, accept_zero=True, rank=None):
 
     SETUP::
 
-        sage: from mjo.cone.symmetric_psd import is_symmetric_psd, random_psd
+        sage: from mjo.cone.symmetric_psd import (is_symmetric_psd,
+        ....:                                     random_symmetric_psd)
 
     EXAMPLES:
 
     Well, it doesn't crash at least::
 
         sage: V = VectorSpace(QQ, 2)
-        sage: A = random_psd(V)
+        sage: A = random_symmetric_psd(V)
         sage: A.matrix_space()
         Full MatrixSpace of 2 by 2 dense matrices over Rational Field
         sage: is_symmetric_psd(A)
@@ -258,26 +259,26 @@ def random_psd(V, accept_zero=True, rank=None):
     A matrix with the desired rank is returned::
 
         sage: V = VectorSpace(QQ, 5)
-        sage: A = random_psd(V,False,1)
+        sage: A = random_symmetric_psd(V,False,1)
         sage: A.rank()
         1
-        sage: A = random_psd(V,False,2)
+        sage: A = random_symmetric_psd(V,False,2)
         sage: A.rank()
         2
-        sage: A = random_psd(V,False,3)
+        sage: A = random_symmetric_psd(V,False,3)
         sage: A.rank()
         3
-        sage: A = random_psd(V,False,4)
+        sage: A = random_symmetric_psd(V,False,4)
         sage: A.rank()
         4
-        sage: A = random_psd(V,False,5)
+        sage: A = random_symmetric_psd(V,False,5)
         sage: A.rank()
         5
 
     If the user asks for a rank that's too high, we fail::
 
         sage: V = VectorSpace(QQ, 2)
-        sage: A = random_psd(V,False,3)
+        sage: A = random_symmetric_psd(V,False,3)
         Traceback (most recent call last):
         ...
         ValueError: The ``rank`` must be between 0 and the dimension of ``V``.
@@ -318,4 +319,4 @@ def random_psd(V, accept_zero=True, rank=None):
         return A
     else:
         # Uh oh, we need to generate a new one.
-        return random_psd(V, accept_zero, rank)
+        return random_symmetric_psd(V, accept_zero, rank)