C implementation of group velocity