Coding the matrix, linear algebra, python implementation