Share normalization code across nvmatrix and matrix.