Implementation of cachematrix.R