cache matrix solution