matrix inverse solver, implemented caching od computed results