Cache matrix inversion via the solve function