C implementation of NAC dynamical matrix