Finalized cachematrix.R