cache and retrieve matrix inverse