Some useful matrix functions in pure Python