Inv
Performs element-wise inversion for a vector.
The function interface is declared as follows:
HmppResult HMPPS_Inv_32f(const float *src, float *dst, int32_t len);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
src |
Pointer to the source vector |
The value cannot be NULL. |
Input |
dst |
Pointer to the destination vector |
The value cannot be NULL. |
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 dst is NULL. |
HMPP_STS_SIZE_ERR |
The value of len is less than or equal to 0. |
Example
#define BUFFER_SIZE_T 10
void InvExample(void)
{
float src[BUFFER_SIZE_T] = {1.64, 1.63, -1.09, 0.71, -3.20, -0.43, 0.41, -4.83, 5.36, -4.40};
float dst[BUFFER_SIZE_T];
(void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T); // Initialize all elements of dst to 0.
HmppResult result = HMPPS_Inv_32f(src, dst, BUFFER_SIZE_T);
printf("result = %d\n", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
printf("dst =");
for (int i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %.2f", dst[i]);
}
printf("\n");
}
int main() {
InvExample();
return 0;
}
Output:
result = 0 dst = 0.61 0.61 -0.92 1.41 -0.31 -2.33 2.44 -0.21 0.19 -0.23
Parent topic: Basic and Common Calculations