Functions to compute and cache inverse of a matrix.