Implementation of programming assignment 2 cachematrix.