Cachematrix function update