Mul
Multiplies a vector by another vector.
The function interface declaration is as follows:
- Operations on integers without scaling:
HmppResult HMPPS_Mul_8u16u(const uint8_t *src1, const uint8_t *src2, uint16_t *dst, int32_t len);
HmppResult HMPPS_Mul_16s(const int16_t *src1, const int16_t *src2, int16_t *dst, int32_t len);
- Operations on floating-point numbers without scaling:
HmppResult HMPPS_Mul_16s32f(const int16_t *src1, const int16_t *src2, float *dst, int32_t len);
HmppResult HMPPS_Mul_32f(const float *src1, const float *src2, float *dst, int32_t len);
HmppResult HMPPS_Mul_32f32fc(const float *src1, const Hmpp32fc *src2, Hmpp32fc *dst, int32_t len);
HmppResult HMPPS_Mul_64f(const double *src1, const double *src2, double *dst, int32_t len);
HmppResult HMPPS_Mul_32fc(const Hmpp32fc *src1, const Hmpp32fc *src2, Hmpp32fc *dst, int32_t len);
HmppResult HMPPS_Mul_64fc(const Hmpp64fc *src1, const Hmpp64fc *src2, Hmpp64fc *dst, int32_t len);
- Operations on integers with scaling:
HmppResult HMPPS_Mul_8u_S(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int32_t len, double scale);
HmppResult HMPPS_Mul_16u_S(const uint16_t *src1, const uint16_t *src2, uint16_t *dst, int32_t len, double scale);
HmppResult HMPPS_Mul_16s_S(const int16_t *src1, const int16_t *src2, int16_t *dst, int32_t len, double scale);
HmppResult HMPPS_Mul_16s32s_S(const int16_t *src1, const int16_t *src2, int32_t *dst, int32_t len, double scale);
HmppResult HMPPS_Mul_32s_S(const int32_t *src1, const int32_t *src2, int32_t *dst, int32_t len, double scale);
HmppResult HMPPS_Mul_16sc_S(const Hmpp16sc *src1, const Hmpp16sc *src2, Hmpp16sc *dst, int32_t len, double scale);
HmppResult HMPPS_Mul_32sc_S(const Hmpp32sc *src1, const Hmpp32sc *src2, Hmpp32sc *dst, int32_t len, double scale);
HmppResult HMPPS_Mul_16u16s_S(const uint16_t *src1, const int16_t *src2, int16_t *dst, int32_t len, double scale);
- In-place operations on integers without scaling:
HmppResult HMPPS_Mul_16s_I(const int16_t *src, int16_t *srcDst, int32_t len);
- In-place operations on floating-point numbers without scaling:
HmppResult HMPPS_Mul_32f_I(const float *src, float *srcDst, int32_t len);
HmppResult HMPPS_Mul_64f_I(const double *src, double *srcDst, int32_t len);
HmppResult HMPPS_Mul_32fc_I(const Hmpp32fc *src, Hmpp32fc *srcDst, int32_t len);
HmppResult HMPPS_Mul_32f32fc_I(const float *src, Hmpp32fc *srcDst, int32_t len);
HmppResult HMPPS_Mul_64fc_I(const Hmpp64fc *src, Hmpp64fc *srcDst, int32_t len);
- In-place operations on integers with scaling:
HmppResult HMPPS_Mul_8u_IS(const uint8_t *src, uint8_t *srcDst, int32_t len, double scale);
HmppResult HMPPS_Mul_16u_IS(const uint16_t *src, uint16_t *srcDst, int32_t len, double scale);
HmppResult HMPPS_Mul_16s_IS(const int16_t *src, int16_t *srcDst, int32_t len, double scale);
HmppResult HMPPS_Mul_32s_IS(const int32_t *src, int32_t *srcDst, int32_t len, double scale);
HmppResult HMPPS_Mul_16sc_IS(const Hmpp16sc *src, Hmpp16sc *srcDst, int32_t len, double scale);
HmppResult HMPPS_Mul_32sc_IS(const Hmpp32sc *src, Hmpp32sc *srcDst, int32_t len, double scale);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src1 |
Pointer to the first source vector |
The value cannot be NULL. |
Input |
src2 |
Pointer to the second source vector |
The value cannot be NULL. |
Input |
src |
Pointer to the source vector |
The value cannot be NULL. |
Input |
dst |
Pointer to the destination vector |
The value cannot be NULL. |
Output |
srcDst |
Pointer to the source vector for in-place operations |
The value cannot be NULL. |
Input/Output |
len |
Vector length |
(0, INT_MAX] |
Input |
scale |
Scale factor |
scale = 2n, where n is an integer. The value is within (0, INF). |
Input |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Code
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The value of src1, src2, src, dst, or srcDst is NULL. |
HMPP_STS_SIZE_ERR |
The value of len is less than or equal to 0. |
HMPP_STS_SCALE_ERR |
The value of scale is not within the range (0, INF) or is NaN. |
Example
#define BUFFER_SIZE_T 10
void MulExample(void)
{
uint8_t src1[BUFFER_SIZE_T] = {255, 0, 254, 0, 253, 1, 252, 2, 251, 3};
uint8_t src2[BUFFER_SIZE_T] = {2, 3, 1, 2, 6, 2, 2, 12, 2, 8};
uint8_t dst[BUFFER_SIZE_T];
(void)HMPPS_Zero_8u(dst, BUFFER_SIZE_T); //Initialize all elements of dst to 0.
HmppResult result = HMPPS_Mul_8u_S(src1, src2, dst, BUFFER_SIZE_T, 8.0);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("dst =");
for (int i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %d", dst[i]);
}
printf("\n");
}
Output:
result = 0 dst = 64 0 32 0 190 0 63 3 63 3