Added functions to calculate inverse of matrix