revised and commented cache matrix functions