updated functions for matrix with cached inverse