Update cachematrix.R

Add my own code to the stub from R. Peng.