Calculate inverse of a matrix that utilize caching

Calculate an inverse of an input matrix, using caching to improve
performance.  The input matrix is assumed to be square and can be
inverses.