= IDISA Horizontal Operations =
The table below lists the various IDISA horizontal operations on vectors of N-bit
fields, together with their description and semantic specification.
These operations generally have the form `r = hsimd::op(a, b)` for each
operation `op`, where `a` and `b` are operand vectors of N bit fields and `r` is
the corresponding result vector.
In general, operand fields may be interpreted as either signed or unsigned ''w''-bit
integers, depending on the operation. When the results depend on
this interpretation, the notation s(a) refers to the interpretation
of field a as a signed integer (2's complement interpretation), while
the notation u(a) refers to the interpretation as an unsigned integer
(natural binary interpretation).
In general, result fields are converted to N-bits by truncation.
|| `add` || addition || r,,i,, = c,,2i,, + c,,2i+1,, ||
|| `min` || minimum value || r,,i,, = if s(c,,2i,,) < s(c,,2i+1,,) then c,,2i,, else c,,2i+1,, ||
|| `umin` || minimum value || r,,i,, = if u(c,,2i,,) < u(c,,2i+1,,) then c,,2i,, else c,,2i+1,, ||
|| `packl` || pack low || r,,i,, = c,,2i+1,, ||
|| `packh` || pack high || r,,i,, = c,,2i,, ||
|| `packus` || pack with unsigned saturation || r,,i,, = us,,N,,(concat(c,,2i,,, c,,2i+1,,))||
|| `packss` || pack with signed saturation || r,,i,, = ss,,N,,(concat(c,,2i,,, c,,2i+1,,)) ||
where the ''w''-bit unsigned and signed saturation functions are defined as follows.
- us,,''w'',,(x) = x, if u(x) < 2^''w''^
- us,,''w'',,(x) = 2^''w''^-1, if u(x) >= 2^''w''^
- ss,,''w'',,(x) = x, if -2^''w''-1^ <= s(x) < 2^''w''-1^
- ss,,''w'',,(x) = 2^''w''-1^-1, if s(x) >= 2^''w''-1^
- ss,,''w'',,(x) = -2^''w''-1^, if s(x) < 2^''w''-1^
In these definitions, fields are numbered left-to-right in so-called *big-endian*
style. Implementations using little-endian processors generally reverse the
arguments c,,2i,, and c,,2i+1,,.