working methods for cachematrix.R