VectorSlope

该函数的功能是创建斜率向量化数组,其公式如下:

dst[n] = offset + slope * n, n = 1, 2, 3, ...

函数接口声明如下:

参数

参数名

描述

取值范围

输入/输出

dst

斜率向量数组指针。

非空

输出

len

斜率向量数组元素个数。

(0,INT_MAX]

输入

offset

偏移值。

非空

输入

slope

斜率值。

非空

输入

返回值

错误码

错误码

描述

HMPP_STS_NULL_PTR_ERR

dst这个入参中存在空指针。

HMPP_STS_SIZE_ERR

长度错误。

示例

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");
}

运行结果:

result = 0
2 2 2 3 4 4 4 5 6 6 6 7 8 8 8