from cvxopt import matrix, spmatrix
+from math import sqrt
def append_col(A,b):
"""
"""
return matrix([A.trans(),b.trans()]).trans()
-def append_cols(cols):
- """
- Append a bunch of columns together, left to right.
- """
- if len(cols) == 0:
- return cols
-
- result = cols[0]
- del(cols[0])
- for column in cols:
- result = append_col(result, column)
-
- return result
-
-
def append_row(A,b):
"""
Append the row ``b`` to the bottom of the matrix ``A``.
Return the ``n``-by-``n`` identity matrix.
"""
return spmatrix(1,range(n),range(n))
+
+def norm(x):
+ """
+ Return the Euclidean norm of the given vector.
+ """
+ return sqrt(sum([z**2 for z in x]))