Added core functional code for matrix inverse caching.