implemented functions on cachematrix.R