for assignment2 cache the matrix inversion