build out matrix inversion caching functions