cacheable matrix functions.