from sage.all import *
-# Sage doesn't load ~/.sage/init.sage during testing (sage -t), so we
-# have to explicitly mangle our sitedir here so that "mjo.symbolic"
-# resolves.
-from os.path import abspath
-from site import addsitedir
-addsitedir(abspath('../../'))
-from mjo.symbolic import matrix_simplify_full
-
-
def is_symmetric_psd(A):
"""
Determine whether or not the matrix ``A`` is symmetric
Either ``True`` if ``A`` is symmetric positive-semidefinite, or
``False`` otherwise.
+ SETUP::
+
+ sage: from mjo.cone.symmetric_psd import is_symmetric_psd
+
EXAMPLES:
Every completely positive matrix is symmetric
A list of (eigenvalue, eigenvector) pairs where each eigenvector is
associated with its paired eigenvalue of ``A`` and has norm `1`.
+ SETUP::
+
+ sage: from mjo.cone.symmetric_psd import unit_eigenvectors
+
EXAMPLES::
sage: A = matrix(QQ, [[0, 2, 3], [2, 0, 0], [3, 0, 0]])
`$D$` will have dimension `$k \times k$`. In the end everything
works out the same.
+ SETUP::
+
+ sage: from mjo.cone.symmetric_psd import factor_psd
+
EXAMPLES:
Create a symmetric positive-semidefinite matrix over the symbolic
sage: A = matrix(SR, [[0, 2, 3], [2, 0, 0], [3, 0, 0]])
sage: X = factor_psd(A)
- sage: A2 = matrix_simplify_full(X*X.transpose())
+ sage: A2 = (X*X.transpose()).simplify_full()
sage: A == A2
True
``accept_zero`` is ``False``, we restart the process from the
beginning.
+ SETUP::
+
+ sage: from mjo.cone.symmetric_psd import is_symmetric_psd, random_psd
+
EXAMPLES:
Well, it doesn't crash at least::
# Use the one the user gave us.
rank_A = rank
- # Begin with the zero matrix, and add projectors to it if we have
- # any.
- A = V.zero_element().column()*V.zero_element().row()
+ # Begin with the zero matrix, and add projectors to it if we have any.
+ A = V.zero().column()*V.zero().row()
# Careful, begin at idx=1 so that we only generate a projector
# when rank_A is greater than zero.