from cvxopt import matrix, spmatrix def append_col(A,b): """ Append the column ``b`` to the right side of the matrix ``A``. """ return matrix([A.trans(),b.trans()]).trans() def append_row(A,b): """ Append the row ``b`` to the bottom of the matrix ``A``. """ return matrix([A,b]) def identity(n): """ Return the ``n``-by-``n`` identity matrix. """ return spmatrix(1,range(n),range(n))