Completed code for assignment 2.

Added functionality for the cache matrix.