Added code to implement the cached matrix functions.