compute Inverse of matrix and cache the result

Changes to compute Inverse of matrix and cache the result