finalized functions to create special matrix and calculate its inverse that is stored in cache