Modified R file to support matrix Inverse function