Completed Matrix Inverse Function

Caches for faster calculation