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

MulC

向量与常量相乘。

函数接口声明如下:

  1. 有缩放的浮点数的操作:

    HmppResult HMPPS_MulC_32f(const float *src, float val, float *dst, int32_t len);

    HmppResult HMPPS_MulC_64f(const double *src, double val, double*dst, int32_t len);

    HmppResult HMPPS_MulC_32fc(const Hmpp32fc *src, Hmpp32fc val, Hmpp32fc *dst, int32_t len);

    HmppResult HMPPS_MulC_64fc(const Hmpp64fc *src, Hmpp64fc val, Hmpp64fc *dst, int32_t len);

    HmppResult HMPPS_MulC_Low_32f16s(const float *src, float val, int16_t *dst, int32_t len);

  1. 有缩放的整型数的操作:

    HmppResult HMPPS_MulC_8u_S(const uint8_t *src, uint8_t val, uint8_t *dst, int32_t len, double scale);

    HmppResult HMPPS_MulC_16u_S(const uint16_t *src, uint16_t val, uint16_t *dst, int32_t len, double scale);

    HmppResult HMPPS_MulC_16s_S(const int16_t *src, int16_t val, int16_t *dst, int32_t len, double scale);

    HmppResult HMPPS_MulC_32s_S(const int32_t *src, int32_t val, int32_t *dst, int32_t len, double scale);

    HmppResult HMPPS_MulC_32f16s_S(const float *src, float val, int16_t *dst, int32_t len, double scale);

    HmppResult HMPPS_MulC_16sc_S(const Hmpp16sc *src, Hmpp16sc val, Hmpp16sc *dst, int32_t len, double scale);

    HmppResult HMPPS_MulC_32sc_S(const Hmpp32sc *src, Hmpp32sc val, Hmpp32sc *dst, int32_t len, double scale);

  1. 整型数的原地操作:

    HmppResult HMPPS_MulC_8u_IS(uint8_t val, uint8_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_MulC_16u_IS(uint16_t val, uint16_t *srcDst, int32_t len, double scale);

  1. 浮点数的原地操作:

    HmppResult HMPPS_MulC_16s_I(int16_t val, int16_t *srcDst, int32_t len);

    HmppResult HMPPS_MulC_32f_I(float val, float *srcDst, int32_t len);

    HmppResult HMPPS_MulC_64f_I(double val, double *srcDst, int32_t len);

    HmppResult HMPPS_MulC_32fc_I(Hmpp32fc val, Hmpp32fc *srcDst, int32_t len);

    HmppResult HMPPS_MulC_64fc_I(Hmpp64fc val, Hmpp64fc *srcDst, int32_t len);

  1. 有缩放的整型数原地操作:

    HmppResult HMPPS_MulC_16s_IS(int16_t val, int16_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_MulC_32s_IS(int32_t val, int32_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_MulC_64s_IS(int64_t val, int64_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_MulC_64f64s_IS(double val, int64_t *srcDst, int32_t len, double scale);

    HmppResult HMPPS_MulC_16sc_IS(Hmpp16sc val, Hmpp16sc *srcDst, int32_t len, double scale);

    HmppResult HMPPS_MulC_32sc_IS(Hmpp32sc val, Hmpp32sc *srcDst, int32_t len, double scale);

参数

参数名

描述

取值范围

输入/输出

src

指向源向量的指针。

非空

输入

val

常量。

不限,视类型而定

输入

dst

指向目的向量的指针。

非空

输出

srcDst

指向原地操作向量的指针。

非空

输入/输出

len

向量长度。

(0, INT_MAX]

输入

scale

缩放因数。

(0, inf)且为2n

输入

返回值

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

错误码

错误码

描述

HMPP_STS_NULL_PTR_ERR

入参src、dst、srcDst中存在空指针。

HMPP_STS_SIZE_ERR

len小于或等于0。

HMPP_STS_SCALE_ERR

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

示例

#define BUFFER_SIZE_T 10

void MulCExample(void)
{
    uint8_t srcDst[BUFFER_SIZE_T] = {255, 0, 254, 0, 253, 1, 252, 2, 251, 3};
    uint8_t val = 54;
    HmppResult result = HMPPS_MulC_8u_IS(val, srcDst, BUFFER_SIZE_T, 8.0);
    printf("result = %d\n", result);
    if (result != HMPP_STS_NO_ERR) {
        return;
    }
    printf("srcDst =");
    for (int i = 0; i < BUFFER_SIZE_T; i++) {
        printf(" %d", srcDst[i]);
    }
    printf("\n");
}

运行结果:

result = 0
srcDst = 255 0 255 0 255 7 255 14 255 20