linear-algebra: memoization with maps :D