First version of cachematrix functions