added functions to calculate and store inverseof matrix