Code for Assignment 2

Calculates inverse of a given matrix or returns cached value.