Cache Matrix implementation