Function for storing and retrieving a matrix inverse