AddProductC
Adds the product of the source vector and a constant to the destination vector.
The calculation formula is as follows:
.
The function interface declaration is as follows:
Operations on floating-point numbers:
HmppResult HMPPS_AddProductC_32f(const float *src, float val, float *srcDst, int32_t len);
HmppResult HMPPS_AddProductC_64f(const double *src, const double val, double *srcDst, int32_t len);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src |
Pointer to the source vector |
The value cannot be NULL. |
Input |
val |
Fixed value |
Not limited, depending on the type |
Input |
srcDst |
Pointer to the destination vector |
The value cannot be NULL. |
Input/Output |
len |
Vector length |
(0, INT_MAX] |
Input |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The value of src or srcDst is NULL. |
HMPP_STS_SIZE_ERR |
The value of len must be greater than 0. |
Example
#define BUFFER_SIZE_T 10
void AddProductCExample(void)
{
double src[BUFFER_SIZE_T] = {2.2672e-08, -2.2672e-08, -18246, 26700, -6189, 10090, -5686, -17433, -29849, -1064};
double dst[BUFFER_SIZE_T] = {3.2672e-08, -6.2672e-08, 18246, 26700, -7189, 20090, -6686, -16433, -23849, -1864};
double val = -3;
int32_t i;
HmppResult result = HMPPS_AddProductC_64f(src, val, dst, BUFFER_SIZE_T);
printf("result = %d \ndst =", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
for (i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %f ", dst[i]);
}
}
Output:
result = 0 dst = -0.000000 0.000000 72984.000000 -53400.000000 11378.000000 -10180.000000 10372.000000 35866.000000 65698.000000 1328.000000