]> gitweb.michael.orlitzky.com - dunshire.git/blobdiff - src/dunshire/matrices.py
Fix SymmetricPSD documentation and add the column-major vec() function.
[dunshire.git] / src / dunshire / matrices.py
index 0d97c0cbc4e83dfc95231a2306b870fb7b93a5db..1e0f2a5b7970fd19b78a2d136dc0a98dee2547af 100644 (file)
@@ -101,3 +101,26 @@ def norm(matrix_or_vector):
 
     """
     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))