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

LIBM、MATHLIB、LIBIMF迁移到KML_MATH

可替换性

表1 LIBM、MATHLIB、LIBIMF的替换映射关系

接口名

KML接口名

数据类型

描述

sin

sin

/、f、l

正弦函数

cos

cos

/、f、l

余弦函数

sincos

sincos

/、f、l

正弦、余弦函数

tan

tan

/、f、l

正切函数

asin

asin

/、f

反正弦函数

asind

asind

/、f

反正弦函数(入参为角度)

acos

acos

/、f

反余弦函数

atan

atan

/、f

反正切函数

atan2

atan2

/、f、l

反正切函数

cosd

cosd

/、f、l

余弦函数(入参为角度)

sinh

sinh

/、f

双曲正弦函数

cosh

cosh

/、f

双曲余弦函数

tanh

tanh

/、f

双曲正切函数

asinh

asinh

/、f

反双曲正弦函数

acosh

acosh

/、f

反双曲余弦函数

atanh

atanh

/、f

反双曲正切函数

exp

exp

/、f、l

指数函数(base e)

exp2

exp2

/、f

指数函数(base 2)

log

log

/、f、l

对数函数(base e)

log2

log2

/、f

对数函数(base 2)

log10

log10

/、f

对数函数(base 10)

pow

pow

/、f、l

幂函数

sqrt

sqrt

/、f、l

平方根函数

cbrt

cbrt

/、f

立方根函数

fmod

fmod

/、f

浮点数求模

tgamma

tgamma

/、f

伽马函数

__powr8i4

powr8i4

-

80位扩展精度幂函数

高性能版本C语言迁移步骤

  1. 识别源码中是否包含开源基础数学库的头文件:<mathimf.h>/<math.h> /<mathlib.h>。
  2. 将开源头文件替换成<km.h>。
  3. 在编译选项中将-lm/-lmathlib替换为-lkm -lm。
  4. 添加环境变量,/PATH_TO_KM为安装路径。
    export LD_LIBRARY_PATH=/PATH_TO_KM:$LD_LIBRARY_PATH

高精度版本C语言迁移步骤

  1. 识别源码中是否包含开源基础数学库的头文件:<mathimf.h>/<math.h>。
  2. 将开源头文件替换成<km.h> 。
  3. 在编译选项中将-lm -fp-model=precise替换为-lkm_l9 -lm。
  4. 添加环境变量,/PATH_TO_KM为安装路径。
    export LD_LIBRARY_PATH=/PATH_TO_KM:$LD_LIBRARY_PATH

Fortran接口迁移步骤

Fortran接口迁移与高性能版本C语言迁移步骤一致。