Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# 32-bit vector API

group vect_s32_api

  Defines

  VECT_SQRT_S32_MAX_DEPTH

    Maximum bit-depth that can be calculated by vect_s32_sqrt().

    See also

    vect_s32_sqrt

  Enums

  enum pad_mode_e

    Supported padding modes for convolutions in “same” mode.

    See also

    vect_s32_convolve_same(), bfp_s32_convolve_same()

    Values:

    enumerator PAD_MODE_REFLECT

      Vector is reflected at its boundaries, such that

      \( \tilde{x}_i \begin{cases} x_{-i} & i < 0 \\ x_{2N - 2 - i} & i \ge N \\ x_i & otherwise \end{cases} \)

      For example, if the length \(N\) of input vector \(\bar x\) is \(7\) and the order \(K\) of the filter is \(5\), then

      \( \bar{x} = [x_0, x_1, x_2, x_3, x_4, x_5, x_6] \)

      \( \tilde{x} = [x_2, x_1, x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_5, x_4] \)

      Note that by convention the first element of \(\tilde{x}\) is considered to be at index \(-P\), where \(P = \lfloor K/2 \rfloor\).

    enumerator PAD_MODE_EXTEND

      Vector is padded using the value of the bounding elements.

      \( \tilde{x}_i \begin{cases} x_{0} & i < 0 \\ x_{N-1} & i \ge N \\ x_i & otherwise \end{cases} \)

      For example, if the length \(N\) of input vector \(\bar x\) is \(7\) and the order \(K\) of the filter is \(5\), then

      \( \bar{x} = [x_0, x_1, x_2, x_3, x_4, x_5, x_6] \)

      \( \tilde{x} = [x_0, x_0, x_0, x_1, x_2, x_3, x_4, x_5, x_6, x_6, x_6] \)

      Note that by convention the first element of \(\tilde{x}\) is considered to be at index \(-P\), where \(P = \lfloor K/2 \rfloor\).

    enumerator PAD_MODE_ZERO

      Vector is padded with zeroes.

      \( \tilde{x}_i \begin{cases} 0 & i < 0 \\ 0 & i \ge N \\ x_i & otherwise \end{cases} \)

      For example, if the length \(N\) of input vector \(\bar x\) is \(7\) and the order \(K\) of the filter is \(5\), then

      \( \bar{x} = [x_0, x_1, x_2, x_3, x_4, x_5, x_6] \)

      \( \tilde{x} = [0, 0, x_0, x_1, x_2, x_3, x_4, x_5, x_6, 0, 0] \)

      Note that by convention the first element of \(\tilde{x}\) is considered to be at index \(-P\), where \(P = \lfloor K/2 \rfloor\).

  Functions

  headroom_t vect_s32_copy(int32_t a[], const int32_t b[], const unsigned length)

    Copy one 32-bit vector to another.

    This function is effectively a constrained version of `memcpy`.

    With the constraints below met, this function should be modestly faster than `memcpy`.

    `a[]` is the output vector to which elements are copied.

    `b[]` is the input vector from which elements are copied.

    `a` and `b` each must begin at a word-aligned address.

    `length` is the number of elements to be copied. `length` must be a multiple of 8.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow b_k \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of output vector \(\bar a\)

  headroom_t vect_s32_abs(int32_t a[], const int32_t b[], const unsigned length)

    Compute the element-wise absolute value of a 32-bit vector.

    `a[]` and `b[]` represent the 32-bit vectors \(\bar a\) and \(\bar b\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`.

    `length` is the number of elements in each of the vectors.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow sat_{32}(\left| b_k \right|) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the output vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp\).

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of the output vector \(\bar a\).

  int64_t vect_s32_abs_sum(const int32_t b[], const unsigned length)

    Compute the sum of the absolute values of elements of a 32-bit vector.

    `b[]` represents the 32-bit mantissa vector \(\bar b\). `b[]` must begin at a word-aligned address.

    `length` is the number of elements in \(\bar b\).

    Operation Performed

      \[\begin{aligned} \sum_{k=0}^{length-1} sat_{32}(\left| b_k \right|) \end{aligned}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the returned value \(a\) is the 64-bit mantissa of floating-point value \(a \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp\).

    Additional Details

      Internally the sum accumulates into 8 separate 40-bit accumulators. These accumulators apply symmetric 40-bit saturation logic (with bounds \(\pm (2^{39}-1)\)) with each added element. At the end, the 8 accumulators are summed together into the 64-bit value \(a\) which is returned by this function. No saturation logic is applied at this final step.

      Because symmetric 32-bit saturation logic is applied when computing the absolute value, in the corner case where each element is `INT32_MIN`, each of the 8 accumulators can accumulate \(256\) elements before saturation is possible. Therefore, with \(b\_hr\) bits of headroom, no saturation of intermediate results is possible with fewer than \(2^{11 + b\_hr}\) elements in \(\bar b\).

      If the length of \(\bar b\) is greater than \(2^{11 + b\_hr}\), the sum can be computed piece-wise in several calls to this function, with the partial results summed in user code.

    Parameters:

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      The 64-bit sum \(a\)

  headroom_t vect_s32_add(int32_t a[], const int32_t b[], const int32_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)

    Add together two 32-bit vectors.

    `a[]`, `b[]` and `c[]` represent the 32-bit mantissa vectors \(\bar a\), \(\bar b\) and \(\bar c\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]` or `c[]`.

    `length` is the number of elements in each of the vectors.

    `b_shr` and `c_shr` are the signed arithmetic right-shifts applied to each element of \(\bar b\) and \(\bar c\) respectively.

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' = sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & c_k' = sat_{32}(\lfloor c_k \cdot 2^{-c\_shr} \rfloor) \\ & a_k \leftarrow sat_{32}\!\left( b_k' + c_k' \right) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) and \(\bar c\) are the mantissas of BFP vectors \( \bar{b} \cdot 2^{b\_exp} \) and \(\bar{c} \cdot 2^{c\_exp}\), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\).

      In this case, \(b\_shr\) and \(c\_shr\) must be chosen so that \(a\_exp = b\_exp + b\_shr = c\_exp + c\_shr\). Adding or subtracting mantissas only makes sense if they are associated with the same exponent.

      The function vect_s32_add_prepare() can be used to obtain values for \(a\_exp\), \(b\_shr\) and \(c\_shr\) based on the input exponents \(b\_exp\) and \(c\_exp\) and the input headrooms \(b\_hr\) and \(c\_hr\).

    See also

    vect_s32_add_prepare()

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] Number of elements in vectors \(\bar a\), \(\bar b\) and \(\bar c\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

      - c_shr – [in] Right-shift appled to \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `a`, `b` or `c` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of the output vector \(\bar a\).

  headroom_t vect_s32_add_scalar(int32_t a[], const int32_t b[], const int32_t c, const unsigned length, const right_shift_t b_shr)

    Add a scalar to a 32-bit vector.

    `a[]`, `b[]` represent the 32-bit mantissa vectors \(\bar a\) and \(\bar b\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`.

    `c` is the scalar \(c\) to be added to each element of \(\bar b\).

    `length` is the number of elements in each of the vectors.

    `b_shr` is the signed arithmetic right-shift applied to each element of \(\bar b\).

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' = sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & a_k \leftarrow sat_{32}\!\left( b_k' + c \right) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If elements of \(\bar b\) are the mantissas of BFP vector \( \bar{b} \cdot 2^{b\_exp} \), and \(c\) is the mantissa of floating-point value \(c \cdot 2^{c\_exp}\), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\).

      In this case, \(b\_shr\) and \(c\_shr\) must be chosen so that \(a\_exp = b\_exp + b\_shr = c\_exp + c\_shr\). Adding or subtracting mantissas only makes sense if they are associated with the same exponent.

      The function vect_s32_add_scalar_prepare() can be used to obtain values for \(a\_exp\), \(b\_shr\) and \(c\_shr\) based on the input exponents \(b\_exp\) and \(c\_exp\) and the input headrooms \(b\_hr\) and \(c\_hr\).

      Note that \(c\_shr\) is an output of `vect_s32_add_scalar_prepare()`, but is not a parameter to this function. The \(c\_shr\) produced by `vect_s32_add_scalar_prepare()` is to be applied by the user, and the result passed as input `c`.

    See also

    vect_s32_add_scalar_prepare()

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input scalar \(c\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of the output vector \(\bar a\).

  unsigned vect_s32_argmax(const int32_t b[], const unsigned length)

    Obtain the array index of the maximum element of a 32-bit vector.

    `b[]` represents the 32-bit input vector \(\bar b\). It must begin at a word-aligned address.

    `length` is the number of elements in \(\bar b\).

    Operation Performed

      \[\begin{split}\begin{aligned} & a \leftarrow argmax_k\{ b_k \} \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]
    Parameters:

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elemetns in \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      \(a\), the index of the maximum element of vector \(\bar b\). If there is a tie for the maximum value, the lowest tying index is returned.

  unsigned vect_s32_argmin(const int32_t b[], const unsigned length)

    Obtain the array index of the minimum element of a 32-bit vector.

    `b[]` represents the 32-bit input vector \(\bar b\). It must begin at a word-aligned address.

    `length` is the number of elements in \(\bar b\).

    Operation Performed

      \[\begin{split}\begin{aligned} & a \leftarrow argmin_k\{ b_k \} \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]
    Parameters:

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elemetns in \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      \(a\), the index of the minimum element of vector \(\bar b\). If there is a tie for the minimum value, the lowest tying index is returned.

  headroom_t vect_s32_clip(int32_t a[], const int32_t b[], const unsigned length, const int32_t lower_bound, const int32_t upper_bound, const right_shift_t b_shr)

    Clamp the elements of a 32-bit vector to a specified range.

    `a[]` and `b[]` represent the 32-bit vectors \(\bar a\) and \(\bar b\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`.

    `length` is the number of elements in each of the vectors.

    `lower_bound` and `upper_bound` are the lower and upper bounds of the clipping range respectively. These bounds are checked for each element of \(\bar b\) only after `b_shr` is applied.

    `b_shr` is the signed arithmetic right-shift applied to elements of \(\bar b\) before being compared to the upper and lower bounds.

    If \(\bar b\) are the mantissas for a BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the exponent \(a\_exp\) of the output BFP vector \(\bar{a} \cdot 2^{a\_exp}\) is given by \(a\_exp = b\_exp + b\_shr\).

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' \leftarrow sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & a_k \leftarrow \begin{cases} lower\_bound & b_k' \le lower\_bound \\ upper\_bound & b_k' \ge upper\_bound \\ b_k' & otherwise \end{cases} \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the output vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp + b\_shr\).

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

      - lower_bound – [in] Lower bound of clipping range

      - upper_bound – [in] Upper bound of clipping range

      - b_shr – [in] Arithmetic right-shift applied to elements of \(\bar b\) prior to clipping

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of output vector \(\bar a\)

  int64_t vect_s32_dot(const int32_t b[], const int32_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)

    Compute the inner product between two 32-bit vectors.

    `b[]` and `c[]` represent the 32-bit mantissa vectors \(\bar b\) and \(\bar c\) respectively. Each must begin at a word-aligned address.

    `length` is the number of elements in each of the vectors.

    `b_shr` and `c_shr` are the signed arithmetic right-shifts applied to each element of \(\bar b\) and \(\bar c\) respectively.

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' \leftarrow sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & c_k' \leftarrow sat_{32}(\lfloor c_k \cdot 2^{-c\_shr} \rfloor) \\ & a \leftarrow \sum_{k=0}^{length-1}\left(round( b_k' \cdot c_k' \cdot 2^{-30} ) \right) \\ & \qquad\text{where } a \text{ is returned} \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) and \(\bar c\) are the mantissas of the BFP vectors \( \bar{b} \cdot 2^{b\_exp} \) and \(\bar{c}\cdot 2^{c\_exp}\), then result \(a\) is the 64-bit mantissa of the result \(a \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp + c\_exp + b\_shr + c\_shr + 30\).

      If needed, the bit-depth of \(a\) can then be reduced to 32 bits to get a new result \(a' \cdot 2^{a\_exp'}\) where \(a' = a \cdot 2^{-a\_shr}\) and \(a\_exp' = a\_exp + a\_shr\).

      The function vect_s32_dot_prepare() can be used to obtain values for \(a\_exp\), \(b\_shr\) and \(c\_shr\) based on the input exponents \(b\_exp\) and \(c\_exp\) and the input headrooms \(b\_hr\) and \(c\_hr\).

    Additional Details

      The 30-bit rounding right-shift applied to each of the 64-bit products \(b_k \cdot c_k\) is a feature of the hardware and cannot be avoided. As such, if the input vectors \(\bar b\) and \(\bar c\) together have too much headroom (i.e. \(b\_hr + c\_hr\)), the sum may effectively vanish. To avoid this situation, negative values of `b_shr` and `c_shr` may be used (with the stipulation that \(b\_shr \ge -b\_hr\) and \(c\_shr \ge -c\_hr\) if saturation of \(b_k'\) and \(c_k'\) is to be avoided). The less headroom \(b_k'\) and \(c_k'\) have, the greater the precision of the final result.

      Internally, each product \((b_k' \cdot c_k' \cdot 2^{-30})\) accumulates into one of eight 40-bit accumulators (which are all used simultaneously) which apply symmetric 40-bit saturation logic (with bounds \(\approx 2^{39}\)) with each value added. The saturating arithmetic employed is not associative and no indication is given if saturation occurs at an intermediate step. To avoid satuation errors, `length` should be no greater than \(2^{10+b\_hr+c\_hr}\), where \(b\_hr\) and \(c\_hr\) are the headroom of \(\bar b\) and \(\bar c\) respectively.

      If the caller’s mantissa vectors are longer than that, the full inner product can be found by calling this function multiple times for partial inner products on sub-sequences of the input vectors, and adding the results in user code.

      In many situations the caller may have a priori knowledge that saturation is impossible (or very nearly so), in which case this guideline may be disregarded. However, such situations are application-specific and are well beyond the scope of this documentation, and as such are left to the user’s discretion.

    Parameters:

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] Number of elements in vectors \(\bar b\) and \(\bar c\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

      - c_shr – [in] Right-shift appled to \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `b` or `c` is not word-aligned (See Note: Vector Alignment)

    Returns:

      The inner product of vectors \(\bar b\) and \(\bar c\), scaled as indicated above.

  int64_t vect_s32_energy(const int32_t b[], const unsigned length, const right_shift_t b_shr)

    Calculate the energy (sum of squares of elements) of a 32-bit vector.

    `b[]` represents the 32-bit mantissa vector \(\bar b\). `b[]` must begin at a word-aligned address.

    `length` is the number of elements in \(\bar b\).

    `b_shr` is the signed arithmetic right-shift applied to elements of \(\bar b\).

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' \leftarrow sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & a \leftarrow \sum_{k=0}^{length-1} round((b_k')^2 \cdot 2^{-30}) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of the BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then floating-point result is \(a \cdot 2^{a\_exp}\), where the 64-bit mantissa \(a\) is returned by this function, and \(a\_exp = 30 + 2 \cdot (b\_exp + b\_shr) \).

      The function vect_s32_energy_prepare() can be used to obtain values for \(a\_exp\), \(b\_shr\) and \(c\_shr\) based on the input exponents \(b\_exp\) and \(c\_exp\) and the input headrooms \(b\_hr\) and \(c\_hr\).

    Additional Details

      The 30-bit rounding right-shift applied to each element of the 64-bit products \((b_k')^2\) is a feature of the hardware and cannot be avoided. As such, if the input vector \(\bar b\) has too much headroom (i.e. \(2\cdot b\_hr\)), the sum may effectively vanish. To avoid this situation, negative values of `b_shr` may be used (with the stipulation that \(b\_shr \ge -b\_hr\) if satuartion of \(b_k'\) is to be avoided). The less headroom \(b_k'\) has, the greater the precision of the final result.

      Internally, each product \((b_k')^2 \cdot 2^{-30}\) accumulates into one of eight 40-bit accumulators (which are all used simultaneously) which apply symmetric 40-bit saturation logic (with bounds \(\approx 2^{39}\)) with each value added. The saturating arithmetic employed is not associative and no indication is given if saturation occurs at an intermediate step. To avoid saturation errors, `length` should be no greater than \(2^{10+2\cdot b\_hr}\), where \(b\_hr\) is the headroom of \(\bar b\).

      If the caller’s mantissa vector is longer than that, the full result can be found by calling this function multiple times for partial results on sub-sequences of the input, and adding the results in user code.

      In many situations the caller may have a priori knowledge that saturation is impossible (or very nearly so), in which case this guideline may be disregarded. However, such situations are application-specific and are well beyond the scope of this documentation, and as such are left to the user’s discretion.

    Parameters:

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in \(\bar b\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      64-bit mantissa of vector \(\bar b\)’s energy

  headroom_t vect_s32_headroom(const int32_t x[], const unsigned length)

    Calculate the headroom of a 32-bit vector.

    The headroom of an N-bit integer is the number of bits that the integer’s value may be left-shifted without any information being lost. Equivalently, it is one less than the number of leading sign bits.

    The headroom of an `int32_t` array is the minimum of the headroom of each of its `int32_t` elements.

    This function efficiently traverses the elements of `a[]` to determine its headroom.

    `x[]` represents the 32-bit vector \(\bar x\). `x[]` must begin at a word-aligned address.

    `length` is the number of elements in `x[]`.

    Operation Performed

      \[\begin{aligned} min\!\{ HR_{32}\left(x_0\right), HR_{32}\left(x_1\right), ..., HR_{32}\left(x_{length-1}\right) \} \end{aligned}\]

    See also

    vect_s16_headroom, vect_complex_s16_headroom, vect_complex_s32_headroom

    Parameters:

      - x – [in] Input vector \(\bar x\)

      - length – [in] The number of elements in `x[]`

    Throws ET_LOAD_STORE:

      Raised if `x` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of vector \(\bar x\)

  headroom_t vect_s32_inverse(int32_t a[], const int32_t b[], const unsigned length, const unsigned scale)

    Compute the inverse of elements of a 32-bit vector.

    `a[]` and `b[]` represent the 32-bit mantissa vectors \(\bar a\) and \(\bar b\) respectively. Each vector must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`.

    `length` is the number of elements in each of the vectors.

    `scale` is a scaling parameter used to maximize the precision of the result.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow \lfloor\frac{2^{scale}}{b_k}\rfloor \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = scale - b\_exp\).

      The function vect_s32_inverse_prepare() can be used to obtain values for \(a\_exp\) and \(scale\).

    See also

    vect_s32_inverse_prepare

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

      - scale – [in] Scale factor applied to dividend when computing inverse

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of output vector \(\bar a\)

  int32_t vect_s32_max(const int32_t b[], const unsigned length)

    Find the maximum value in a 32-bit vector.

    `b[]` represents the 32-bit vector \(\bar b\). It must begin at a word-aligned address.

    `length` is the number of elements in \(\bar b\).

    Operation Performed

      \[\begin{aligned} max\{ x_0, x_1, ..., x_{length-1} \} \end{aligned}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the returned value \(a\) is the 32-bit mantissa of floating-point value \(a \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp\).

    Parameters:

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Maximum value from \(\bar b\)

  headroom_t vect_s32_max_elementwise(int32_t a[], const int32_t b[], const int32_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)

    Get the element-wise maximum of two 32-bit vectors.

    `a[]`, `b[]` and `c[]` represent the 32-bit mantissa vectors \(\bar a\), \(\bar b\) and \(\bar c\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`, but not on `c[]`.

    `length` is the number of elements in each of the vectors.

    `b_shr` and `c_shr` are the signed arithmetic right-shifts applied to each element of \(\bar b\) and \(\bar c\) respectively.

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' \leftarrow sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & c_k' \leftarrow sat_{32}(\lfloor c_k \cdot 2^{-c\_shr} \rfloor) \\ & a_k \leftarrow max(b_k', c_k') \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) and \(\bar c\) are the mantissas of BFP vectors \( \bar{b} \cdot 2^{b\_exp} \) and \(\bar{c} \cdot 2^{c\_exp}\), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp + b\_shr = c\_exp + c\_shr\).

      The function vect_2vec_prepare() can be used to obtain values for \(a\_exp\), \(b\_shr\) and \(c\_shr\) based on the input exponents \(b\_exp\) and \(c\_exp\) and the input headrooms \(b\_hr\) and \(c\_hr\).

    Warning

    For correct operation, this function requires at least 1 bit of headroom in each mantissa vector after the shifts have been applied.

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] Number of elements in vectors \(\bar a\), \(\bar b\) and \(\bar c\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

      - c_shr – [in] Right-shift appled to \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `a`, `b` or `c` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of vector \(\bar a\)

  int32_t vect_s32_min(const int32_t b[], const unsigned length)

    Find the minimum value in a 32-bit vector.

    `b[]` represents the 32-bit vector \(\bar b\). It must begin at a word-aligned address.

    `length` is the number of elements in \(\bar b\).

    Operation Performed

      \[\begin{aligned} max\{ x_0, x_1, ..., x_{length-1} \} \end{aligned}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the returned value \(a\) is the 32-bit mantissa of floating-point value \(a \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp\).

    Parameters:

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Minimum value from \(\bar b\)

  headroom_t vect_s32_min_elementwise(int32_t a[], const int32_t b[], const int32_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)

    Get the element-wise minimum of two 32-bit vectors.

    `a[]`, `b[]` and `c[]` represent the 32-bit mantissa vectors \(\bar a\), \(\bar b\) and \(\bar c\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`, but not on `c[]`.

    `length` is the number of elements in each of the vectors.

    `b_shr` and `c_shr` are the signed arithmetic right-shifts applied to each element of \(\bar b\) and \(\bar c\) respectively.

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' \leftarrow sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & c_k' \leftarrow sat_{32}(\lfloor c_k \cdot 2^{-c\_shr} \rfloor) \\ & a_k \leftarrow min(b_k', c_k') \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) and \(\bar c\) are the mantissas of BFP vectors \( \bar{b} \cdot 2^{b\_exp} \) and \(\bar{c} \cdot 2^{c\_exp}\), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp + b\_shr = c\_exp + c\_shr\).

      The function vect_2vec_prepare() can be used to obtain values for \(a\_exp\), \(b\_shr\) and \(c\_shr\) based on the input exponents \(b\_exp\) and \(c\_exp\) and the input headrooms \(b\_hr\) and \(c\_hr\).

    Warning

    For correct operation, this function requires at least 1 bit of headroom in each mantissa vector after the shifts have been applied.

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] Number of elements in vectors \(\bar a\), \(\bar b\) and \(\bar c\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

      - c_shr – [in] Right-shift appled to \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `a`, `b` or `c` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of vector \(\bar a\)

  headroom_t vect_s32_mul(int32_t a[], const int32_t b[], const int32_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)

    Multiply one 32-bit vector element-wise by another.

    `a[]`, `b[]` and `c[]` represent the 32-bit mantissa vectors \(\bar a\), \(\bar b\) and \(\bar c\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]` or `c[]`.

    `length` is the number of elements in each of the vectors.

    `b_shr` and `c_shr` are the signed arithmetic right-shifts applied to each element of \(\bar b\) and \(\bar c\) respectively.

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' \leftarrow sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & c_k' \leftarrow sat_{32}(\lfloor c_k \cdot 2^{-c\_shr} \rfloor) \\ & a_k \leftarrow sat_{32}(round(b_k' \cdot c_k' \cdot 2^{-30})) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) and \(\bar c\) are the mantissas of BFP vectors \( \bar{b} \cdot 2^{b\_exp} \) and \(\bar{c} \cdot 2^{c\_exp}\), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp + c\_exp + b\_shr + c\_shr + 30\).

      The function vect_s32_mul_prepare() can be used to obtain values for \(a\_exp\), \(b\_shr\) and \(c\_shr\) based on the input exponents \(b\_exp\) and \(c\_exp\) and the input headrooms \(b\_hr\) and \(c\_hr\).

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] Number of elements in vectors \(\bar a\), \(\bar b\) and \(\bar c\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

      - c_shr – [in] Right-shift appled to \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `a`, `b` or `c` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of vector \(\bar a\)

  headroom_t vect_s32_macc(int32_t acc[], const int32_t b[], const int32_t c[], const unsigned length, const right_shift_t acc_shr, const right_shift_t b_shr, const right_shift_t c_shr)

    Multiply one 32-bit vector element-wise by another, and add the result to an accumulator.

    `acc[]` represents the 32-bit accumulator mantissa vector \(\bar a\). Each \(a_k\) is `acc[k]`.

    `b[]` and `c[]` represent the 32-bit input mantissa vectors \(\bar b\) and \(\bar c\), where each \(b_k\) is `b[k]` and each \(c_k\) is `c[k]`.

    Each of the input vectors must begin at a word-aligned address.

    `length` is the number of elements in each of the vectors.

    `acc_shr`, `b_shr` and `c_shr` are the signed arithmetic right-shifts applied to input elements \(a_k\), \(b_k\) and \(c_k\).

    Operation Performed

      \[\begin{split}\begin{aligned} & \tilde{b}_k \leftarrow sat_{32}( b_k \cdot 2^{-b\_shr} ) \\ & \tilde{c}_k \leftarrow sat_{32}( c_k \cdot 2^{-c\_shr} ) \\ & \tilde{a}_k \leftarrow sat_{32}( a_k \cdot 2^{-acc\_shr} ) \\ & v_k \leftarrow round( sat_{32}( \tilde{b}_k \cdot \tilde{c}_k \cdot 2^{-30} ) ) \\ & a_k \leftarrow sat_{32}( \tilde{a}_k + v_k ) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If inputs \(\bar b\) and \(\bar c\) are the mantissas of BFP vectors \( \bar{b} \cdot 2^{b\_exp} \) and \(\bar{c} \cdot 2^{c\_exp}\), and input \(\bar a\) is the accumulator BFP vector \(\bar{a} \cdot 2^{a\_exp}\), then the output values of \(\bar a\) have the exponent \(2^{a\_exp + acc\_shr}\).

      For accumulation to make sense mathematically, \(bc\_sat\) must be chosen such that \( a\_exp + acc\_shr = b\_exp + c\_exp + bc\_sat \).

      The function vect_complex_s16_macc_prepare() can be used to obtain values for \(a\_exp\), \(acc\_shr\) and \(bc\_sat\) based on the input exponents \(a\_exp\), \(b\_exp\) and \(c\_exp\) and the input headrooms \(a\_hr\), \(b\_hr\) and \(c\_hr\).

    See also

    vect_s32_macc_prepare

    Parameters:

      - acc – [inout] Accumulator \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] Number of elements in vectors \(\bar a\), \(\bar b\) and \(\bar c\)

      - acc_shr – [in] Signed arithmetic right-shift applied to accumulator elements.

      - b_shr – [in] Signed arithmetic right-shift applied to elements of \(\bar b\)

      - c_shr – [in] Signed arithmetic right-shift applied to elements of \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `acc`, `b` or `c` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of the output vector \(\bar a\)

  headroom_t vect_s32_nmacc(int32_t acc[], const int32_t b[], const int32_t c[], const unsigned length, const right_shift_t acc_shr, const right_shift_t b_shr, const right_shift_t c_shr)

    Multiply one 32-bit vector element-wise by another, and subtract the result from an accumulator.

    `acc[]` represents the 32-bit accumulator mantissa vector \(\bar a\). Each \(a_k\) is `acc[k]`.

    `b[]` and `c[]` represent the 32-bit input mantissa vectors \(\bar b\) and \(\bar c\), where each \(b_k\) is `b[k]` and each \(c_k\) is `c[k]`.

    Each of the input vectors must begin at a word-aligned address.

    `length` is the number of elements in each of the vectors.

    `acc_shr`, `b_shr` and `c_shr` are the signed arithmetic right-shifts applied to input elements \(a_k\), \(b_k\) and \(c_k\).

    Operation Performed

      \[\begin{split}\begin{aligned} & \tilde{b}_k \leftarrow sat_{32}( b_k \cdot 2^{-b\_shr} ) \\ & \tilde{c}_k \leftarrow sat_{32}( c_k \cdot 2^{-c\_shr} ) \\ & \tilde{a}_k \leftarrow sat_{32}( a_k \cdot 2^{-acc\_shr} ) \\ & v_k \leftarrow round( sat_{32}( \tilde{b}_k \cdot \tilde{c}_k \cdot 2^{-30} ) ) \\ & a_k \leftarrow sat_{32}( \tilde{a}_k - v_k ) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If inputs \(\bar b\) and \(\bar c\) are the mantissas of BFP vectors \( \bar{b} \cdot 2^{b\_exp} \) and \(\bar{c} \cdot 2^{c\_exp}\), and input \(\bar a\) is the accumulator BFP vector \(\bar{a} \cdot 2^{a\_exp}\), then the output values of \(\bar a\) have the exponent \(2^{a\_exp + acc\_shr}\).

      For accumulation to make sense mathematically, \(bc\_sat\) must be chosen such that \( a\_exp + acc\_shr = b\_exp + c\_exp + bc\_sat \).

      The function vect_complex_s16_macc_prepare() can be used to obtain values for \(a\_exp\), \(acc\_shr\) and \(bc\_sat\) based on the input exponents \(a\_exp\), \(b\_exp\) and \(c\_exp\) and the input headrooms \(a\_hr\), \(b\_hr\) and \(c\_hr\).

    See also

    vect_s32_nmacc_prepare

    Parameters:

      - acc – [inout] Accumulator \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] Number of elements in vectors \(\bar a\), \(\bar b\) and \(\bar c\)

      - acc_shr – [in] Signed arithmetic right-shift applied to accumulator elements.

      - b_shr – [in] Signed arithmetic right-shift applied to elements of \(\bar b\)

      - c_shr – [in] Signed arithmetic right-shift applied to elements of \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `acc`, `b` or `c` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of the output vector \(\bar a\)

  headroom_t vect_s32_rect(int32_t a[], const int32_t b[], const unsigned length)

    Rectify the elements of a 32-bit vector.

    `a[]` and `b[]` represent the 32-bit mantissa vectors \(\bar a\) and \(\bar b\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`.

    `length` is the number of elements in each of the vectors.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow \begin{cases} b_k & b_k > 0 \\ 0 & b_k \leq 0 \end{cases} \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the output vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp\).

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of the output vector \(\bar a\)

  headroom_t vect_s32_scale(int32_t a[], const int32_t b[], const unsigned length, const int32_t c, const right_shift_t b_shr, const right_shift_t c_shr)

    Multiply a 32-bit vector by a scalar.

    `a[]` and `b[]`represent the 32-bit mantissa vectors \(\bar a\) and \(\bar b\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`.

    `length` is the number of elements in each of the vectors.

    `c` is the 32-bit scalar \(c\) by which each element of \(\bar b\) is multiplied.

    `b_shr` and `c_shr` are the signed arithmetic right-shifts applied to each element of \(\bar b\) and to \(c\).

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' \leftarrow sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & a_k \leftarrow sat_{32}(round(c \cdot b_k' \cdot 2^{-30})) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of a BFP vector \( \bar{b} \cdot 2^{b\_exp} \) and \(c\) is the mantissa of floating-point value \(c \cdot 2^{c\_exp}\), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp + c\_exp + b\_shr + c\_shr + 30\).

      The function vect_s32_scale_prepare() can be used to obtain values for \(a\_exp\), \(b\_shr\) and \(c\_shr\) based on the input exponents \(b\_exp\) and \(c\_exp\) and the input headrooms \(b\_hr\) and \(c\_hr\).

    See also

    vect_s32_scale_prepare

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

      - c – [in] Scalar to be multiplied by elements of \(\bar b\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

      - c_shr – [in] Right-shift applied to \(c\)

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of output vector \(\bar a\)

  void vect_s32_set(int32_t a[], const int32_t b, const unsigned length)

    Set all elements of a 32-bit vector to the specified value.

    `a[]` represents the 32-bit output vector \(\bar a\). `a[]` must begin at a word-aligned address.

    `b` is the new value to set each element of \(\bar a\) to.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow b \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(b\) is the mantissa of floating-point value \(b \cdot 2^{b\_exp}\), then the output vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp\).

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] New value for the elements of \(\bar a\)

      - length – [in] Number of elements in \(\bar a\)

    Throws ET_LOAD_STORE:

      Raised if `a` is not word-aligned (See Note: Vector Alignment)

  headroom_t vect_s32_shl(int32_t a[], const int32_t b[], const unsigned length, const left_shift_t b_shl)

    Left-shift the elements of a 32-bit vector by a specified number of bits.

    `a[]` and `b[]` represent the 32-bit vectors \(\bar a\) and \(\bar b\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`.

    `length` is the number of elements in vectors \(\bar a\) and \(\bar b\).

    `b_shl` is the signed arithmetic left-shift applied to each element of \(\bar b\).

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow sat_{32}(\lfloor b_k \cdot 2^{b\_shl} \rfloor) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of a BFP vector \( \bar{b} \cdot 2^{b\_exp} \), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(\bar{a} = \bar{b} \cdot 2^{b\_shl}\) and \(a\_exp = b\_exp\).

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

      - b_shl – [in] Arithmetic left-shift applied to elements of \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of output vector \(\bar a\)

  headroom_t vect_s32_shr(int32_t a[], const int32_t b[], const unsigned length, const right_shift_t b_shr)

    Right-shift the elements of a 32-bit vector by a specified number of bits.

    `a[]` and `b[]` represent the 32-bit vectors \(\bar a\) and \(\bar b\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`.

    `length` is the number of elements in vectors \(\bar a\) and \(\bar b\).

    `b_shr` is the signed arithmetic right-shift applied to each element of \(\bar b\).

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of a BFP vector \( \bar{b} \cdot 2^{b\_exp} \), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(\bar{a} = \bar{b} \cdot 2^{-b\_shr}\) and \(a\_exp = b\_exp\).

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

      - b_shr – [in] Arithmetic right-shift applied to elements of \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of output vector \(\bar a\)

  headroom_t vect_s32_sqrt(int32_t a[], const int32_t b[], const unsigned length, const right_shift_t b_shr, const unsigned depth)

    Compute the square root of elements of a 32-bit vector.

    `a[]` and `b[]` represent the 32-bit mantissa vectors \(\bar a\) and \(\bar b\) respectively. Each vector must begin at a word-aligned address. This operation can be performed safely in-place on `b[]`.

    `length` is the number of elements in each of the vectors.

    `b_shr` is the signed arithmetic right-shift applied to elements of \(\bar b\).

    `depth` is the number of most significant bits to calculate of each \(a_k\). For example, a `depth` value of 8 will only compute the 8 most significant byte of the result, with the remaining 3 bytes as 0. The maximum value for this parameter is `VECT_SQRT_S32_MAX_DEPTH` (31). The time cost of this operation is approximately proportional to the number of bits computed.

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' \leftarrow sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & a_k \leftarrow \sqrt{ b_k' } \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \\ & \qquad\text{ where } sqrt() \text{ computes the first } depth \text{ bits of the square root.} \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = (b\_exp + b\_shr - 30)/2\).

      Note that because exponents must be integers, that means \(b\_exp + b\_shr\) must be even.

      The function vect_s32_sqrt_prepare() can be used to obtain values for \(a\_exp\) and \(b\_shr\) based on the input exponent \(b\_exp\) and headroom \(b\_hr\).

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

      - depth – [in] Number of bits of each output value to compute

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of output vector \(\bar a\)

  headroom_t vect_s32_sub(int32_t a[], const int32_t b[], const int32_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)

    Subtract one 32-bit vector from another.

    `a[]`, `b[]` and `c[]` represent the 32-bit mantissa vectors \(\bar a\), \(\bar b\) and \(\bar c\) respectively. Each must begin at a word-aligned address. This operation can be performed safely in-place on `b[]` or `c[]`.

    `length` is the number of elements in each of the vectors.

    `b_shr` and `c_shr` are the signed arithmetic right-shifts applied to each element of \(\bar b\) and \(\bar c\) respectively.

    Operation Performed

      \[\begin{split}\begin{aligned} & b_k' = sat_{32}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & c_k' = sat_{32}(\lfloor c_k \cdot 2^{-c\_shr} \rfloor) \\ & a_k \leftarrow sat_{32}\!\left( b_k' - c_k' \right) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) and \(\bar c\) are the mantissas of BFP vectors \( \bar{b} \cdot 2^{b\_exp} \) and \(\bar{c} \cdot 2^{c\_exp}\), then the resulting vector \(\bar a\) are the mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\).

      In this case, \(b\_shr\) and \(c\_shr\) must be chosen so that \(a\_exp = b\_exp + b\_shr = c\_exp + c\_shr\). Adding or subtracting mantissas only makes sense if they are associated with the same exponent.

      The function vect_s32_sub_prepare() can be used to obtain values for \(a\_exp\), \(b\_shr\) and * \(c\_shr\) based on the input exponents \(b\_exp\) and \(c\_exp\) and the input headrooms \(b\_hr\) and \(c\_hr\).

    See also

    vect_s32_sub_prepare

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] Number of elements in vectors \(\bar a\), \(\bar b\) and \(\bar c\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

      - c_shr – [in] Right-shift appled to \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `a`, `b` or `c` is not word-aligned (See Note: Vector Alignment)

    Returns:

      Headroom of output vector \(\bar a\)

  int64_t vect_s32_sum(const int32_t b[], const unsigned length)

    Sum the elements of a 32-bit vector.

    `b[]` represents the 32-bit mantissa vector \(\bar b\). `b[]` must begin at a word-aligned address.

    `length` is the number of elements in \(\bar b\).

    Operation Performed

      \[\begin{aligned} a \leftarrow \sum_{k=0}^{length-1} b_k \end{aligned}\]

    Block Floating-Point

      If \(\bar b\) are the mantissas of BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the returned value \(a\) is the 64-bit mantissa of floating-point value \(a \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp\).

    Additional Details

      Internally, each element accumulates into one of eight 40-bit accumulators (which are all used simultaneously) which apply symmetric 40-bit saturation logic (with bounds \(\approx 2^{39}\)) with each value added. The saturating arithmetic employed is not associative and no indication is given if saturation occurs at an intermediate step. To avoid the possibility of saturation errors, `length` should be no greater than \(2^{11+b\_hr}\), where \(b\_hr\) is the headroom of \(\bar b\).

      If the caller’s mantissa vector is longer than that, the full result can be found by calling this function multiple times for partial results on sub-sequences of the input, and adding the results in user code.

      In many situations the caller may have a priori knowledge that saturation is impossible (or very nearly so), in which case this guideline may be disregarded. However, such situations are application-specific and are well beyond the scope of this documentation, and as such are left to the user’s discretion.

    Parameters:

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vector \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` is not word-aligned (See Note: Vector Alignment)

    Returns:

      64-bit mantissa of the sum, \(a\).

  void vect_s32_zip(complex_s32_t a[], const int32_t b[], const int32_t c[], const unsigned length, const right_shift_t b_shr, const right_shift_t c_shr)

    Interleave the elements of two vectors into a single vector.

    Elements of 32-bit input vectors \(\bar b\) and \(\bar c\) are interleaved into 32-bit output vector \(\bar a\). Each element of \(\bar b\) has a right-shift of \(b\_shr\) applied, and each element of \(\bar c\) has a right-shift of \(c\_shr\) applied.

    Alternatively (and equivalently), this function can be conceived of as taking two real vectors \(\bar b\) and \(\bar c\) and forming a new complex vector \(\bar a\) where \(\bar{a} = \bar{b} + i\cdot\bar{c}\).

    If vectors \(\bar b\) and \(\bar c\) each have \(N\) elements, then the resulting \(\bar a\) will have either \(2N\) `int32_t` elements or (equivalently) \(N\) `complex_s32_t` elements (and must have space for such).

    Each element \(b_k\) of \(\bar b\) will end up as end up as element \(a_{2k}\) of \(\bar a\) (with the bit-shift applied). Each element \(c_k\) will end up as element \(a_{2k+1}\) of \(\bar a\).

    `a[]` is the output vector \(\bar a\).

    `b[]` and `c[]` are the input vectors \(\bar b\) and \(\bar c\) respectively.

    `a`, `b` and `c` must each begin at a double word-aligned (8 byte) address. (see `DWORD_ALIGNED`).

    `length` is the number \(N\) of `int32_t` elements in \(\bar b\) and \(\bar c\).

    `b_shr` is the signed arithmetic right-shift applied to elements of \(\bar b\).

    `c_shr` is the signed arithmetic right-shift applied to elements of \(\bar c\).

    Operation Performed

      \[\begin{split}\begin{aligned} & Re{a_{k}} \leftarrow sat_{32}( b_k \cdot 2^{-b\_shr} \\ & Im{a_{k}} \leftarrow sat_{32}( c_k \cdot 2^{-c\_shr} \\ & \qquad\text{ for }k\in 0\ ...\ (N-1) \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] Number of elements \(N\) in vectors \(\bar a\), \(\bar b\) and \(\bar c\)

      - b_shr – [in] Signed arithmetic right-shift applied to elements of \(\bar b\)

      - c_shr – [in] Signed arithmetic right-shift applied to elements of \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `a`, `b` or `c` is not double word-aligned (See Note: Vector Alignment)

  void vect_s32_unzip(int32_t a[], int32_t b[], const complex_s32_t c[], const unsigned length)

    Deinterleave the real and imaginary parts of a complex 32-bit vector into two separate vectors.

    Complex 32-bit input vector \(\bar c\) has its real and imaginary parts (which correspond to the even and odd-indexed elements, if reinterpreted as an `int32_t` array) split apart to create real 32-bit output vectors \(\bar a\) and \(\bar b\), such that \(\bar{a} = Re{\bar{c}}\) and \(\bar{b} = Im{\bar{c}}\).

    `a[]` and `b[]` are the real output vectors \(\bar a\) and \(\bar b\) which receive the real and imaginary parts respectively of \(\bar c\). `a` and `b` must each begin at a word-aligned address.

    `c[]` is the complex input vector \(\bar c\). `c` must begin at a double word-aligned address.

    `length` is the number \(N\) of `int32_t` elements in \(\bar a\) and \(\bar b\) and the number of `complex_s32_t` in \(\bar c\).

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k = Re\{c_k\} \\ & b_k = Im\{c_k\} \\ & \qquad\text{ for }k\in 0\ ...\ (N-1) \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [out] Output vector \(\bar b\)

      - c – [in] Input vector \(\bar c\)

      - length – [in] The number of elements \(N\) in vectors \(\bar a\), \(\bar b\) and \(\bar c\)

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)

    Throws ET_LOAD_STORE:

      Raised if `c` is not double word-aligned (See Note: Vector Alignment)

  headroom_t vect_s32_convolve_valid(int32_t y[], const int32_t x[], const int32_t b_q30[], const unsigned x_length, const unsigned b_length)

    Convolve a 32-bit vector with a short kernel.

    32-bit input vector \(\bar x\) is convolved with a short fixed-point kernel \(\bar b\) to produce 32-bit output vector \(\bar y\). In other words, this function applies the \(K\)th-order FIR filter with coefficients given by \(\bar b\) to the input signal \(\bar x\). The convolution is “valid” in the sense that no output elements are emitted where the filter taps extend beyond the bounds of the input vector, resulting in an output vector \(\bar y\) with fewer elements.

    The maximum filter order \(K\) supported by this function is \(7\).

    `y[]` is the output vector \(\bar y\). If input \(\bar x\) has \(N\) elements, and the filter has \(K\) elements, then \(\bar y\) has \(N-2P\) elements, where \(P = \lfloor K / 2 \rfloor\).

    `x[]` is the input vector \(\bar x\) with length \(N\).

    `b_q30[]` is the vector \(\bar b\) of filter coefficients. The coefficients of \(\bar b\) are encoded in a Q2.30 fixed-point format. The effective value of the \(i\)th coefficient is then \(b_i \cdot 2^{-30}\).

    `x_length` is the length \(N\) of \(\bar x\) in elements.

    `b_length` is the length \(K\) of \(\bar b\) in elements (i.e. the number of filter taps). `b_length` must be one of \( \{ 1, 3, 5, 7 \} \).

    Operation Performed

      \[\begin{split}\begin{aligned} & y_k \leftarrow \sum_{l=0}^{K-1} (x_{(k+l)} \cdot b_l \cdot 2^{-30} ) \\ & \qquad\text{ for }k\in 0\ ...\ (N-2P) \\ & \qquad\text{ where }P = \lfloor K/2 \rfloor \end{aligned}\end{split}\]

    Additional Details

      To avoid the possibility of saturating any output elements, \(\bar b\) may be constrained such that \( \sum_{i=0}^{K-1} \left|b_i\right| \leq 2^{30} \).

      This operation can be applied safely in-place on `x[]`.

    Parameters:

      - y – [out] Output vector \(\bar y\)

      - x – [in] Input vector \(\bar x\)

      - b_q30 – [in] Filter coefficient vector \(\bar b\)

      - x_length – [in] The number of elements \(N\) in vector \(\bar x\)

      - b_length – [in] The number of elements \(K\) in \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `x` or `y` or `b_q30` is not word-aligned (See Note: Vector Alignment)

  headroom_t vect_s32_convolve_same(int32_t y[], const int32_t x[], const int32_t b_q30[], const unsigned x_length, const unsigned b_length, const pad_mode_e padding_mode)

    Convolve a 32-bit vector with a short kernel.

    32-bit input vector \(\bar x\) is convolved with a short fixed-point kernel \(\bar b\) to produce 32-bit output vector \(\bar y\). In other words, this function applies the \(K\)th-order FIR filter with coefficients given by \(\bar b\) to the input signal \(\bar x\). The convolution mode is “same” in that the input vector is effectively padded such that the input and output vectors are the same length. The padding behavior is one of those given by pad_mode_e.

    The maximum filter order \(K\) supported by this function is \(7\).

    `y[]` and `x[]` are the output and input vectors \(\bar y\) and \(\bar x\) respectively.

    `b_q30[]` is the vector \(\bar b\) of filter coefficients. The coefficients of \(\bar b\) are encoded in a Q2.30 fixed-point format. The effective value of the \(i\)th coefficient is then \(b_i \cdot 2^{-30}\).

    `x_length` is the length \(N\) of \(\bar x\) and \(\bar y\) in elements.

    `b_length` is the length \(K\) of \(\bar b\) in elements (i.e. the number of filter taps). `b_length` must be one of \( \{ 1, 3, 5, 7 \} \).

    `padding_mode` is one of the values from the pad_mode_e enumeration. The padding mode indicates the filter input values for filter taps that have extended beyond the bounds of the input vector \(\bar x\). See pad_mode_e for a list of supported padding modes and associated behaviors.

    Operation Performed

      \[\begin{split}\begin{aligned} & \tilde{x}_i = \begin{cases} \text{determined by padding mode} & i < 0 \\ \text{determined by padding mode} & i \ge N \\ x_i & otherwise \end{cases} \\ & y_k \leftarrow \sum_{l=0}^{K-1} (\tilde{x}_{(k+l-P)} \cdot b_l \cdot 2^{-30} ) \\ & \qquad\text{ for }k\in 0\ ...\ (N-2P) \\ & \qquad\text{ where }P = \lfloor K/2 \rfloor \end{aligned}\end{split}\]

    Additional Details

      To avoid the possibility of saturating any output elements, \(\bar b\) may be constrained such that \( \sum_{i=0}^{K-1} \left|b_i\right| \leq 2^{30} \).

    Note

    Unlike vect_s32_convolve_valid(), this operation cannot be performed safely in-place on `x[]`

    Parameters:

      - y – [out] Output vector \(\bar y\)

      - x – [in] Input vector \(\bar x\)

      - b_q30 – [in] Filter coefficient vector \(\bar b\)

      - x_length – [in] The number of elements \(N\) in vector \(\bar x\)

      - b_length – [in] The number of elements \(K\) in \(\bar b\)

      - padding_mode – [in] The padding mode to be applied at signal boundaries

    Throws ET_LOAD_STORE:

      Raised if `x` or `y` or `b_q30` is not word-aligned (See Note: Vector Alignment)

  void vect_s32_merge_accs(int32_t a[], const split_acc_s32_t b[], const unsigned length)

    Merge a vector of split 32-bit accumulators into a vector of int32_t’s.

    Convert a vector of split_acc_s32_t into a vector of `int32_t`. This is useful when a function (e.g. `mat_mul_s8_x_s8_yield_s32`) outputs a vector of accumulators in the XS3 VPU’s native split 32-bit format, which has the upper half of each accumulator in the first 32 bytes and the lower half in the following 32 bytes.

    This function is most efficient (in terms of cycles/accumulator) when `length` is a multiple of

    1. In any case, `length` will be rounded up such that a multiple of 16 accumulators will always be merged.

    This function can safely merge accumulators in-place.

    Parameters:

      - a – [out] Output vector of int32_t

      - b – [in] Input vector of split_acc_s32_t

      - length – [in] Number of accumulators to merge

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not word-aligned (See Note: Vector Alignment)

  void vect_s32_split_accs(split_acc_s32_t a[], const int32_t b[], const unsigned length)

    Split a vector of `int32_t`’s into a vector of `split_acc_s32_t`.

    Convert a vector of `int32_t` into a vector of split_acc_s32_t, the native format for the XS3 VPU’s 32-bit accumulators. This is useful when a function (e.g. `mat_mul_s8_x_s8_yield_s32`) takes in a vector of accumulators in that native format.

    This function is most efficient (in terms of cycles/accumulator) when `length` is a multiple of

    1. In any case, `length` will be rounded up such that a multiple of 16 accumulators will always be split.

    This function can safely split accumulators in-place.

    Parameters:

      - a – [out] Output vector of split_acc_s32_t

      - b – [in] Input vector of int32_t

      - length – [in] Number of accumulators to split

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not word-aligned (See Note: Vector Alignment)

  void vect_split_acc_s32_shr(split_acc_s32_t a[], const unsigned length, const right_shift_t shr)

    Apply a right-shift to the elements of a 32-bit split accumulator vector.

    This function may be used in conjunction with chunk_s16_accumulate() or bfp_s16_accumulate() to avoid saturation of accumulators.

    This function updates \(\bar a\) in-place.

    Parameters:

      - a – [inout] Accumulator vector \(\bar a\)

      - length – [in] Number of elements of \(\bar a\)

      - shr – [in] Number of bits to right-shift the elements of \(\bar a\)

    Throws ET_LOAD_STORE:

      Raised if `a` is not double-word-aligned (See Note: Vector Alignment)

  void vect_q30_power_series(int32_t a[], const q2_30 b[], const int32_t c[], const unsigned term_count, const unsigned length)

    Compute a power series sum on a vector of Q2.30 values.

    This function is used to compute a power series summation on a vector \(\bar b\). \(\bar b\) contains Q2.30 values. \(\bar c\) is a vector containing coefficients to be multiplied by powers of \(\bar b\), and may have any associated exponent. The output is vector \(\bar a\) and has the same exponent as \(\bar c\).

    `c[]` is an array with shape `(term_count, VPU_INT32_EPV)`, where the second axis contains the same value replicated across all `VPU_INT32_EPV` elements. That is, `c[k][i] = c[k][j]` for `i` and `j` in `0..(VPU_INT32_EPV-1)`. This is for performance reasons. (For the purpose of this explanation, \(\bar c\) is considered to be single-dimensional, without redundancy.)

    Operation Performed

      \[\begin{split}\begin{aligned} & b_{k,0} = 2^{30} \\ & b_{k,i} = round\left(\frac{b_{k,i-1}\cdot{}b_k}{2^{30}}\right) \\ & \qquad\text{for }i \in {1..(N-1)} \\ & a_k \leftarrow \sum_{i=0}^{N-1} round\left( \frac{b_{k,i}\cdot c_i}{2^{30}} \right) \\ & \qquad\text{for }k \in {0..\mathtt{length}-1} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - c – [in] Coefficient vector \(\bar c\)

      - term_count – [in] Number of power series terms, \(N\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

  void vect_float_s32_log_base(q8_24 a[], const float_s32_t b[], const q2_30 inv_ln_base_q30, const unsigned length)

    Compute the logarithm (in the specified base) of a vector of `float_s32_t`.

    This function computes the logarithm of a vector \(\bar b\) of `float_s32_t` values. The base of the computed logarithm is given by parameter `inv_ln_base_q30`. The result is written to output \(\bar a\), a vector of Q8.24 values.

    If the desired base is \(D\), then `inv_ln_base_q30`, represented here by \(R\), should be \(\mathtt{Q30}\left(\frac{1}{ln\left(D\right)}\right)\). That is: the inverse of the natural logarithm of the desired base, expressed as a Q2.30 value. Typically the desired base is known at compile time, so this value will usually be a precomputed constant.

    The resulting \(a_k\) for \(b_k \le 0\) is undefined.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow log_{D}\left(b_k\right) \\ & \qquad\text{for }k \in {0..\mathtt{length}-1} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output Q8.24 vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - inv_ln_base_q30 – [in] Coefficient \(R\) converting from natural log to desired base \(D\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not double word-aligned (See Note: Vector Alignment)

  void vect_float_s32_log(q8_24 a[], const float_s32_t b[], const unsigned length)

    Compute the natural logarithm of a vector of `float_s32_t`.

    This function computes the natural logarithm of a vector \(\bar b\) of `float_s32_t` values. The result is written to output \(\bar a\), a vector of Q8.24 values.

    The resulting \(a_k\) for \(b_k \le 0\) is undefined.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow ln\left(b_k\right) \\ & \qquad\text{for }k \in {0..\mathtt{length}-1} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output Q8.24 vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not double word-aligned (See Note: Vector Alignment)

  void vect_float_s32_log2(q8_24 a[], const float_s32_t b[], const unsigned length)

    Compute the base 2 logarithm of a vector of `float_s32_t`.

    This function computes the base 2 logarithm of a vector \(\bar b\) of `float_s32_t` values. The result is written to output \(\bar a\), a vector of Q8.24 values.

    The resulting \(a_k\) for \(b_k \le 0\) is undefined.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow log_2\left(b_k\right) \\ & \qquad\text{for }k \in {0..\mathtt{length}-1} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output Q8.24 vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not double word-aligned (See Note: Vector Alignment)

  void vect_float_s32_log10(q8_24 a[], const float_s32_t b[], const unsigned length)

    Compute the base 10 logarithm of a vector of `float_s32_t`.

    This function computes the base 10 logarithm of a vector \(\bar b\) of `float_s32_t` values. The result is written to output \(\bar a\), a vector of Q8.24 values.

    The resulting \(a_k\) for \(b_k \le 0\) is undefined.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow log_{10}\left(b_k\right) \\ & \qquad\text{for }k \in {0..\mathtt{length}-1} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output Q8.24 vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not double word-aligned (See Note: Vector Alignment)

  void vect_s32_log_base(q8_24 a[], const int32_t b[], const exponent_t b_exp, const q2_30 inv_ln_base_q30, const unsigned length)

    Compute the logarithm (in the specified base) of a block floating-point vector.

    This function computes the logarithm of the block floating-point vector \(\bar{b}\cdot 2^{b\_exp}\). The base of the computed logarithm is given by parameter `inv_ln_base_q30`. The result is written to output \(\bar a\), a vector of Q8.24 values.

    If the desired base is \(D\), then `inv_ln_base_q30`, represented here by \(R\), should be \(\mathtt{Q30}\left(\frac{1}{ln\left(D\right)}\right)\). That is: the inverse of the natural logarithm of the desired base, expressed as a Q2.30 value. Typically the desired base is known at compile time, so this value will usually be a precomputed constant.

    The resulting \(a_k\) for \(b_k \le 0\) is undefined.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow log_{D}\left(b_k\cdot 2^{b\_exp}\right) \\ & \qquad\text{for }k \in {0..\mathtt{length}-1} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output Q8.24 vector \(\bar a\)

      - b – [in] Input mantissa vector \(\bar b\)

      - b_exp – [in] Exponent associated with \(\bar b\)

      - inv_ln_base_q30 – [in] Coefficient \(R\) converting from natural log to desired base \(D\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not double word-aligned (See Note: Vector Alignment)

  void vect_s32_log(q8_24 a[], const int32_t b[], const exponent_t b_exp, const unsigned length)

    Compute the natural logarithm of a block floating-point vector.

    This function computes the natural logarithm of the block floating-point vector \(\bar{b}\cdot 2^{b\_exp}\). The result is written to output \(\bar a\), a vector of Q8.24 values.

    The resulting \(a_k\) for \(b_k \le 0\) is undefined.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow ln\left(b_k\cdot 2^{b\_exp}\right) \\ & \qquad\text{for }k \in {0..\mathtt{length}-1} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output Q8.24 vector \(\bar a\)

      - b – [in] Input mantissa vector \(\bar b\)

      - b_exp – [in] Exponent associated with \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not double word-aligned (See Note: Vector Alignment)

  void vect_s32_log2(q8_24 a[], const int32_t b[], const exponent_t b_exp, const unsigned length)

    Compute the base 2 logarithm of a block floating-point vector.

    This function computes the base 2 logarithm of the block floating-point vector \(\bar{b}\cdot 2^{b\_exp}\). The result is written to output \(\bar a\), a vector of Q8.24 values.

    The resulting \(a_k\) for \(b_k \le 0\) is undefined.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow log_2\left(b_k\cdot 2^{b\_exp}\right) \\ & \qquad\text{for }k \in {0..\mathtt{length}-1} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output Q8.24 vector \(\bar a\)

      - b – [in] Input mantissa vector \(\bar b\)

      - b_exp – [in] Exponent associated with \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not double word-aligned (See Note: Vector Alignment)

  void vect_s32_log10(q8_24 a[], const int32_t b[], const exponent_t b_exp, const unsigned length)

    Compute the base 10 logarithm of a block floating-point vector.

    This function computes the base 10 logarithm of the block floating-point vector \(\bar{b}\cdot 2^{b\_exp}\). The result is written to output \(\bar a\), a vector of Q8.24 values.

    The resulting \(a_k\) for \(b_k \le 0\) is undefined.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow log_{10}\left(b_k\cdot 2^{b\_exp}\right) \\ & \qquad\text{for }k \in {0..\mathtt{length}-1} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output Q8.24 vector \(\bar a\)

      - b – [in] Input mantissa vector \(\bar b\)

      - b_exp – [in] Exponent associated with \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `b` or `a` is not double word-aligned (See Note: Vector Alignment)

  void vect_q30_exp_small(q2_30 a[], const q2_30 b[], const unsigned length)

    Compute \(e^x\) for Q2.30 value near \(0\).

    This function computes \(e^{b_k \cdot 2^{-30}}\) for each \(b_k\) in input vector \(\bar b\). The results are placed in output vector \(\bar a\) as Q2.30 values.

    This function is meant to compute \(e^x\) for values of \(x\) in the interval \( \left[-0.5, 0.5\right] \). The error grows quickly outside of this range.

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow \frac{ e^{b_k \cdot 2^{-30}} }{ 2^{30} } \\ & \qquad\text{for }k \in {0..(\mathtt{length}-1)} \end{aligned}\end{split}\]
    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

  void vect_s32_to_vect_s16(int16_t a[], const int32_t b[], const unsigned length, const right_shift_t b_shr)

    Convert a 32-bit vector to a 16-bit vector.

    This function converts a 32-bit mantissa vector \(\bar b\) into a 16-bit mantissa vector \(\bar a\). Conceptually, the output BFP vector \(\bar{a}\cdot 2^{a\_exp}\) represents the same values as the input BFP vector \(\bar{b}\cdot 2^{b\_exp}\), only with a reduced bit-depth.

    In most cases \(b\_shr\) should be \(16 - b\_hr\), where \(b\_hr\) is the headroom of the 32-bit input mantissa vector \(\bar b\).

    The output exponent \(a\_exp\) will be given by

    \( a\_exp = b\_exp + b\_shr \)

    Parameter Details

      `a[]` represents the 16-bit output mantissa vector \(\bar a\).

      `b[]` represents the 32-bit input mantissa vector \(\bar b\).

      `a[]` and `b[]` must each begin at a word-aligned address.

      `length` is the number of elements in each of the vectors.

      `b_shr` is the signed arithmetic right-shift applied to elements of \(\bar b\).

    Operation Performed

      \[\begin{split}\begin{aligned} & a_k \leftarrow sat_{16}(\lfloor b_k \cdot 2^{-b\_shr} \rfloor) \\ & \qquad\text{ for }k\in 0\ ...\ (length-1) \end{aligned}\end{split}\]

    Block Floating-Point

      If \(\bar b\) are the 32-bit mantissas of a BFP vector \(\bar{b} \cdot 2^{b\_exp}\), then the resulting vector \(\bar a\) are the 16-bit mantissas of BFP vector \(\bar{a} \cdot 2^{a\_exp}\), where \(a\_exp = b\_exp + b\_shr\).

    See also

    vect_s16_to_vect_s32

    Parameters:

      - a – [out] Output vector \(\bar a\)

      - b – [in] Input vector \(\bar b\)

      - length – [in] Number of elements in vectors \(\bar a\) and \(\bar b\)

      - b_shr – [in] Right-shift appled to \(\bar b\)

    Throws ET_LOAD_STORE:

      Raised if `a` or `b` is not word-aligned (See Note: Vector Alignment)