generalize dot product