completed and tested cachematrix.R functions