## 3.14 Reduction of a vector to a scalar

A special category of scalar use within loops is reduction operations. This category involves the reduction of a vector of values down to a scalar result.

The most common reduction is the summation of all elements of a vector. Other reductions include:

• The dot product of two vectors.

• The maximum value in a vector.

• The minimum value in a vector.

• The product of all vector elements.

• The index of the maximum or minimum element of a vector.

The following example shows a dot product reduction where `x` is a reduction scalar.

```float a[99], b[99], x;
int i, n;
...
for (i = 0; i < n; i++) x += a[i] * b[i];
```

Reduction operations are worth vectorizing because they occur so often. In general, reduction operations are vectorized by creating a vector of partial reductions that is then reduced into the final resulting scalar.

##### Related reference
3.11 Recommended loop structure for vectorization
8.189 --vectorize, --no_vectorize
3.10 NEON vectorization performance goals