Modified the file cachematirx.R as per the assignment task.