update matrix size