cachematrix implemented for assignment.