First version of matrix class with cached inverse