Pair of functions to calculate inverses of matrices or retrieve inverses of matrices from cache in a time efficient manner