函数说明

KML_MATH是C语言实现的基本数学函数库。其中,高性能版本(libkm.so)计算结果对标开源数学库MPFR,高精度版本(libkm_l9.so)计算结果对标x86数学库。

函数类

函数名

描述

高性能版本

高精度版本

三角函数

(Trigonometric functions)

sin

正弦函数

实数单精度/双精度

实数单精度/双精度/长双精度

sind

正弦函数(入参为角度)

实数单精度/双精度

实数单精度/双精度/长双精度

sinpi

正弦函数(求入参乘以pi的正弦值)

实数单精度/双精度

cos

余弦函数

实数单精度/双精度

实数单精度/双精度/长双精度

cosd

余弦函数(入参为角度)

实数单精度/双精度

实数单精度/双精度/长双精度

cospi

余弦函数(求入参乘以pi的余弦值)

实数单精度/双精度

sincos

正弦、余弦函数

实数单精度/双精度

实数单精度/双精度/长双精度

sincosd

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

实数单精度/双精度

tan

正切函数

实数单精度/双精度

实数单精度/双精度/长双精度

tand

正切函数(入参为角度)

实数单精度/双精度

实数单精度/双精度/长双精度

tanpi

正切函数(求入参乘以pi的正切值)

实数单精度/双精度

asin

反正弦函数

实数单精度/双精度

实数单精度/双精度/长双精度

asind

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

实数单精度/双精度

实数单精度/双精度/长双精度

asinpi

反正弦函数/π

实数单精度/双精度

acos

反余弦函数

实数单精度/双精度

实数单精度/双精度/长双精度

acosd

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

实数单精度/双精度

实数单精度/双精度/长双精度

acospi

反余弦函数/π

实数单精度/双精度

atan

反正切函数

实数单精度/双精度

实数单精度/双精度/长双精度

atand

反正切函数(出参为角度)

实数单精度/双精度

atanpi

反正切函数/π

实数单精度/双精度

atan2

反正切函数

实数单精度/双精度

实数单精度/双精度/长双精度

atan2d

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

实数单精度/双精度

实数单精度/双精度/长双精度

atan2pi

反正切函数/π

实数单精度/双精度

cosd

余弦函数(入参为角度)

实数单精度/双精度

实数单精度/双精度/长双精度

cot

余切函数(入参为弧度)

实数单精度/双精度

cotd

余切函数(入参为角度)

实数单精度/双精度

超越函数

(Hyperbolic functions)

sinh

双曲正弦函数

实数单精度/双精度

实数单精度/双精度/长双精度

cosh

双曲余弦函数

实数单精度/双精度

实数单精度/双精度/长双精度

sinhcosh

双曲正弦、余弦函数

实数单精度/双精度

tanh

双曲正切函数

实数单精度/双精度

实数单精度/双精度/长双精度

asinh

反双曲正弦函数

实数单精度/双精度

acosh

反双曲余弦函数

实数单精度/双精度

atanh

反双曲正切函数

实数单精度/双精度

实数长双精度

指数和对数函数

(Exponential and logarithmic functions)

exp

指数函数(base e)

实数单精度/双精度

实数单精度/双精度/长双精度

exp2

指数函数(base 2)

实数单精度/双精度

实数单精度/双精度/长双精度

exp10

指数函数 (base 10)

实数单精度/双精度

实数单精度/双精度/长双精度

expm1

指数函数(e^x - 1)

实数单精度/双精度

frexp

将x转换为归一化[1/2, 1)的有符号数乘以2的积分幂

实数单精度/双精度/长双精度

ldexp

指数函数(x * 2^exp)

实数单精度/双精度/长双精度

log

对数函数(base e)

实数单精度/双精度

实数单精度/双精度/长双精度

log2

对数函数(base 2)

实数单精度/双精度

实数单精度/双精度/长双精度

log10

对数函数(base 10)

实数单精度/双精度

实数单精度/双精度/长双精度

log1p

对数函数 (ln(1+x))

实数单精度/双精度

logb

对数函数,求x的指数

实数单精度/双精度

ilogb

计算x的指数,返回整型结果

实数单精度/双精度

scalb

求 x*(2^y)

实数单精度/双精度

hypot

求 (x^2 + y^2) 的开方

实数单精度/双精度

实数单精度/双精度/长双精度

幂和根函数(Power and root function)

pow

幂函数

实数单精度/双精度

实数单精度/双精度/长双精度

powr?i?

幂函数

实数单精度/双精度/长双精度

powi?i?

幂函数

实数整型/长整型

pow2o3

幂函数 (幂值2/3)

实数单精度/双精度

pow3o2

幂函数 (幂值3/2)

实数单精度/双精度

powr

幂函数(x>0)

实数单精度/双精度

sqrt

平方根函数

实数单精度/双精度/长双精度

实数单精度/双精度/长双精度

invsqrt

