Defined and unit tested cache matrix functions.