functions for cached inverse matrix calculations