implemented matrix cache functions for assignment 2