implement cache functions

This pair of functions caches the inverse of a matrix.