Vector Scale

void riscv_scale_f16(const float16_t *pSrc, float16_t scale, float16_t *pDst, uint32_t blockSize)
void riscv_scale_f32(const float32_t *pSrc, float32_t scale, float32_t *pDst, uint32_t blockSize)
void riscv_scale_f64(const float64_t *pSrc, float64_t scale, float64_t *pDst, uint32_t blockSize)
void riscv_scale_q15(const q15_t *pSrc, q15_t scaleFract, int8_t shift, q15_t *pDst, uint32_t blockSize)
void riscv_scale_q31(const q31_t *pSrc, q31_t scaleFract, int8_t shift, q31_t *pDst, uint32_t blockSize)
void riscv_scale_q7(const q7_t *pSrc, q7_t scaleFract, int8_t shift, q7_t *pDst, uint32_t blockSize)
group BasicScale

Multiply a vector by a scalar value. For floating-point data, the algorithm used is:

In the fixed-point Q7, Q15, and Q31 functions, scale is represented by a fractional multiplication scaleFract and an arithmetic shift shift. The shift allows the gain of the scaling operation to exceed 1.0. The algorithm used with fixed-point data is:

The overall scale factor applied to the fixed-point data is

The functions support in-place computation allowing the source and destination pointers to reference the same memory buffer.

Functions

void riscv_scale_f16(const float16_t *pSrc, float16_t scale, float16_t *pDst, uint32_t blockSize)

Multiplies a floating-point vector by a scalar.

Parameters
  • pSrc[in] points to the input vector

  • scale[in] scale factor to be applied

  • pDst[out] points to the output vector

  • blockSize[in] number of samples in each vector

Returns

none

void riscv_scale_f32(const float32_t *pSrc, float32_t scale, float32_t *pDst, uint32_t blockSize)

Multiplies a floating-point vector by a scalar.

Parameters
  • pSrc[in] points to the input vector

  • scale[in] scale factor to be applied

  • pDst[out] points to the output vector

  • blockSize[in] number of samples in each vector

Returns

none

void riscv_scale_f64(const float64_t *pSrc, float64_t scale, float64_t *pDst, uint32_t blockSize)

Multiplies a floating-point vector by a scalar.

Parameters
  • pSrc[in] points to the input vector

  • scale[in] scale factor to be applied

  • pDst[out] points to the output vector

  • blockSize[in] number of samples in each vector

Returns

none

void riscv_scale_q15(const q15_t *pSrc, q15_t scaleFract, int8_t shift, q15_t *pDst, uint32_t blockSize)

Multiplies a Q15 vector by a scalar.

Scaling and Overflow Behavior

The input data *pSrc and scaleFract are in 1.15 format. These are multiplied to yield a 2.30 intermediate result and this is shifted with saturation to 1.15 format.

Parameters
  • pSrc[in] points to the input vector

  • scaleFract[in] fractional portion of the scale value

  • shift[in] number of bits to shift the result by

  • pDst[out] points to the output vector

  • blockSize[in] number of samples in each vector

Returns

none

void riscv_scale_q31(const q31_t *pSrc, q31_t scaleFract, int8_t shift, q31_t *pDst, uint32_t blockSize)

Multiplies a Q31 vector by a scalar.

Scaling and Overflow Behavior

The input data *pSrc and scaleFract are in 1.31 format. These are multiplied to yield a 2.62 intermediate result and this is shifted with saturation to 1.31 format. There is an intermediate shift by 32 to go from the 2.62 to 1.31 format. The shift argument is applied on the 1.31 result and not to the intermediate 2.62 format.

Parameters
  • pSrc[in] points to the input vector

  • scaleFract[in] fractional portion of the scale value

  • shift[in] number of bits to shift the result by

  • pDst[out] points to the output vector

  • blockSize[in] number of samples in each vector

Returns

none

void riscv_scale_q7(const q7_t *pSrc, q7_t scaleFract, int8_t shift, q7_t *pDst, uint32_t blockSize)

Multiplies a Q7 vector by a scalar.

Scaling and Overflow Behavior

The input data *pSrc and scaleFract are in 1.7 format. These are multiplied to yield a 2.14 intermediate result and this is shifted with saturation to 1.7 format.

Parameters
  • pSrc[in] points to the input vector

  • scaleFract[in] fractional portion of the scale value

  • shift[in] number of bits to shift the result by

  • pDst[out] points to the output vector

  • blockSize[in] number of samples in each vector

Returns

none