matrix inverse in python without numpy