Implementation of Assignment 2, caching invers matrices