Complete implementation of cachematrix.R