update matrix dimensions