First version of cached matrix functions.