my inverse function for mmatrices using cache