Updates matrix structure