code and comments to cache matrix