]> gitweb.michael.orlitzky.com - dunshire.git/blob - matrices.py
Add a TODO with a bunch of things I need to do.
[dunshire.git] / matrices.py
1 from cvxopt import matrix, spmatrix
2
3 def append_col(A,b):
4 """
5 Append the column ``b`` to the right side of the matrix ``A``.
6 """
7 return matrix([A.trans(),b.trans()]).trans()
8
9 def append_row(A,b):
10 """
11 Append the row ``b`` to the bottom of the matrix ``A``.
12 """
13 return matrix([A,b])
14
15 def identity(n):
16 """
17 Return the ``n``-by-``n`` identity matrix.
18 """
19 return spmatrix(1,range(n),range(n))