Initial version of the functions. matrix inversion and caching works.