A cached matrix inverse implementation