Support to compute and cache inverse of a square matrix

In this implementation, it only uses solve to compute the inverse of a square matrix. It couldn't support 3x3 or 4x4.