long dotProduct(const short *a, const short *b, unsigned int n) { long sum = 0; for (unsigned int i = 0; i < n; i++) { sum += (long)a[i] * (long)b[i]; } return sum; }