updated cachematrix code

added code into functions to store and calculate needed data