Implemented cached inverse of matrix