normalize

fnbool normalize(R)(R range, ElementType!(R) sum = 1) if (isForwardRange!(R))

Normalizes values in range by multiplying each element with a number chosen such that values sum up to sum. If elements in range sum to zero, assigns sum / range.length to all. Normalization makes sense only if all elements in range are positive. normalize assumes that is the case without checking it.

Returns

true if normalization completed normally, false if

all elements in range were zero or if range is empty.