Adds cache matrix functionality.