matrix function and inverse caching/calculating finishes!