class SymmetricPSD(SymmetricCone):
"""
- The nonnegative orthant in ``n`` dimensions.
+ The cone of real symmetric positive-semidefinite matrices.
+
+ This cone has a dimension ``n`` associated with it, but we let ``n``
+ refer to the dimension of the domain of our matrices and not the
+ dimension of the (much larger) space in which the matrices
+ themselves live. In other words, our ``n`` is the ``n`` that appears
+ in the usual notation `S^{n}` for symmetric matrices.
+
+ As a result, the cone ``SymmetricPSD(n)`` lives in a space of dimension
+ ``(n**2 + n)/2)``.
EXAMPLES:
>>> K = SymmetricPSD(3)
>>> print(K)
Cone of symmetric positive-semidefinite matrices on the real 3-space
+ >>> K.dimension()
+ 3
"""
def __str__(self):
"""
return sqrt(sum([x**2 for x in matrix_or_vector]))
+
+
+def vec(real_matrix):
+ """
+ Create a long vector in column-major order from ``real_matrix``.
+
+ EXAMPLES:
+
+ >>> A = matrix([[1,2],[3,4]])
+ >>> print(A)
+ [ 1 3]
+ [ 2 4]
+ <BLANKLINE>
+
+ >>> print(vec(A))
+ [ 1]
+ [ 2]
+ [ 3]
+ [ 4]
+ <BLANKLINE>
+
+ """
+ return matrix(real_matrix, (len(real_matrix), 1))