placing Sheena Joseph solution to cachematrix.R