Added cache matrix functions