matrix mean code modified for assignment 2 to do matrix inversion