Add cached matrix inverse function