Implementation of a cache matrix and a function to calculate and cache its inverse