Implement the matrix with cached inverse