Implement matrix inversion with solution caching