python code for manipulating some linear algebra constructs