added assignment 2 code

added code to 2 functions to handle the matrix inversion and cache.