Code to create the matrix cache and compute invers