added functionality to both functions

* can now cache the calculation of an inverse matrix