Cache matrix functions implementation