Implement 2 functions for cache-able matrix inverse calculation.