Cache matrix functions