Write matrix inverse functions