Functions to compute matrix inverse, store/return cached values