Implement a matrix with cachable inverse.