VectorSlope
Creates a slope vector array. The formula is as follows:
dst[n] = offset + slope * n, n = 1, 2, 3, ...
The function interface declaration is as follows:
- Operations on integers:
HmppResult HMPPS_VectorSlope_8u(uint8_t *dst, int32_t len, float offset, float slope);
HmppResult HMPPS_VectorSlope_16u(uint16_t *dst, int32_t len, float offset, float slope);
HmppResult HMPPS_VectorSlope_16s(int16_t *dst, int32_t len, float offset, float slope);
HmppResult HMPPS_VectorSlope_32u(uint32_t *dst, int32_t len, double offset, double slope);
HmppResult HMPPS_VectorSlope_32s(int32_t *dst, int32_t len, double offset, double slope);
- Operations on floating-point numbers:
HmppResult HMPPS_VectorSlope_32f(float *dst, int32_t len, float offset, float slope);
HmppResult HMPPS_VectorSlope_64f(double *dst, int32_t len, double offset, double slope);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
dst |
Pointer to the slope vector array |
The value cannot be NULL. |
Output |
len |
Number of elements in the slope vector array |
(0, INT_MAX] |
Input |
offset |
Offset value |
The value cannot be NULL. |
Input |
slope |
Slope value |
The value cannot be NULL. |
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 dst is NULL. |
HMPP_STS_SIZE_ERR |
Incorrect length |
Example
void VectorSlopeExample()
{
int16_t dst[BUFFER_SIZE_T];
int32_t i;
float offset =1.5;
float slope =0.5;
HmppResult result =HMPPS_VectorSlope_16s(dst, BUFFER_SIZE_T, offset, slope);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
for (i =0; i < BUFFER_SIZE_T; i++) {
printf("%d ", dst[i]);
}
printf("\n");
}
Output:
result = 0 2 2 2 3 4 4 4 5 6 6 6 7 8 8 8