first implementation cached matrix

implement both functions, and some basic tests