Cached matrix inverse implementation