add general matrix inverse function