求平方根的倒数(

实数单精度/双精度/长双精度

cbrt

立方根函数

实数单精度/双精度

实数单精度/双精度/长双精度

杂项函数(Miscellaneous Functions)

fabs

计算浮点数绝对值

实数单精度/双精度

fdim

如果x<=y,则fdim函数返回零值;否则返回x-y的值

实数单精度/双精度

fmax

返回入参的最大值

实数单精度/双精度

fmaxmag

返回绝对值相对较大的入参,否则行为类似于fmax(x,y)

实数单精度/双精度

fmin

返回入参的最小值

实数单精度/双精度

fminmag

返回绝对值相对较小的入参,否则行为类似于fmin(x,y)

实数单精度/双精度

nextafter

y方向上,以指定格式返回x之后的下一个可表示值

实数单精度/双精度

nexttoward

返回x在y方向的下个浮点数

实数单精度/双精度

significand

求x的有效数字

实数单精度/双精度

特殊函数(Special Function)

annuity

求年金现值系数(

实数单精度/双精度

compound

计算复利终值系数

实数单精度/双精度

erf

误差函数

实数单精度/双精度

实数单精度/双精度/长双精度

erfc

互补误差函数

实数单精度/双精度

erfcx

互补误差函数与的乘积

实数单精度/双精度

erfinv

逆误差函数

实数单精度/双精度

gamma

计算x的伽马值绝对值的自然对数

实数单精度/双精度

gamma_r

计算x的伽马值绝对值的自然对数,返回伽马值的符号

实数双精度

tgamma

计算x的伽马值

实数单精度/双精度

舍入函数(Nearest Integer Functions)

ceil

向上舍入

实数单精度/双精度

实数单精度/双精度/长双精度

floor

向下舍入

实数单精度/双精度

实数单精度/双精度/长双精度

llrint

基于当前舍入策略四舍五入

实数单精度/双精度

llround

四舍五入

实数单精度/双精度

lrint

基于当前舍入策略四舍五入

实数单精度/双精度

实数单精度/双精度/长双精度

lround

四舍五入

实数单精度/双精度

实数单精度/双精度/长双精度

modf

获取浮点数的整数和小数部分

实数单精度/双精度/长双精度

nearbyint

四舍五入取偶

实数单精度/双精度

实数单精度/双精度

rint

基于当前舍入策略四舍五入

实数单精度/双精度

实数单精度/双精度/长双精度

round

四舍五入

实数单精度/双精度

实数单精度/双精度/长双精度

trunc

向0取整

实数单精度/双精度

实数单精度/双精度/长双精度

取余函数(Remainder Functions)

fmod

求余数(x-ny)

实数单精度/双精度

实数单精度/双精度/长双精度

remainder

求余数(IEEE标准)

实数单精度/双精度

remquo

求商和余数

实数单精度/双精度

复数函数(Complex Functions)

cabs

复数的绝对值

实数单精度/双精度

复数单精度/双精度/长双精度

cacos

复数形式的反余弦函数

复数单精度/双精度

复数单精度/双精度

cacosh

复数形式的反双曲余弦函数

复数单精度/双精度

carg

返回复数的极坐标形式的角度值

复数单精度/双精度

casin

复数形式的反正弦函数

复数单精度/双精度

复数单精度/双精度

casinh

复数形式的反双曲正弦函数

复数单精度/双精度

复数单精度/双精度

catan

复数形式的反正切函数

复数单精度/双精度

复数单精度/双精度

catanh

计算复数的双曲正切值

复数单精度/双精度

ccos

复数形式的余弦函数

复数单精度/双精度

复数单精度/双精度

ccosh

复数形式的双曲余弦函数

复数单精度/双精度

复数单精度/双精度

cdiv

复数除法

复数单精度/双精度

cexp

复数形式的指数函数(base e)

复数单精度/双精度

复数单精度/双精度/长双精度

cexp2

复数形式的指数函数(base 2)

复数单精度/双精度

复数单精度/双精度/长双精度

cexp10

复数形式的指数函数(base 10)

复数单精度/双精度

cimag

复数的虚部

复数单精度/双精度

cis

复数的形式返回x的sin/cos值

复数单精度/双精度

cisd

复数的形式返回x的sin/cos值(入参为角度)

复数单精度/双精度

clog

复数形式的对数函数(base e)

复数单精度/双精度

复数双精度/长双精度

clog2

复数形式的对数函数(base 2)

复数单精度/双精度

clog10

复数形式的对数函数(base 10)

复数单精度/双精度

复数单精度/双精度/长双精度

conj

复数z的共轭

复数单精度/双精度

cpow

复数形式的幂函数

复数单精度/双精度/长双精度

cproj

复数在黎曼球面的的投影

复数单精度/双精度

creal

复数的实部

复数单精度/双精度

csin

复数形式的正弦函数

复数单精度/双精度

复数单精度/双精度

csinh

复数形式的双曲正弦函数

复数单精度/双精度

复数单精度/双精度

csqrt

复数形式的平方根函数

复数单精度/双精度

复数单精度/双精度/长双精度

ctan

复数形式的正切函数

复数单精度/双精度

复数单精度/双精度

ctanh

复数形式的双曲正切函数

复数单精度/双精度