modded file to compute and store matrix inverse