filled in cachematrix R script with required functions