中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

Sub

向量与向量相减。

函数接口声明如下:

  • 整型数的操作:

    HmppResult HMPPS_Sub_16s(const int16_t *src1, const int16_t *src2, int16_t *dst, int32_t len);

  • 浮点数的操作:

    HmppResult HMPPS_Sub_32f(const float *src1, const float *src2, float *dst, int32_t len);

    HmppResult HMPPS_Sub_64f(const double *src1, const double *src2, double *dst, int32_t len);

    HmppResult HMPPS_Sub_32fc(const Hmpp32fc *src1, const Hmpp32fc *src2, Hmpp32fc *dst, int32_t len);

    HmppResult HMPPS_Sub_16s32f(const int16_t *src1, const int16_t *src2, float *dst, int32_t len);

    HmppResult HMPPS_Sub_64fc(const Hmpp64fc *src1, const Hmpp64fc *src2, Hmpp64fc *dst, int32_t len);

  • 有缩放的整型数操作:

    HmppResult HMPPS_Sub_16s_S(const int16_t *src1, const int16_t *src2, int16_t *dst, int32_t len, double scale);

    HmppResult HMPPS_Sub_32s_S(const int32_t *src1, const int32_t *src2, int32_t *dst, int32_t len, double scale);

    HmppResult HMPPS_Sub_8u_S(const uint8_t *src1, const uint8_t *src2, uint8_t *dst, int32_t len, double scale);

    HmppResult HMPPS_Sub_16u_S(const uint16_t *src1, const uint16_t *src2, uint16_t *dst, int32_t len, double scale);

    HmppResult HMPPS_Sub_16sc_S(const Hmpp16sc *src1, const Hmpp16sc *src2, Hmpp16sc *dst, int32_t len, double scale);

    HmppResult HMPPS_Sub_32sc_S(const Hmpp32sc *src1, const Hmpp32sc *src2, Hmpp32sc *dst, int32_t len, int32_t scale);

  • 整型数的原址操作:

    HmppResult HMPPS_Sub_16s_I(const int16_t *src, int16_t *srcDst, int32_t len);

  • 浮点数的原址操作:

    HmppResult HMPPS_Sub_32f_I(const float *src, float *srcDst, int32_t len);

    HmppResult HMPPS_Sub_64f_I(const double *src, double *srcDst, int32_t len);

    HmppResult HMPPS_Sub_32fc_I(const Hmpp32fc *src, Hmpp32fc *srcDst, int32_t len);

    HmppResult HMPPS_Sub_64fc_I(const Hmpp64fc *src, Hmpp64fc *srcDst, int32_t len);

  • 有缩放的整型数原址操作:

    HmppResult HMPPS_Sub_16s_IS(const int16_t *src1, int16_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_Sub_32s_IS(const int32_t *src1, int32_t *srcDst, int32_t len, doublescale);

    HmppResult HMPPS_Sub_8u_IS(const uint8_t *src, uint8_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_Sub_16u_IS(const uint16_t *src, uint16_t *srcDst, int32_t len, doublescale);

    HmppResult HMPPS_Sub_16sc_IS(const Hmpp16sc *src, Hmpp16sc *srcDst, int32_t len, double scale);

    HmppResult HMPPS_Sub_32sc_IS(const Hmpp32sc *src, Hmpp32sc *srcDst, int32_t len, double scale);

参数

参数名

描述

取值范围

输入/输出

src1

指向减数的指针。

非空

输入

src2

指向被减数的指针。

非空

输入

dst

指向目的向量的指针。

非空

输出

src

指向原址操作中减数的指针。

非空

输入

srcDst

指向原址操作向量中被减数的指针。

非空

输入/输出

len

向量长度。

(0,INT_MAX]

输入

scale

缩放因数。

(0,INF)且输入为2^n

输入

返回值

  • 成功:返回HMPP_STS_NO_ERR
  • 失败:返回错误码。

错误码

错误码

描述

HMPP_STS_NULL_PTR_ERR

src1、src2、dst、src、srcDst这几个入参中存在空指针。

HMPP_STS_SIZE_ERR

len小于或等于0。

HMPP_STS_SCALE_ERR

scale不在(0,INF)范围内或输入为nan。

示例

#define BUFFER_SIZE_T 10
void SubExample(void)
{
    float src1[BUFFER_SIZE_T] = { -1.40, 10.85, 7.26, 8.98, 0.26, 6.47, 10.42, 8.64, 3.22, 10.90};    
    float src2[BUFFER_SIZE_T] = { 10.11, 4.27, 0.53, 4.00, 4.73, -1.23, 6.44, 8.88, 0.78, 5.33};    
    float dst[BUFFER_SIZE_T];
    (void)HMPPS_Zero_32f(dst, BUFFER_SIZE_T);
    HmppResult result = HMPPS_Sub_32f(src1, src2, 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");
}

运行结果:

sub: result = 0.
dst = 11.51    -6.58    -6.73    -4.98    4.47    -7.70    -3.98    0.24    -2.44    -5.57