implement cached matrix inversion.