Android NDK开发详解RenderScript之RenderScript 数学常量和函数

Android NDK开发详解RenderScript之RenderScript 数学常量和函数

概览

以下数学函数可应用于标量和矢量。应用于向量时,返回的值是应用于每个输入条目的函数的矢量。

例如:
float3 a, b;
// The following call sets
// a.x to sin(b.x),
// a.y to sin(b.y), and
// a.z to sin(b.z).
a = sin(b);

请参阅矢量数学函数,了解 distance() 和 length() 等可将输入解释为 N 维空间中的单个向量的函数。

对 32 位浮点数进行数学运算的精度受 pragmas rs_fp_relaxed 和 rs_fp_full 的影响。在 rs_fp_relaxed 下,次正常值可能会被刷新到 0,并可能向 0 舍入。相比之下,rs_fp_full 需要正确处理次正规值,即小于 1.17549435e-38f。rs_fp_rull 还需要四舍五入为最接近的整数值,并取偶数。

通过使用通用数学函数的变体,可以实现不同的精度/速度权衡。名称以

native_:可能包含精确度较低的自定义硬件实现。此外,次正规值可能会刷新为零,可以使用向零舍入,并且可能无法正确处理 NaN 和无穷大输入。
double_:可以使用 16 位浮点数执行内部计算。此外,次正规值可能会被刷新为零,并且可以向零舍入。

摘要

常量
M_1_PI	1 / pi,32 位浮点数
M_2_PI	2 / pi,32 位浮点数
M_2_SQRTPI	2 / sqrt(pi),32 位浮点格式
M_E	e,以 32 位浮点数表示
M_LN10	log_e(10),采用 32 位浮点格式
M_LN2	log_e(2),采用 32 位浮点格式
M_LOG10E	log_10(e),采用 32 位浮点格式
M_LOG2E	log_2(e),采用 32 位浮点格式
M_PI	pi,32 位浮点数
M_PI_2	pi / 2,以 32 位浮点格式表示
M_PI_4	pi / 4,32 位浮点数
M_SQRT1_2	1 / sqrt(2),32 位浮点形式
M_SQRT2	sqrt(2),为 32 位浮点
函数
绝对值	整数的绝对值
acos	反余弦
acosh	反双曲余弦
acospi	反余弦值除以 pi
asin	反正弦
asinh	反双曲正弦
asinpi	反正弦除以圆周率
atan	反正切
atan2	比率的反正切
atan2pi	比率的反正切值/圆周率
atanh	反双曲正切
atanpi	反正切除以圆周率
cbrt	立方根
ceil	不小于某个值的最小整数
clamp	将值限制在某个范围内
clz	前导 0 位的数量
文案签名	将一个数的符号复制到另一个数中
cos	余弦
cosh	双曲余弦
Cospi	数值的余弦值乘以 pi
度	将弧度转换为角度
erf	数学误差函数
erfc	数学互补误差函数
exp	将 e 提高为数值
exp10	10 取数为 10
实验 2	2 变为数字
expm1	e 设成减 1
生产商	浮点数的绝对值
fdim	两个值之间的正差
floor	不大于值的最小整数
fma	乘法和加法
fmax	最多两个浮点数
fmin	最少两个浮点数
fmod	模数
fract	正小数部分
frexp	二元尾数和指数
half_recip	按照 16 位精度计算的倒数
half_rsqrt	按 16 位精度计算的平方根的倒数
half_sqrt	根据 16 位精度计算的平方根
Hypot	斜边
ilogb	以 2 为底的指数
ldexp	根据尾数和指数创建浮点数
lgamma	伽玛函数的自然对数
log	自然对数
log10	以 10 为底的对数
log1p	数值加 1 的自然对数
log2	以 2 为底的对数
logb	以 2 为底的指数
疯了	乘法和加法
max	上限
分钟	下限
合辑	将两个值混合
modf	积分和小数分量
nan	不是数字
nan_half	不是数字
native_acos	近似反余弦值
native_acosh	近似反双曲余弦
native_acospi	近似反余弦值除以 pi
native_asin	近似反正弦
native_asinh	近似反双曲正弦
native_asinpi	近似正弦除以 pi
native_atan	近似反正切
native_atan2	比率的近似反正切
native_atan2pi	比率的近似反正切,除以 pi
native_atanh	近似反双曲正切
native_atanpi	近似反正切除以 pi
native_cbrt	近似立方根
native_cos	近似余弦值
native_cosh	近似双曲余弦
native_cospi	数值的近似余弦值乘以 pi
native_divide	近似除法
native_exp	将 e 取值近似为数值
native_exp10	将 10 取整为数字的近似值
native_exp2	将 2 取整为数的近似值
native_expm1	将 e 提高为负 1 的近似值
native_hypot	近似斜边
native_log	近似自然对数
native_log10	近似以 10 为底的对数
native_log1p	数值的近似自然对数加 1
native_log2	近似以 2 为底的对数
native_powr	取某个指数的近似正数底数
native_recip	近似倒数
native_rootn	近似 n 次方根
native_rsqrt	平方根的近似倒数
native_sin	近似正弦值
native_sincos	近似正弦和余弦
native_sinh	近似双曲正弦
native_sinpi	数值的近似正弦值乘以 pi
native_sqrt	近似平方根
native_tan	近似正切
native_tanh	近似双曲正切
native_tanpi	数值的近似正切值乘以 pi 的值
nextafter	下一个浮点数
pow	以指数为底数的底数
pown	基数为整数指数的底数
powr	以指数为底数的正数
弧度	将角度转换为弧度
remainder	除法(求余数)
remquo	除法的余数和商
rint	四舍五入为偶
rootn	N 次方根
round	向远离 0 的方向舍入
rsRand	伪随机数
rsqrt	平方根的倒数
签名	值的符号
sin	正弦
sincos	正弦和余弦
sinh	双曲正弦
sinpi	数值乘以 pi 的正弦值
sqrt	平方根
step	如果小于值,则为 0,否则为 1
tan	正切
双色	双曲正切
Tanpi	数值乘以 pi 的正切值
tgamma	Gamma 函数
截断	截断浮点数
已弃用的函数
rsClamp	已弃用。将值限制在某个范围内
rsFrac	已弃用。返回浮点数的小数部分

常量

M_1_PI :1 / pi,32 位浮点数

值:0.318309886183790671537767526745028724f
圆周率的倒数,表示为 32 位浮点数。

M_2_PI :2 / pi,32 位浮点数

值:0.636619772367581343075535053490057448f
2 除以 pi ,表示为 32 位浮点数。

M_2_SQRTPI :2 / sqrt(pi),32 位浮点数

值:1.128379167095512573896158903121545172f
2 除以圆周率的平方根,表示为 32 位浮点。

M_E :e,以 32 位浮点数表示

值:2.718281828459045235360287471352662498f
数字 e,自然对数的底数,表示为 32 位浮点数。

M_LN10 :log_e(10),采用 32 位浮点格式

值:2.302585092994045684017991454684364208f
10 的自然对数,表示为 32 位浮点数。

M_LN2 :log_e(2),采用 32 位浮点格式

值:0.693147180559945309417232121458176568f
2 的自然对数,表示为 32 位浮点数。

M_LOG10E :log_10(e),采用 32 位浮点格式

值:0.434294481903251827651128918916605082f
e 的以 10 为底的对数,表示为 32 位浮点。

M_LOG2E :log_2(e),采用 32 位浮点格式

值:1.442695040888963407359924681001892137f
e 的以 2 为底的对数,表示为 32 位浮点。

M_PI :pi,32 位浮点数

值:3.141592653589793238462643383279502884f
常数 pi,32 位浮点。

M_PI_2 :pi / 2,32 位浮点格式

值:1.570796326794896619231321691639751442f
圆周率除以 2,表示为 32 位浮点数。

M_PI_4 :pi / 4,32 位浮点数

值:0.785398163397448309615660845819875721f
圆周率除以 4,表示为 32 位浮点数。

M_SQRT1_2 :1 / sqrt(2),32 位浮点数

值:0.707106781186547524400844362104849039f
2 的平方根的倒数,表示为 32 位浮点数。

M_SQRT2 :sqrt(2),32 位浮点数

值:1.414213562373095048801688724209698079f
2 的平方根,表示为 32 位浮点。

函数

绝对值 :整数的绝对值
uchar abs(char v);
uchar2 abs(char2 v);
uchar3 abs(char3 v);
uchar4 abs(char4 v);
uint abs(int v);
uint2 abs(int2 v);
uint3 abs(int3 v);
uint4 abs(int4 v);
ushort abs(short v);
ushort2 abs(short2 v);
ushort3 abs(short3 v);
ushort4 abs(short4 v);
返回整数的绝对值。

对于浮点数,请使用 fabs()。

acos :反余弦
float acos(float v);
float2 acos(float2 v);
float3 acos(float3 v);
float4 acos(float4 v);
half acos(half v); 在 API 级别 24 中引入
half2 acos(half2 v); 在 API 级别 24 中引入
half3 acos(half3 v); 在 API 级别 24 中引入
half4 acos(half4 v); 在 API 级别 24 中引入
返回反余弦值(以弧度表示)。

另请参阅 native_acos()。

acosh :反双曲余弦
float acosh(float v);
float2 acosh(float2 v);
float3 acosh(float3 v);
float4 acosh(float4 v);
half acosh(half v); 在 API 级别 24 中引入
half2 acosh(half2 v); 在 API 级别 24 中引入
half3 acosh(half3 v); 在 API 级别 24 中引入
half4 acosh(half4 v); 在 API 级别 24 中引入
返回反双曲余弦值(以弧度为单位)。

另请参阅 native_acosh()。

acospi :反余弦值除以 pi
float acospi(float v);
float2 acospi(float2 v);
float3 acospi(float3 v);
float4 acospi(float4 v);
half acospi(half v); 在 API 级别 24 中引入
half2 acospi(half2 v); 在 API 级别 24 中引入
half3 acospi(half3 v); 在 API 级别 24 中引入
half4 acospi(half4 v); 在 API 级别 24 中引入
返回弧度除以圆周率的反余弦值。

如需获取以度为单位的反余弦值,请使用 acospi(a) * 180.f。

另请参阅 native_acospi()。

asin :反正弦
float asin(float v);
float2 asin(float2 v);
float3 asin(float3 v);
float4 asin(float4 v);
half asin(half v); 在 API 级别 24 中引入
half2 asin(half2 v); 在 API 级别 24 中引入
half3 asin(half3 v); 在 API 级别 24 中引入
half4 asin(half4 v); 在 API 级别 24 中引入
返回反正弦值(以弧度表示)。

另请参阅 native_asin()。

asinh :反双曲正弦
float asinh(float v);
float2 asinh(float2 v);
float3 asinh(float3 v);
float4 asinh(float4 v);
half asinh(half v); 在 API 级别 24 中引入
half2 asinh(half2 v); 在 API 级别 24 中引入
half3 asinh(half3 v); 在 API 级别 24 中引入
half4 asinh(half4 v); 在 API 级别 24 中引入
返回反双曲正弦值(以弧度为单位)。

另请参阅 native_asinh()。

asinpi :反正弦除以圆周率
float asinpi(float v);
float2 asinpi(float2 v);
float3 asinpi(float3 v);
float4 asinpi(float4 v);
half asinpi(half v); 在 API 级别 24 中引入
half2 asinpi(half2 v); 在 API 级别 24 中引入
half3 asinpi(half3 v); 在 API 级别 24 中引入
half4 asinpi(half4 v); 在 API 级别 24 中引入
返回弧度除以圆周率的反正弦值。

如需获取以度为单位的反正弦值,请使用 asinpi(a) * 180.f。

另请参阅 native_asinpi()。

atan :反正切
float atan(float v);
float2 atan(float2 v);
float3 atan(float3 v);
float4 atan(float4 v);
half atan(half v); 在 API 级别 24 中引入
half2 atan(half2 v); 在 API 级别 24 中引入
half3 atan(half3 v); 在 API 级别 24 中引入
half4 atan(half4 v); 在 API 级别 24 中引入
返回反正切值(以弧度表示)。

另请参阅 native_atan()。

atan2 :比率的反正切
float atan2(浮点分子, 浮点分母);
float2 atan2(float2 分子, float2 分母);
float3 atan2(float3 分子, float3 分母);
float4 atan2(float4 分子, float4 分母);
half atan2(half 分子, half 分母); 在 API 级别 24 中引入
half2 atan2(half2 分子, half2 分母); 在 API 级别 24 中引入
half3 atan2(half3 分子, half3 分母); 在 API 级别 24 中引入
half4 atan2(half4 分子, half4 分母); 在 API 级别 24 中引入
参数
分子 分子。
分母 分母。可以是 0。
返回 (numerator / denominator) 的反正切值,以弧度表示。

另请参阅 native_atan2()。

atan2pi :比率的反正切,除以 pi
float atan2pi(浮点分子, 浮点分母);
float2 atan2pi(float2 分子, float2 分母);
float3 atan2pi(float3 分子, float3 分母);
float4 atan2pi(float4 分子, float4 分母);
half atan2pi(half 分子, half 分母); 在 API 级别 24 中引入
half2 atan2pi(half2 分子, half2 分母); 在 API 级别 24 中引入
half3 atan2pi(half3 分子, half3 分母); 在 API 级别 24 中引入
half4 atan2pi(half4 分子, half4 分母); 在 API 级别 24 中引入
参数
分子 分子。
分母 分母。可以是 0。
返回 (numerator / denominator) 的反正切值,以弧度除以圆周率。

如需获取以度为单位的反正切值,请使用 atan2pi(n, d) * 180.f。

另请参阅 native_atan2pi()。

atanh :反双曲正切
float atanh(float v);
float2 atanh(float2 v);
float3 atanh(float3 v);
float4 atanh(float4 v);
half atanh(half v); 在 API 级别 24 中引入
half2 atanh(half2 v); 在 API 级别 24 中引入
half3 atanh(half3 v); 在 API 级别 24 中引入
half4 atanh(half4 v); 在 API 级别 24 中引入
返回反双曲正切值(以弧度为单位)。

另请参阅 native_atanh()。

atanpi :反正切除以 pi 所得的值
float atanpi(float v);
float2 atanpi(float2 v);
float3 atanpi(float3 v);
float4 atanpi(float4 v);
half atanpi(half v); 在 API 级别 24 中引入
half2 atanpi(half2 v); 在 API 级别 24 中引入
half3 atanpi(half3 v); 在 API 级别 24 中引入
half4 atanpi(half4 v); 在 API 级别 24 中引入
返回弧度除以圆周率的反正切值。

如需获取以度为单位的反正切值,请使用 atanpi(a) * 180.f。

另请参阅 native_atanpi()。

cbrt :立方体根
float cbrt(float v);
float2 cbrt(float2 v);
float3 cbrt(float3 v);
float4 cbrt(float4 v);
half cbrt(half v); 在 API 级别 24 中引入
half2 cbrt(half2 v); 在 API 级别 24 中引入
half3 cbrt(half3 v); 在 API 级别 24 中引入
half4 cbrt(half4 v); 在 API 级别 24 中引入
返回立方根。

另请参阅 native_cbrt()。

ceil :不小于值的最小整数
float ceil(float v);
float2 ceil(float2 v);
float3 ceil(float3 v);
float4 ceil(float4 v);
half ceil(half v); 在 API 级别 24 中引入
half2 ceil(half2 v); 在 API 级别 24 中引入
half3 ceil(half3 v); 在 API 级别 24 中引入
half4 ceil(half4 v); 在 API 级别 24 中引入
返回不小于某个值的最小整数。

例如,ceil(1.2f) 会返回 2.f,而 ceil(-1.2f) 会返回 -1.f。

另请参阅 floor()。

clamp :将值限制在一定范围内
char clamp(char value, char min_value, char max_value); 在 API 级别 19 中引入
char2 clamp(char2 value, char min_value, char max_value); 在 API 级别 19 中引入
char2 clamp(char2 value, char2 min_value, char2 max_value); 在 API 级别 19 中引入
char3 clamp(char3 value, char min_value, char max_value); 在 API 级别 19 中引入
char3 clamp(char3 value, char3 min_value, char3 max_value); 在 API 级别 19 中引入
char4 clamp(char4 value, char min_value, char max_value); 在 API 级别 19 中引入
char4 clamp(char4 value, char4 min_value, char4 max_value); 在 API 级别 19 中引入
float clamp(float value, float min_value, float max_value);
float2 clamp(float2 value, float min_value, float max_value);
float2 clamp(float2 value, float2 min_value, float2 max_value);
float3 clamp(float3 value, float min_value, float max_value);
float3 clamp(float3 value, float3 min_value, float3 max_value);
float4 clamp(float4 value, float min_value, float max_value);
float4 clamp(float4 value, float4 min_value, float4 max_value);
half clamp(half 值, half min_value, half max_value); 在 API 级别 24 中引入
half2 clamp(half2 值, half min_value, half max_value); 在 API 级别 24 中引入
half2 clamp(half2 值, half2 min_value, half2 max_value); 在 API 级别 24 中引入
half3 clamp(half3 值, half min_value, half max_value); 在 API 级别 24 中引入
half3 clamp(half3 值, half3 min_value, half3 max_value); 在 API 级别 24 中引入
half4 clamp(half4 值, half min_value, half max_value); 在 API 级别 24 中引入
half4 clamp(half4 值, half4 min_value, half4 max_value); 在 API 级别 24 中引入
int clamp(int value, int min_value, int max_value); 在 API 级别 19 中引入
int2 clamp(int2 value, int min_value, int max_value); 在 API 级别 19 中引入
int2 clamp(int2 value, int2 min_value, int2 max_value); 在 API 级别 19 中引入
int3 clamp(int3 value, int min_value, int max_value); 在 API 级别 19 中引入
int3 clamp(int3 value, int3 min_value, int3 max_value); 在 API 级别 19 中引入
int4 clamp(int4 value, int min_value, int max_value); 在 API 级别 19 中引入
int4 clamp(int4 value, int4 min_value, int4 max_value); 在 API 级别 19 中引入
long clamp(long value, long min_value, long max_value); 在 API 级别 19 中引入
long2 clamp(long2 值, long min_value, long max_value); 在 API 级别 19 中引入
long2 clamp(long2 值, long2 min_value, long2 max_value); 在 API 级别 19 中引入
long3 clamp(long3 值, long min_value, long max_value); 在 API 级别 19 中引入
long3 clamp(long3 值, long3 min_value, long3 max_value); 在 API 级别 19 中引入
long4 clamp(long4 值, long min_value, long max_value); 在 API 级别 19 中引入
long4 clamp(long4 值, long4 min_value, long4 max_value); 在 API 级别 19 中引入
short clamp(short value, short min_value, short max_value); 在 API 级别 19 中引入
short2 clamp(short2 值, short min_value, short max_value); 在 API 级别 19 中引入
short2 clamp(short2 值, short2 min_value, short2 max_value); 在 API 级别 19 中引入
short3 clamp(short3 值, 短最小值, 短最大值); 在 API 级别 19 中引入
short3 clamp(short3 值, short3 min_value, short3 max_value); 在 API 级别 19 中引入
short4 clamp(short4 值, short min_value, short max_value); 在 API 级别 19 中引入
short4 clamp(short4 值, short4 min_value, short4 max_value); 在 API 级别 19 中引入
uchar clamp(uchar value, uchar min_value, uchar max_value); 在 API 级别 19 中引入
uchar2 clamp(uchar2 值, uchar min_value, uchar max_value); 在 API 级别 19 中引入
uchar2 clamp(uchar2 值, uchar2 min_value, uchar2 max_value); 在 API 级别 19 中引入
uchar3 clamp(uchar3 value, uchar min_value, uchar max_value); 在 API 级别 19 中引入
uchar3 clamp(uchar3 value, uchar3 min_value, uchar3 max_value); 在 API 级别 19 中引入
uchar4 clamp(uchar4 值, uchar min_value, uchar max_value); 在 API 级别 19 中引入
uchar4 clamp(uchar4 值, uchar4 min_value, uchar4 max_value); 在 API 级别 19 中引入
uint clamp(uint value, uint min_value, uint max_value); 在 API 级别 19 中引入
uint2 clamp(uint2 value, uint min_value, uint max_value); 在 API 级别 19 中引入
uint2 clamp(uint2 value, uint2 min_value, uint2 max_value); 在 API 级别 19 中引入
uint3 clamp(uint3 value, uint min_value, uint max_value); 在 API 级别 19 中引入
uint3 clamp(uint3 value, uint3 min_value, uint3 max_value); 在 API 级别 19 中引入
uint4 clamp(uint4 value, uint min_value, uint max_value); 在 API 级别 19 中引入
uint4 clamp(uint4 value, uint4 min_value, uint4 max_value); 在 API 级别 19 中引入
ulong clamp(ulong 值, ulong min_value, ulong max_value); 在 API 级别 19 中引入
ulong2 clamp(ulong2 值, ulong min_value, ulong max_value); 在 API 级别 19 中引入
ulong2 clamp(ulong2 值, ulong2 min_value, ulong2 max_value); 在 API 级别 19 中引入
ulong3 clamp(ulong3 值, ulong min_value, ulong max_value); 在 API 级别 19 中引入
ulong3 clamp(ulong3 值, ulong3 min_value, ulong3 max_value); 在 API 级别 19 中引入
ulong4 clamp(ulong4 值, ulong min_value, ulong max_value); 在 API 级别 19 中引入
ulong4 clamp(ulong4 值, ulong4 min_value, ulong4 max_value); 在 API 级别 19 中引入
ushort clamp(ushort 值, ushort min_value, ushort max_value); 在 API 级别 19 中引入
ushort2 clamp(ushort2 值, ushort min_value, ushort max_value); 在 API 级别 19 中引入
ushort2 clamp(ushort2 值, ushort2 min_value, ushort2 max_value); 在 API 级别 19 中引入
ushort3 clamp(ushort3 值, ushort min_value, ushort max_value); 在 API 级别 19 中引入
ushort3 clamp(ushort3 值, ushort3 min_value, ushort3 max_value); 在 API 级别 19 中引入
ushort4 clamp(ushort4 值, ushort min_value, ushort max_value); 在 API 级别 19 中引入
ushort4 clamp(ushort4 值, ushort4 min_value, ushort4 max_value); 在 API 级别 19 中引入
参数
value 要限制的值。
最小值 下限、标量或匹配向量。
最大值 上限,必须与下限类型相匹配。
将值限制在指定的上下限和下限之间。如果值 < min_value,则 clamp() 返回 min_value;如果 value > max_value,则返回 max_value,否则返回 value。

clamp 有两种变体:一种是最小值和最大值是应用于值的所有条目的标量,另一种是最小值和最大值也是矢量。

如果 min_value 大于 max_value,则结果未定义。

clz :前导 0 位的数量
char clz(char value);
char2 clz(char2 value);
char3 clz(char3 value);
char4 clz(char4 value);
int clz(int value);
int2 clz(int2 value);
int3 clz(int3 value);
int4 clz(int4 value);
Shorts clz(short value);
short2 clz(short2 值)
short3 clz(short3 value);
short4 clz(short4 value);
uchar clz(uchar 值);
uchar2 clz(uchar2 值);
uchar3 clz(uchar3 value);
uchar4 clz(uchar4 值);
uint clz(uint 值);
uint2 clz(uint2 值);
uint3 clz(uint3 value);
uint4 clz(uint4 值);
ushort clz(ushort 值);
ushort2 clz(ushort2 值);
ushort3 clz(ushort3 值);
ushort4 clz(ushort4 值)
返回值中前导 0 位数的数量。

例如,clz((char)0x03) 会返回 6。

复制符号 :将一个数字的符号复制到另一个数字
float copysign(float magnitude_value, float sign_value);
float2 copysign(float2 magnitude_value, float2 sign_value);
float3 copysign(float3 magnitude_value, float3 sign_value);
float4 copysign(float4 magnitude_value, float4 sign_value);
half copysign(half magnitude_value, half sign_value); 在 API 级别 24 中引入
half2 copysign(half2 magnitude_value, half2 sign_value); 在 API 级别 24 中引入
half3 copysign(half3 magnitude_value, half3 sign_value); 在 API 级别 24 中引入
half4 copysign(half4 magnitude_value, half4 sign_value); 在 API 级别 24 中引入
将符号从 sign_value 复制到 magnitude_value 中。

返回的值是 magnitude_value 或 -magnitude_value。

例如,copysign(4.0f, -2.7f) 返回 -4.0f,copysign(-4.0f, 2.7f) 返回 4.0f。

cos :余弦
float cos(float v);
float2 cos(float2 v);
float3 cos(float3 v);
float4 cos(float4 v);
half cos(half v); 在 API 级别 24 中引入
half2 cos(half2 v); 在 API 级别 24 中引入
half3 cos(half3 v); 在 API 级别 24 中引入
half4 cos(half4 v); 在 API 级别 24 中引入
返回以弧度为单位的角度的余弦值。

另请参阅 native_cos()。

cosh :双曲余弦值
float cosh(float v);
float2 cosh(float2 v);
float3 cosh(float3 v);
float4 cosh(float4 v);
half cosh(half v); 在 API 级别 24 中引入
half2 cosh(half2 v); 在 API 级别 24 中引入
half3 cosh(half3 v); 在 API 级别 24 中引入
half4 cosh(half4 v); 在 API 级别 24 中引入
返回 v 的双曲余弦,其中 v 以弧度为单位。

另请参阅 native_cosh()。

cospi :数值的余弦值与 pi 的乘积
float cospi(float v);
float2 cospi(float2 v);
float3 cospi(float3 v);
float4 cospi(float4 v);
half cospi(half v); 在 API 级别 24 中引入
half2 cospi(half2 v); 在 API 级别 24 中引入
half3 cospi(half3 v); 在 API 级别 24 中引入
half4 cospi(half4 v); 在 API 级别 24 中引入
返回 (v * pi) 的余弦值,其中 (v * pi) 以弧度为单位。

如需获取以度为单位的值的余弦值,请调用 cospi(v / 180.f)。

另请参阅 native_cospi()。

角度 :将弧度转换为角度
float degrees(float v);
float2 度(float2 v);
float3 度(float3 v);
float4 度(float4 v);
half 度(half v); 在 API 级别 24 中引入
half2 度(half2 v); 在 API 级别 24 中引入
half3 度(half3 v); 在 API 级别 24 中引入
half4 度(half4 v); 在 API 级别 24 中引入
从弧度转换为角度。

erf :数学误差函数
float erf(float v);
float2 erf(float2 v);
float3 erf(float3 v);
float4 erf(float4 v);
half erf(half v); 在 API 级别 24 中引入
half2 erf(half2 v); 在 API 级别 24 中引入
half3 erf(half3 v); 在 API 级别 24 中引入
half4 erf(half4 v); 在 API 级别 24 中引入
返回错误函数。

erfc :数学互补误差函数
float erfc(float v);
float2 erfc(float2 v);
float3 erfc(float3 v);
float4 erfc(float4 v);
half erfc(half v); 在 API 级别 24 中引入
half2 erfc(half2 v); 在 API 级别 24 中引入
half3 erfc(half3 v); 在 API 级别 24 中引入
half4 erfc(half4 v); 在 API 级别 24 中引入
返回互补误差函数。

exp :e 加为数字
float exp(float v);
float2 exp(float2 v);
float3 exp(float3 v);
float4 exp(float4 v);
half exp(half v); 在 API 级别 24 中引入
half2 exp(half2 v); 在 API 级别 24 中引入
half3 exp(half3 v); 在 API 级别 24 中引入
half4 exp(half4 v); 在 API 级别 24 中引入
返回提高到 v 的 e,即 e ^ v。

另请参阅 native_exp()。

exp10 :10 取到数字
float exp10(float v);
float2 exp10(float2 v);
float3 exp10(float3 v);
float4 exp10(float4 v);
half exp10(half v); 在 API 级别 24 中引入
half2 exp10(half2 v); 在 API 级别 24 中引入
half3 exp10(half3 v); 在 API 级别 24 中引入
half4 exp10(half4 v); 在 API 级别 24 中引入
返回增加到 v 的 10,即 10.f ^ v。

另请参阅 native_exp10()。

exp2 :2 变为数字
float exp2(float v);
float2 exp2(float2 v);
float3 exp2(float3 v);
float4 exp2(float4 v);
half exp2(half v); 在 API 级别 24 中引入
half2 exp2(half2 v); 在 API 级别 24 中引入
half3 exp2(half3 v); 在 API 级别 24 中引入
half4 exp2(half4 v); 在 API 级别 24 中引入
返回 v 得出的 2,即 2.f ^ v。

另请参阅 native_exp2()。

expm1 :e 加为数字减 1
float expm1(float v);
float2 expm1(float2 v);
float3 expm1(float3 v);
float4 expm1(float4 v);
half expm1(half v); 在 API 级别 24 中引入
half2 expm1(half2 v); 在 API 级别 24 中引入
half3 expm1(half3 v); 在 API 级别 24 中引入
half4 expm1(half4 v); 在 API 级别 24 中引入
返回 e 增加到 v 减 1 的结果,即 (e ^ v) - 1。

另请参阅 native_expm1()。

fabs :浮点数的绝对值
float fabs(float v);
float2 fabs(float2 v);
float3 fabs(float3 v);
float4 fabs(float4 v);
half fabs(half v); 在 API 级别 24 中引入
half2 fabs(half2 v); 在 API 级别 24 中引入
half3 fabs(half3 v); 在 API 级别 24 中引入
half4 fabs(half4 v); 在 API 级别 24 中引入
返回浮点数 v 的绝对值。

对于整数,请使用 abs()。

fdim :两个值之间的正差
float fdim(float a, float b);
float2 fdim(float2 a, float2 b);
float3 fdim(float3 a, float3 b);
float4 fdim(float4 a, float4 b);
half fdim(half a, half b); 在 API 级别 24 中引入
half2 fdim(half2 a, half2 b); 在 API 级别 24 中引入
half3 fdim(half3 a, half3 b); 在 API 级别 24 中引入
half4 fdim(half4 a, half4 b); 在 API 级别 24 中引入
返回两个值之间的正差。

如果 a > b,则返回 (a - b),否则返回 0f。

floor :不大于值的最小整数
float floor(float v);
float2 floor(float2 v);
float3 floor(float3 v);
float4 floor(float4 v);
half floor(half v); 在 API 级别 24 中引入
half2 floor(half2 v); 在 API 级别 24 中引入
half3 floor(half3 v); 在 API 级别 24 中引入
half4 floor(half4 v); 在 API 级别 24 中引入
返回不大于值的最小整数。

例如,floor(1.2f) 会返回 1.f,而 floor(-1.2f) 会返回 -2.f。

另请参阅 ceil()。

fma :乘法和加法
float fma(float multiplicand1, float multiplicand2, float offset);
float2 fma(float2 multiplicand1, float2 multiplicand2, float2 offset);
float3 fma(float3 multiplicand1, float3 multiplicand2, float3 offset);
float4 fma(float4 multiplicand1, float4 multiplicand2, float4 offset);
half fma(half multiplicand1, half multiplicand2, half offset); 在 API 级别 24 中引入
half2 fma(half2 multiplicand1, half2 multiplicand2, half2 offset); 在 API 级别 24 中引入
half3 fma(half3 multiplicand1, half3 multiplicand2, half3 offset); 在 API 级别 24 中引入
half4 fma(half4 multiplicand1, half4 multiplicand2, half4 偏移量); 在 API 级别 24 中引入
乘法和加法。返回 (multiplicand1 * multiplicand2) + offset。

此函数类似于 mad()。fma() 仅在相加后才保留已乘结果和舍入的完整精度。mad() 会在乘法和加法后舍入。 在 rs_fp_relaxed 模式下,无法保证提供这种额外的精确度。

fmax :最多两个浮点数
float fmax(float a, float b);
float2 fmax(float2 a, float b);
float2 fmax(float2 a, float2 b);
float3 fmax(float3 a, float b);
float3 fmax(float3 a, float3 b);
float4 fmax(float4 a, float b);
float4 fmax(float4 a, float4 b);
half fmax(half a, half b); 在 API 级别 24 中引入
half2 fmax(half2 a, half b); 在 API 级别 24 中引入
half2 fmax(half2 a, half2 b); 在 API 级别 24 中引入
half3 fmax(half3 a, half b); 在 API 级别 24 中引入
half3 fmax(half3 a, half3 b); 在 API 级别 24 中引入
half4 fmax(half4 a, half b); 在 API 级别 24 中引入
half4 fmax(half4 a, half4 b); 在 API 级别 24 中引入
返回 a 和 b 的最大值,即 (a < b ? b : a)。

max() 函数会返回相同的结果,但可用于更多数据类型。

fmin :最少两个浮点数
float fmin(float a, float b);
float2 fmin(float2 a, float b);
float2 fmin(float2 a, float2 b);
float3 fmin(float3 a, float b);
float3 fmin(float3 a, float3 b);
float4 fmin(float4 a, float b);
float4 fmin(float4 a, float4 b);
half fmin(half a, half b); 在 API 级别 24 中引入
half2 fmin(half2 a, half b); 在 API 级别 24 中引入
half2 fmin(half2 a, half2 b); 在 API 级别 24 中引入
half3 fmin(half3 a, half b); 在 API 级别 24 中引入
half3 fmin(half3 a, half3 b); 在 API 级别 24 中引入
half4 fmin(half4 a, half b); 在 API 级别 24 中引入
half4 fmin(half4 a, half4 b); 在 API 级别 24 中引入
返回 a 和 b 的最小值,即 (a > b ? b : a)。

min() 函数会返回相同的结果,但可以应用于更多数据类型。

fmod :模数
float fmod(float numerator, float denominator);
float2 fmod(float2 分子, float2 分母);
float3 fmod(float3 分子, float3 分母);
float4 fmod(float4 分子, float4 分母);
half fmod(half 分子, half 分母); 在 API 级别 24 中引入
half2 fmod(half2 分子, half2 分母); 在 API 级别 24 中引入
half3 fmod(half3 分子, half3 分母); 在 API 级别 24 中引入
half4 fmod(half4 分子, half4 分母); 在 API 级别 24 中引入
返回(分子 / 分母)的余数,其中商数向上舍入为零。

函数 remainder() 与此类似,但会向最接近的整数四舍五入。例如,fmod(-3.8f, 2.f) 返回 -1.8f (-3.8f - -1.f * 2.f),而 remainder(-3.8f, 2.f) 返回 0.2f (-3.8f - -2.f * 2.f)。

分数 :正小数部分
float fract(float v);
float fract(float v, float* floor);
float2 fract(float2 v);
float2 fract(float2 v, float2* floor);
float3 fract(float3 v);
float3 fract(float3 v, float3* floor);
float4 fract(float4 v);
float4 fract(float4 v, float4* floor);
half fract(half v); 在 API 级别 24 中引入
half fract(half v, half* floor); 在 API 级别 24 中引入
half2 fract(half2 v); 在 API 级别 24 中引入
half2 fract(half2 v, half2* floor); 在 API 级别 24 中引入
half3 fract(half3 v); 在 API 级别 24 中引入
half3 fract(half3 v, half3* floor); 在 API 级别 24 中引入
half4 fract(half4 v); 在 API 级别 24 中引入
half4 fract(half4 v, half4* floor); 在 API 级别 24 中引入
参数
v 输入值。
层 如果底价不为 null,*底价将设置为 v 的底价。
返回 v 的正小数部分,即 v - floor(v)。

例如,fract(1.3f, &val) 会返回 0.3f 并将 val 设置为 1.f。 fract(-1.3f, &val) 返回 0.7f 并将 val 设置为 -2.f。

frexp :二元尾数和指数
float frexp(float v, int* exponent);
float2 frexp(float2 v, int2* 指数);
float3 frexp(float3 v, int3* 指数);
float4 frexp(float4 v, int4* 指数);
half frexp(half v, int* exponent); 在 API 级别 24 中引入
half2 frexp(half2 v, int2* 指数); 在 API 级别 24 中引入
half3 frexp(half3 v, int3* 指数); 在 API 级别 24 中引入
half4 frexp(half4 v, int4* 指数); 在 API 级别 24 中引入
参数
v 输入值。
指数 如果指数不为 null,*指数将设为 v 的指数。
返回 v 的二元尾数和指数,即 v == mantissa * 2 ^ exponent。

尾数始终介于 0.5(含)和 1.0(不含)之间。

请参阅 ldexp() 了解反向操作。另请参阅 logb() 和 ilogb()。

half_recip :按 16 位精度计算的倒数
float half_recip(float v); 在 API 级别 17 中引入
float2 half_recip(float2 v); 在 API 级别 17 中引入
float3 half_recip(float3 v); 在 API 级别 17 中引入
float4 half_recip(float4 v); 在 API 级别 17 中引入
返回值的近似倒数。

精度是 16 位浮点值的精度。

另请参阅 native_recip()。

half_rsqrt :按照 16 位精度计算的平方根的倒数
float half_rsqrt(float v); 在 API 级别 17 中引入
float2 half_rsqrt(float2 v); 在 API 级别 17 中引入
float3 half_rsqrt(float3 v); 在 API 级别 17 中引入
float4 half_rsqrt(float4 v); 在 API 级别 17 中引入
返回 (1.f / sqrt(value)) 的近似值。

精度是 16 位浮点值的精度。

另请参阅 rsqrt()、native_rsqrt()。

half_sqrt :根据 16 位精度计算的平方根
float half_sqrt(float v); 在 API 级别 17 中引入
float2 half_sqrt(float2 v); 在 API 级别 17 中引入
float3 half_sqrt(float3 v); 在 API 级别 17 中引入
float4 half_sqrt(float4 v); 在 API 级别 17 中引入
返回值的近似平方根。

精度是 16 位浮点值的精度。

另请参阅 sqrt()、native_sqrt()。

hypot :斜边
float hypot(float a, float b);
float2 hypot(float2 a, float2 b);
float3 hypot(float3 a, float3 b);
float4 hypot(float4 a, float4 b);
half hypot(half a, half b); 在 API 级别 24 中引入
half2 hypot(half2 a, half2 b); 在 API 级别 24 中引入
half3 hypot(half3 a, half3 b); 在 API 级别 24 中引入
half4 hypot(half4 a, half4 b); 在 API 级别 24 中引入
返回斜边,即 sqrt(a * a + b * b)。

另请参阅 native_hypot()。

ilogb :以 2 为底数的指数
int ilogb(float v);
int ilogb(half v); 在 API 级别 24 中引入
int2 ilogb(float2 v);
int2 ilogb(half2 v); 在 API 级别 24 中引入
int3 ilogb(float3 v);
int3 ilogb(half3 v); 在 API 级别 24 中引入
int4 ilogb(float4 v);
int4 ilogb(half4 v); 在 API 级别 24 中引入
返回数值的底数为 2 的指数,尾数介于 1.f(含)和 2.f(不含)之间。

例如,ilogb(8.5f) 会返回 3。

由于尾数不同,因此该数字比 frexp() 返回的值小 1。

logb() 与此类似,但它会返回浮点数。

ldexp :根据尾数和指数创建浮点数
float ldexp(浮点尾数, 整数指数);
float2 ldexp(float2 尾数, int exponent);
float2 ldexp(float2 尾数, int2 指数);
float3 ldexp(float3 尾数, int exponent);
float3 ldexp(float3 尾数, int3 指数);
float4 ldexp(float4 尾数, int exponent);
float4 ldexp(float4 尾数, int4 指数);
half ldexp(半尾数, 整数指数); 在 API 级别 24 中引入
half2 ldexp(half2 尾数, int exponent); 在 API 级别 24 中引入
half2 ldexp(half2 尾数, int2 指数); 在 API 级别 24 中引入
half3 ldexp(half3 尾数, int exponent); 在 API 级别 24 中引入
half3 ldexp(half3 尾数, int3 指数); 在 API 级别 24 中引入
half4 ldexp(half4 尾数, int exponent); 在 API 级别 24 中引入
half4 ldexp(half4 尾数, int4 指数); 在 API 级别 24 中引入
参数
蝠鲼 尾音。
指数 指数、单个分量或匹配矢量。
返回根据尾数和指数创建的浮点数,即(尾数 * 2 ^ 指数)。

请参阅 frexp() 了解反向操作。

lgamma :伽马函数的自然对数
float lgamma(float v);
float lgamma(float v, int* sign_of_gamma);
float2 lgamma(float2 v);
float2 lgamma(float2 v, int2* sign_of_gamma);
float3 lgamma(float3 v);
float3 lgamma(float3 v, int3* sign_of_gamma);
float4 lgamma(float4 v);
float4 lgamma(float4 v, int4* sign_of_gamma);
half lgamma(half v); 在 API 级别 24 中引入
half lgamma(half v, int* sign_of_gamma); 在 API 级别 24 中引入
half2 lgamma(half2 v); 在 API 级别 24 中引入
half2 lgamma(half2 v, int2* sign_of_gamma); 在 API 级别 24 中引入
half3 lgamma(half3 v); 在 API 级别 24 中引入
half3 lgamma(half3 v, int3* sign_of_gamma); 在 API 级别 24 中引入
half4 lgamma(half4 v); 在 API 级别 24 中引入
half4 lgamma(half4 v, int4* sign_of_gamma); 在 API 级别 24 中引入
参数
v
伽马符号 如果 sign_of_gamma 不为 null,如果 v 的灰度系数为负,*sign_of_gamma 将设为 -1.f,否则设为 1.f。
返回伽玛函数的绝对值的自然对数,即 log(fabs(tgamma(v)))。

另请参阅 tgamma()。

log :自然对数
float log(float v);
float2 log(float2 v);
float3 log(float3 v);
float4 log(float4 v);
half log(half v); 在 API 级别 24 中引入
half2 log(half2 v); 在 API 级别 24 中引入
half3 log(half3 v); 在 API 级别 24 中引入
half4 log(half4 v); 在 API 级别 24 中引入
返回自然对数。

另请参阅 native_log()。

log10 :以 10 为底的对数
float log10(float v);
float2 log10(float2 v);
float3 log10(float3 v);
float4 log10(float4 v);
half log10(half v); 在 API 级别 24 中引入
half2 log10(half2 v); 在 API 级别 24 中引入
half3 log10(half3 v); 在 API 级别 24 中引入
half4 log10(half4 v); 在 API 级别 24 中引入
返回以 10 为底的对数。

另请参阅 native_log10()。

log1p :值加 1 的自然对数
float log1p(float v);
float2 log1p(float2 v);
float3 log1p(float3 v);
float4 log1p(float4 v);
half log1p(half v); 在 API 级别 24 中引入
half2 log1p(half2 v); 在 API 级别 24 中引入
half3 log1p(half3 v); 在 API 级别 24 中引入
half4 log1p(half4 v); 在 API 级别 24 中引入
返回 (v + 1.f) 的自然对数。

另请参阅 native_log1p()。

log2 :以 2 为底的对数
float log2(float v);
float2 log2(float2 v);
float3 log2(float3 v);
float4 log2(float4 v);
half log2(half v); 在 API 级别 24 中引入
half2 log2(half2 v); 在 API 级别 24 中引入
half3 log2(half3 v); 在 API 级别 24 中引入
half4 log2(half4 v); 在 API 级别 24 中引入
返回以 2 为底的对数。

另请参阅 native_log2()。

logb :以 2 为底数的指数
float logb(float v);
float2 logb(float2 v);
float3 logb(float3 v);
float4 logb(float4 v);
half logb(half v); 在 API 级别 24 中引入
half2 logb(half2 v); 在 API 级别 24 中引入
half3 logb(half3 v); 在 API 级别 24 中引入
half4 logb(half4 v); 在 API 级别 24 中引入
返回数值的底数为 2 的指数,尾数介于 1.f(含)和 2.f(不含)之间。

例如,logb(8.5f) 会返回 3.f。

由于尾数不同,因此该数字比 frexp() 返回的数字小 1。

ilogb() 与此类似,但它会返回一个整数。

mad :乘法和加法
float mad(float multiplicand1, float multiplicand2, float offset);
float2 mad(float2 multiplicand1, float2 multiplicand2, float2 offset);
float3 mad(float3 multiplicand1, float3 multiplicand2, float3 offset);
float4 mad(float4 multiplicand1, float4 multiplicand2, float4 offset);
half mad(half multiplicand1, half multiplicand2, half 偏移量); 在 API 级别 24 中引入
half2 mad(half2 multiplicand1, half2 multiplicand2, half2 偏移量); 在 API 级别 24 中引入
half3 mad(half3 multiplicand1, half3 multiplicand2, half3 偏移量); 在 API 级别 24 中引入
half4 mad(half4 multiplicand1, half4 multiplicand2, half4 偏移量); 在 API 级别 24 中引入
乘法和加法。返回 (multiplicand1 * multiplicand2) + offset。

此函数类似于 fma()。fma() 仅在相加后才保留已乘结果和舍入的完整精度。mad() 会在乘法和加法后舍入。 在 rs_fp_relaxed 模式下,mad() 可能不会在多重复数后进行舍入。

max :上限
char max(char a, char b);
char2 max(char2 a, char2 b);
char3 max(char3 a, char3 b);
char4 max(char4 a, char4 b);
float max(float a, float b);
float2 max(float2 a, float b);
float2 max(float2 a, float2 b);
float3 max(float3 a, float b);
float3 max(float3 a, float3 b);
float4 max(float4 a, float b);
float4 max(float4 a, float4 b);
half max(half a, half b); 在 API 级别 24 中引入
half2 max(half2 a, half b); 在 API 级别 24 中引入
half2 max(half2 a, half2 b); 在 API 级别 24 中引入
half3 max(half3 a, half b); 在 API 级别 24 中引入
half3 max(half3 a, half3 b); 在 API 级别 24 中引入
half4(max(half4 a, half b); 在 API 级别 24 中引入
half4(max(half4 a, half4 b); 在 API 级别 24 中引入
int max(int a, int b);
int2 max(int2 a, int2 b);
int3 max(int3 a, int3 b);
int4 max(int4 a, int4 b);
long max(long a, long b); 在 API 级别 21 中引入
long2 max(long2 a, long2 b); 在 API 级别 21 中引入
long3(long3 a, long3 b); 在 API 级别 21 中引入
long4(long4 a, long4 b); 在 API 级别 21 中引入
Shorts max(short a, short b);
short2 max(short2 a, short2 b);
short3 max(short3 a, short3 b);
short4 max(short4 a, short4 b);
uchar max(uchar a, uchar b);
uchar2 max(uchar2 a, uchar2 b);
uchar3 max(uchar3 a, uchar3 b);
uchar4 max(uchar4 a, uchar4 b);
uint max(uint a, uint b);
uint2 max(uint2 a, uint2 b);
uint3 max(uint3 a, uint3 b);
uint4 max(uint4 a, uint4 b);
ulong max(ulong a, ulong b); 在 API 级别 21 中引入
ulong2 max(ulong2 a, ulong2 b); 在 API 级别 21 中引入
ulong3 max(ulong3 a, ulong3 b); 在 API 级别 21 中引入
ulong4 max(ulong4 a, ulong4 b); 在 API 级别 21 中引入
ushort max(ushort a, ushort b);
ushort2 max(ushort2 a, ushort2 b);
ushort3 max(ushort3 a, ushort3 b);
ushort4 max(ushort4 a, ushort4 b);
返回两个参数的最大值。

min :最小值
char min(char a, char b);
char2 min(char2 a, char2 b);
char3 min(char3 a, char3 b);
char4 min(char4 a, char4 b);
float min(float a, float b);
float2 min(float2 a, float b);
float2 min(float2 a, float2 b);
float3 min(float3 a, float b);
float3 min(float3 a, float3 b);
float4 min(float4 a, float b);
float4 min(float4 a, float4 b);
half min(half a, half b); 在 API 级别 24 中引入
half2 min(half2 a, half b); 在 API 级别 24 中引入
half2 min(half2 a, half2 b); 在 API 级别 24 中引入
half3 min(half3 a, half b); 在 API 级别 24 中引入
half3 min(half3 a, half3 b); 在 API 级别 24 中引入
half4 min(half4 a, half b); 在 API 级别 24 中引入
half4 min(half4 a, half4 b); 在 API 级别 24 中引入
int min(int a, int b);
int2 min(int2 a, int2 b);
int3 min(int3 a, int3 b);
int4 min(int4 a, int4 b);
long min(long a, long b); 在 API 级别 21 中引入
long2 min(long2 a, long2 b); 在 API 级别 21 中引入
long3 min(long3 a, long3 b); 在 API 级别 21 中引入
long4 min(long4 a, long4 b); 在 API 级别 21 中引入
Shorts min(short a, short b);
short2 min(short2 a, short2 b);
short3 min(short3 a, short3 b);
short4 min(short4 a, short4 b);
uchar min(uchar a, uchar b);
uchar2 min(uchar2 a, uchar2 b);
uchar3 min(uchar3 a, uchar3 b);
uchar4 min(uchar4 a, uchar4 b);
uint min(uint a, uint b);
uint2 min(uint2 a, uint2 b);
uint3 min(uint3 a, uint3 b);
uint4 min(uint4 a, uint4 b);
ulong min(ulong a, ulong b); 在 API 级别 21 中引入
ulong2 min(ulong2 a, ulong2 b); 在 API 级别 21 中引入
ulong3 min(ulong3 a, ulong3 b); 在 API 级别 21 中引入
ulong4 min(ulong4 a, ulong4 b); 在 API 级别 21 中引入
ushort min(ushort a, ushort b);
ushort2 min(ushort2 a, ushort2 b);
ushort3 min(ushort3 a, ushort3 b);
ushort4 min(ushort4 a, ushort4 b);
返回两个参数的最小值。

mix :将两个值混合
float mix(float start, float stop, floatfloat);
float2 mix(float2 start, float2 stop, floatfactor);
float2 mix(float2 start, float2停止, float2比例);
float3 mix(float3 start, float3 stop, float violation);
float3 mix(float3 start, float3停止, float3
float4 mix(float4 start, float4 stop, float resolve);
float4 mix(float4 start, float4 stop, float4 position);
halfmi(半次开始、半次停止、半分); 在 API 级别 24 中引入
half2 mix(half2 开始,half2 停止,half 比例); 在 API 级别 24 中引入
half2 mix(half2 片段,half2 停止排量,half2 比例); 在 API 级别 24 中引入
half3 mix(half3 片段,half3 停靠点,half3 小数); 在 API 级别 24 中引入
half3 mix(开始的 half3,half3 的停止次数,half3 比例); 在 API 级别 24 中引入
half4 mix(half4 播放次数,half4 停止数量,half 小数); 在 API 级别 24 中引入
half4 mix(half4 播放次数,half4 停止数量,half4 比例); 在 API 级别 24 中引入
返回起始值 + ((停止 - 起始值) * 分数)。

这对于混合两个值非常有用。例如,如需创建一个颜色为 40% 且颜色为 60% 的新颜色,请使用 mix(color1, color2, 0.6f)。

modf :积分和小数分量
float modf(float v, float* integral_part);
float2 modf(float2 v, float2* integral_part);
float3 modf(float3 v, float3* integral_part);
float4 modf(float4 v, float4* integral_part);
half modf(half v, half* integral_part); 在 API 级别 24 中引入
half2 modf(half2 v, half2* integral_part); 在 API 级别 24 中引入
half3 modf(half3 v, half3* integral_part); 在 API 级别 24 中引入
half4 modf(half4 v, half4* integral_part); 在 API 级别 24 中引入
参数
v 源值。
整数部分 *integral_part 将设为数值的整数部分。
返回
值的浮点部分。
返回数值的积分和小数分量。

两个分量都将带有与 x 相同的符号。例如,对于 -3.72f 的输入,*integral_part 将设置为 -3.f,将返回 .72f。

nan :不是数字
float nan(uint v);
参数
v 未使用。
返回 NaN 值(非数字)。

nan_half :不是数字
half nan_half); 在 API 级别 24 中引入
返回半精度浮点 NaN 值(不是数字)。

native_acos :近似反余弦值
float native_acos(float v); 在 API 级别 21 中引入
float2 native_acos(float2 v); 在 API 级别 21 中引入
float3 native_acos(float3 v); 在 API 级别 21 中引入
float4 native_acos(float4 v); 在 API 级别 21 中引入
half native_acos(half v); 在 API 级别 24 中引入
half2 native_acos(half2 v); 在 API 级别 24 中引入
half3 native_acos(half3 v); 在 API 级别 24 中引入
half4 native_acos(half4 v); 在 API 级别 24 中引入
返回近似反余弦值(以弧度表示)。

此函数会从小于 -1 或大于 1 的输入值中生成未定义的结果。

另请参阅 acos()。

native_acosh :近似反双曲余弦
float native_acosh(float v); 在 API 级别 21 中引入
float2 native_acosh(float2 v); 在 API 级别 21 中引入
float3 native_acosh(float3 v); 在 API 级别 21 中引入
float4 native_acosh(float4 v); 在 API 级别 21 中引入
half native_acosh(half v); 在 API 级别 24 中引入
half2 native_acosh(half2 v); 在 API 级别 24 中引入
half3 native_acosh(half3 v); 在 API 级别 24 中引入
half4 native_acosh(half4 v); 在 API 级别 24 中引入
返回近似的反双曲余弦值(以弧度为单位)。

另请参阅 acosh()。

native_acospi :近似反余弦值除以 pi
float native_acospi(float v); 在 API 级别 21 中引入
float2 native_acospi(float2 v); 在 API 级别 21 中引入
float3 native_acospi(float3 v); 在 API 级别 21 中引入
float4 native_acospi(float4 v); 在 API 级别 21 中引入
half native_acospi(half v); 在 API 级别 24 中引入
half2 native_acospi(half2 v); 在 API 级别 24 中引入
half3 native_acospi(half3 v); 在 API 级别 24 中引入
half4 native_acospi(half4 v); 在 API 级别 24 中引入
返回弧度除以圆周率的近似反余弦值。

如需获取以度为单位的反余弦值,请使用 acospi(a) * 180.f。

此函数会从小于 -1 或大于 1 的输入值中生成未定义的结果。

另请参阅 acospi()。

native_asin :近似反正弦值
float native_asin(float v); 在 API 级别 21 中引入
float2 native_asin(float2 v); 在 API 级别 21 中引入
float3 native_asin(float3 v); 在 API 级别 21 中引入
float4 native_asin(float4 v); 在 API 级别 21 中引入
half native_asin(half v); 在 API 级别 24 中引入
half2 native_asin(half2 v); 在 API 级别 24 中引入
half3 native_asin(half3 v); 在 API 级别 24 中引入
half4 native_asin(half4 v); 在 API 级别 24 中引入
返回近似反正弦值(以弧度表示)。

此函数会从小于 -1 或大于 1 的输入值中生成未定义的结果。

另请参阅 asin()。

native_asinh :近似反双曲正弦
float native_asinh(float v); 在 API 级别 21 中引入
float2 native_asinh(float2 v); 在 API 级别 21 中引入
float3 native_asinh(float3 v); 在 API 级别 21 中引入
float4 native_asinh(float4 v); 在 API 级别 21 中引入
half native_asinh(half v); 在 API 级别 24 中引入
half2 native_asinh(half2 v); 在 API 级别 24 中引入
half3 native_asinh(half3 v); 在 API 级别 24 中引入
half4 native_asinh(half4 v); 在 API 级别 24 中引入
返回近似的反双曲正弦值(以弧度为单位)。

另请参阅 asinh()。

native_asinpi :近似正弦除以 pi
float native_asinpi(float v); 在 API 级别 21 中引入
float2 native_asinpi(float2 v); 在 API 级别 21 中引入
float3 native_asinpi(float3 v); 在 API 级别 21 中引入
float4 native_asinpi(float4 v); 在 API 级别 21 中引入
half native_asinpi(half v); 在 API 级别 24 中引入
half2 native_asinpi(half2 v); 在 API 级别 24 中引入
half3 native_asinpi(half3 v); 在 API 级别 24 中引入
half4 native_asinpi(half4 v); 在 API 级别 24 中引入
返回弧度除以圆周率的近似反正弦值。

如需获取以度为单位的反正弦值,请使用 asinpi(a) * 180.f。

此函数会从小于 -1 或大于 1 的输入值中生成未定义的结果。

另请参阅 asinpi()。

native_atan :近似反正切
float native_atan(float v); 在 API 级别 21 中引入
float2 native_atan(float2 v); 在 API 级别 21 中引入
float3 native_atan(float3 v); 在 API 级别 21 中引入
float4 native_atan(float4 v); 在 API 级别 21 中引入
half native_atan(half v); 在 API 级别 24 中引入
half2 native_atan(half2 v); 在 API 级别 24 中引入
half3 native_atan(half3 v); 在 API 级别 24 中引入
half4 native_atan(half4 v); 在 API 级别 24 中引入
返回近似反正切值(以弧度表示)。

另请参阅 atan()。

native_atan2 :比率的近似反正切
float native_atan2(float 分子, 浮点分母); 在 API 级别 21 中引入
float2 native_atan2(float2 分子, float2 分母); 在 API 级别 21 中引入
float3 native_atan2(float3 分子, float3 分母); 在 API 级别 21 中引入
float4 native_atan2(float4 分子, float4 分母); 在 API 级别 21 中引入
half native_atan2(half 分子, half 分母); 在 API 级别 24 中引入
half2 native_atan2(half2 分子, half2 分母); 在 API 级别 24 中引入
half3 native_atan2(half3 分子, half3 分母); 在 API 级别 24 中引入
half4 native_atan2(half4 分子, half4 分母); 在 API 级别 24 中引入
参数
分子 分子。
分母 分母。可以是 0。
返回 (numerator / denominator) 的近似反正切值(以弧度为单位)。

另请参阅 atan2()。

native_atan2pi :比率的近似反正切值,除以 pi
float native_atan2pi(浮点分子, 浮点分母); 在 API 级别 21 中引入
float2 native_atan2pi(float2 分子, float2 分母); 在 API 级别 21 中引入
float3 native_atan2pi(float3 分子, float3 分母); 在 API 级别 21 中引入
float4 native_atan2pi(float4 分子, float4 分母); 在 API 级别 21 中引入
半 native_atan2pi(半分子, 半分母); 在 API 级别 24 中引入
half2 native_atan2pi(half2 分子, half2 分母); 在 API 级别 24 中引入
half3 native_atan2pi(half3 分子, half3 分母); 在 API 级别 24 中引入
half4 native_atan2pi(half4 分子, half4 分母); 在 API 级别 24 中引入
参数
分子 分子。
分母 分母。可以是 0。
返回 (numerator / denominator) 的近似反正切值,以弧度除以圆周率。

如需获取以度为单位的反正切值,请使用 atan2pi(n, d) * 180.f。

另请参阅 atan2pi()。

native_atanh :近似反双曲正切
float native_atanh(float v); 在 API 级别 21 中引入
float2 native_atanh(float2 v); 在 API 级别 21 中引入
float3 native_atanh(float3 v); 在 API 级别 21 中引入
float4 native_atanh(float4 v); 在 API 级别 21 中引入
half native_atanh(half v); 在 API 级别 24 中引入
half2 native_atanh(half2 v); 在 API 级别 24 中引入
half3 native_atanh(half3 v); 在 API 级别 24 中引入
half4 native_atanh(half4 v); 在 API 级别 24 中引入
返回近似的反双曲正切值(以弧度为单位)。

另请参阅 atanh()。

native_atanpi :近似反正切除以 pi
float native_atanpi(float v); 在 API 级别 21 中引入
float2 native_atanpi(float2 v); 在 API 级别 21 中引入
float3 native_atanpi(float3 v); 在 API 级别 21 中引入
float4 native_atanpi(float4 v); 在 API 级别 21 中引入
half native_atanpi(half v); 在 API 级别 24 中引入
half2 native_atanpi(half2 v); 在 API 级别 24 中引入
half3 native_atanpi(half3 v); 在 API 级别 24 中引入
half4 native_atanpi(half4 v); 在 API 级别 24 中引入
返回弧度除以圆周率的近似反正切值。

如需获取以度为单位的反正切值,请使用 atanpi(a) * 180.f。

另请参阅 atanpi()。

native_cbrt :近似立方根
float native_cbrt(float v); 在 API 级别 21 中引入
float2 native_cbrt(float2 v); 在 API 级别 21 中引入
float3 native_cbrt(float3 v); 在 API 级别 21 中引入
float4 native_cbrt(float4 v); 在 API 级别 21 中引入
half native_cbrt(half v); 在 API 级别 24 中引入
half2 native_cbrt(half2 v); 在 API 级别 24 中引入
half3 native_cbrt(half3 v); 在 API 级别 24 中引入
half4 native_cbrt(half4 v); 在 API 级别 24 中引入
返回近似立方根。

另请参阅 cbrt()。

native_cos :近似余弦值
float native_cos(float v); 在 API 级别 21 中引入
float2 native_cos(float2 v); 在 API 级别 21 中引入
float3 native_cos(float3 v); 在 API 级别 21 中引入
float4 native_cos(float4 v); 在 API 级别 21 中引入
half native_cos(half v); 在 API 级别 24 中引入
half2 native_cos(half2 v); 在 API 级别 24 中引入
half3 native_cos(half3 v); 在 API 级别 24 中引入
half4 native_cos(half4 v); 在 API 级别 24 中引入
返回以弧度表示的角度的近似余弦值。

另请参阅 cos()。

native_cosh :近似双曲余弦值
float native_cosh(float v); 在 API 级别 21 中引入
float2 native_cosh(float2 v); 在 API 级别 21 中引入
float3 native_cosh(float3 v); 在 API 级别 21 中引入
float4 native_cosh(float4 v); 在 API 级别 21 中引入
half native_cosh(half v); 在 API 级别 24 中引入
half2 native_cosh(half2 v); 在 API 级别 24 中引入
half3 native_cosh(half3 v); 在 API 级别 24 中引入
half4 native_cosh(half4 v); 在 API 级别 24 中引入
返回近似双曲余弦值。

另请参阅 cosh()。

native_cospi :数值的近似余弦值乘以 pi
float native_cospi(float v); 在 API 级别 21 中引入
float2 native_cospi(float2 v); 在 API 级别 21 中引入
float3 native_cospi(float3 v); 在 API 级别 21 中引入
float4 native_cospi(float4 v); 在 API 级别 21 中引入
half native_cospi(half v); 在 API 级别 24 中引入
half2 native_cospi(half2 v); 在 API 级别 24 中引入
half3 native_cospi(half3 v); 在 API 级别 24 中引入
half4 native_cospi(half4 v); 在 API 级别 24 中引入
返回 (v * pi) 的近似余弦值,其中 (v * pi) 以弧度为单位。

如需获取以度为单位的值的余弦值,请调用 cospi(v / 180.f)。

另请参阅 cospi()。

native_divide :近似除法
float native_divide(float left_vector, float right_vector); 在 API 级别 21 中引入
float2 native_divide(float2 left_vector, float2 right_vector); 在 API 级别 21 中引入
float3 native_divide(float3 left_vector, float3 right_vector); 在 API 级别 21 中引入
float4 native_divide(float4 left_vector, float4 right_vector); 在 API 级别 21 中引入
half native_divide(half left_vector, half right_vector); 在 API 级别 24 中引入
half2 native_divide(half2 left_vector, half2 right_vector); 在 API 级别 24 中引入
half3 native_divide(half3 left_vector, half3 right_vector); 在 API 级别 24 中引入
half4 native_divide(half4 left_vector, half4 right_vector); 在 API 级别 24 中引入
计算两个值的近似除法。

native_exp :e 近似为数字
float native_exp(float v); 在 API 级别 18 中引入
float2 native_exp(float2 v); 在 API 级别 18 中引入
float3 native_exp(float3 v); 在 API 级别 18 中引入
float4 native_exp(float4 v); 在 API 级别 18 中引入
half native_exp(half v); 在 API 级别 24 中引入
half2 native_exp(half2 v); 在 API 级别 24 中引入
half3 native_exp(half3 v); 在 API 级别 24 中引入
half4 native_exp(half4 v); 在 API 级别 24 中引入
快速近似体验

适用于从 -86.f 到 86.f 的输入。精度不会低于使用 16 位浮点值时预期的精度。

另请参阅 exp()。

native_exp10 :近似 10 为数字
float native_exp10(float v); 在 API 级别 18 中引入
float2 native_exp10(float2 v); 在 API 级别 18 中引入
float3 native_exp10(float3 v); 在 API 级别 18 中引入
float4 native_exp10(float4 v); 在 API 级别 18 中引入
half native_exp10(half v); 在 API 级别 24 中引入
half2 native_exp10(half2 v); 在 API 级别 24 中引入
half3 native_exp10(half3 v); 在 API 级别 24 中引入
half4 native_exp10(half4 v); 在 API 级别 24 中引入
快速近似实验 10。

该值适用于从 -37.f 到 37.f 的输入。精度不会低于使用 16 位浮点值时预期的精度。

另请参阅 exp10()。

native_exp2 :取 2 的近似值
float native_exp2(float v); 在 API 级别 18 中引入
float2 native_exp2(float2 v); 在 API 级别 18 中引入
float3 native_exp2(float3 v); 在 API 级别 18 中引入
float4 native_exp2(float4 v); 在 API 级别 18 中引入
half native_exp2(half v); 在 API 级别 24 中引入
half2 native_exp2(half2 v); 在 API 级别 24 中引入
half3 native_exp2(half3 v); 在 API 级别 24 中引入
half4 native_exp2(half4 v); 在 API 级别 24 中引入
快速近似实验 2。

适用于从 -125.f 到 125.f 的输入。精度不会低于使用 16 位浮点值时预期的精度。

另请参阅 exp2()。

native_expm1 :e 的近似值为 e 的取值减 1
float native_expm1(float v); 在 API 级别 21 中引入
float2 native_expm1(float2 v); 在 API 级别 21 中引入
float3 native_expm1(float3 v); 在 API 级别 21 中引入
float4 native_expm1(float4 v); 在 API 级别 21 中引入
half native_expm1(half v); 在 API 级别 24 中引入
half2 native_expm1(half2 v); 在 API 级别 24 中引入
half3 native_expm1(half3 v); 在 API 级别 24 中引入
half4 native_expm1(half4 v); 在 API 级别 24 中引入
返回近似值 (e ^ v) - 1。

另请参阅 expm1()。

native_hypot :近似斜边
float native_hypot(float a, float b); 在 API 级别 21 中引入
float2 native_hypot(float2 a, float2 b); 在 API 级别 21 中引入
float3 native_hypot(float3 a, float3 b); 在 API 级别 21 中引入
float4 native_hypot(float4 a, float4 b); 在 API 级别 21 中引入
half native_hypot(half a, half b); 在 API 级别 24 中引入
half2 native_hypot(half2 a, half2 b); 在 API 级别 24 中引入
half3 native_hypot(half3 a, half3 b); 在 API 级别 24 中引入
half4 native_hypot(half4 a, half4 b); 在 API 级别 24 中引入
返回近似的 native_sqrt(a * a + b * b)。

另请参阅 hypot()。

native_log :近似自然对数
float native_log(float v); 在 API 级别 18 中引入
float2 native_log(float2 v); 在 API 级别 18 中引入
float3 native_log(float3 v); 在 API 级别 18 中引入
float4 native_log(float4 v); 在 API 级别 18 中引入
half native_log(half v); 在 API 级别 24 中引入
half2 native_log(half2 v); 在 API 级别 24 中引入
half3 native_log(half3 v); 在 API 级别 24 中引入
half4 native_log(half4 v); 在 API 级别 24 中引入
快速近似记录。

对于非常接近零的值,该值不准确。

另请参阅 log()。

native_log10 :近似以 10 为底数的对数
float native_log10(float v); 在 API 级别 18 中引入
float2 native_log10(float2 v); 在 API 级别 18 中引入
float3 native_log10(float3 v); 在 API 级别 18 中引入
float4 native_log10(float4 v); 在 API 级别 18 中引入
half native_log10(half v); 在 API 级别 24 中引入
half2 native_log10(half2 v); 在 API 级别 24 中引入
half3 native_log10(half3 v); 在 API 级别 24 中引入
half4 native_log10(half4 v); 在 API 级别 24 中引入
快速近似 log10。

对于非常接近零的值,该值不准确。

另请参阅 log10()。

native_log1p :值加 1 的近似自然对数
float native_log1p(float v); 在 API 级别 21 中引入
float2 native_log1p(float2 v); 在 API 级别 21 中引入
float3 native_log1p(float3 v); 在 API 级别 21 中引入
float4 native_log1p(float4 v); 在 API 级别 21 中引入
half native_log1p(half v); 在 API 级别 24 中引入
half2 native_log1p(half2 v); 在 API 级别 24 中引入
half3 native_log1p(half3 v); 在 API 级别 24 中引入
half4 native_log1p(half4 v); 在 API 级别 24 中引入
返回 (v + 1.0f) 的近似自然对数

另请参阅 log1p()。

native_log2 :近似以 2 为底的对数
float native_log2(float v); 在 API 级别 18 中引入
float2 native_log2(float2 v); 在 API 级别 18 中引入
float3 native_log2(float3 v); 在 API 级别 18 中引入
float4 native_log2(float4 v); 在 API 级别 18 中引入
half native_log2(half v); 在 API 级别 24 中引入
half2 native_log2(half2 v); 在 API 级别 24 中引入
half3 native_log2(half3 v); 在 API 级别 24 中引入
half4 native_log2(half4 v); 在 API 级别 24 中引入
快速近似 log2。

对于非常接近零的值,该值不准确。

另请参阅 log2()。

native_powr :取指数的近似正数
float native_powr(float base, float exponent); 在 API 级别 18 中引入
float2 native_powr(float2 base, float2 exponent); 在 API 级别 18 中引入
float3 native_powr(float3 base, float3 exponent); 在 API 级别 18 中引入
float4 native_powr(float4 base, float4 exponent); 在 API 级别 18 中引入
half native_powr(半底数, 半数指数); 在 API 级别 24 中引入
half2 native_powr(half2 底数, half2 指数); 在 API 级别 24 中引入
half3 native_powr(half3 底数, half3 指数); 在 API 级别 24 中引入
half4 native_powr(half4 底数, half4 指数); 在 API 级别 24 中引入
参数
基础 必须介于 0.f 到 256.f 之间。对于非常接近零的值,该函数并不准确。
指数 必须介于 -15.f 到 15.f 之间。
快速近似(底数为 ^ 指数)。

另请参阅 powr()。

native_recip :近似倒数
float native_recip(float v); 在 API 级别 21 中引入
float2 native_recip(float2 v); 在 API 级别 21 中引入
float3 native_recip(float3 v); 在 API 级别 21 中引入
float4 native_recip(float4 v); 在 API 级别 21 中引入
half native_recip(half v); 在 API 级别 24 中引入
half2 native_recip(half2 v); 在 API 级别 24 中引入
half3 native_recip(half3 v); 在 API 级别 24 中引入
half4 native_recip(half4 v); 在 API 级别 24 中引入
返回值的近似倒数。

另请参阅 half_recip()。

native_rootn :近似 n 次根
float native_root(float v, int n); 在 API 级别 21 中引入
float2 native_root(float2 v, int2 n); 在 API 级别 21 中引入
float3 native_root(float3 v, int3 n); 在 API 级别 21 中引入
float4 native_root(float4 v, int4 n); 在 API 级别 21 中引入
half native_rootn(half v, int n); 在 API 级别 24 中引入
half2 native_rootn(half2 v, int2 n); 在 API 级别 24 中引入
half3 native_rootn(half3 v, int3 n); 在 API 级别 24 中引入
half4 native_rootn(half4 v, int4 n); 在 API 级别 24 中引入
计算某个值的近似 N 次方根。

另请参阅 rootn()。

native_rsqrt :平方根的近似倒数
float native_rsqrt(float v); 在 API 级别 21 中引入
float2 native_rsqrt(float2 v); 在 API 级别 21 中引入
float3 native_rsqrt(float3 v); 在 API 级别 21 中引入
float4 native_rsqrt(float4 v); 在 API 级别 21 中引入
half native_rsqrt(half v); 在 API 级别 24 中引入
half2 native_rsqrt(half2 v); 在 API 级别 24 中引入
half3 native_rsqrt(half3 v); 在 API 级别 24 中引入
half4 native_rsqrt(half4 v); 在 API 级别 24 中引入
返回近似值 (1 / sqrt(v))。

另请参阅 rsqrt()、half_rsqrt()。

native_sin :近似正弦值
float native_sin(float v); 在 API 级别 21 中引入
float2 native_sin(float2 v); 在 API 级别 21 中引入
float3 native_sin(float3 v); 在 API 级别 21 中引入
float4 native_sin(float4 v); 在 API 级别 21 中引入
half native_sin(half v); 在 API 级别 24 中引入
half2 native_sin(half2 v); 在 API 级别 24 中引入
half3 native_sin(half3 v); 在 API 级别 24 中引入
half4 native_sin(half4 v); 在 API 级别 24 中引入
返回以弧度表示的角度的近似正弦值。

另请参阅 sin()。

native_sincos :近似正弦和余弦
float native_sincos(float v, float* cos); 在 API 级别 21 中引入
float2 native_sincos(float2 v, float2* cos); 在 API 级别 21 中引入
float3 native_sincos(float3 v, float3* cos); 在 API 级别 21 中引入
float4 native_sincos(float4 v, float4* cos); 在 API 级别 21 中引入
half native_sincos(half v, half* cos); 在 API 级别 24 中引入
half2 native_sincos(half2 v, half2* cos); 在 API 级别 24 中引入
half3 native_sincos(half3 v, half3* cos); 在 API 级别 24 中引入
half4 native_sincos(half4 v, half4* cos); 在 API 级别 24 中引入
参数
v 传入值(以弧度为单位)。
cos *cos 将设置为余弦值。
返回
正弦。
返回数值的近似正弦和余弦。

另请参阅 sincos()。

native_sinh :近似双曲正弦
float native_sinh(float v); 在 API 级别 21 中引入
float2 native_sinh(float2 v); 在 API 级别 21 中引入
float3 native_sinh(float3 v); 在 API 级别 21 中引入
float4 native_sinh(float4 v); 在 API 级别 21 中引入
half native_sinh(half v); 在 API 级别 24 中引入
half2 native_sinh(half2 v); 在 API 级别 24 中引入
half3 native_sinh(half3 v); 在 API 级别 24 中引入
half4 native_sinh(half4 v); 在 API 级别 24 中引入
返回指定值的近似双曲正弦值(以弧度表示)。

另请参阅 sinh()。

native_sinpi :数值乘以 pi 的近似正弦值
float native_sinpi(float v); 在 API 级别 21 中引入
float2 native_sinpi(float2 v); 在 API 级别 21 中引入
float3 native_sinpi(float3 v); 在 API 级别 21 中引入
float4 native_sinpi(float4 v); 在 API 级别 21 中引入
half native_sinpi(half v); 在 API 级别 24 中引入
half2 native_sinpi(half2 v); 在 API 级别 24 中引入
half3 native_sinpi(half3 v); 在 API 级别 24 中引入
half4 native_sinpi(half4 v); 在 API 级别 24 中引入
返回 (v * pi) 的近似正弦值,其中 (v * pi) 以弧度为单位。

如需获取以度为单位的值的正弦值,请调用 sinpi(v / 180.f)。

另请参阅 sinpi()。

native_sqrt :近似平方根
float native_sqrt(float v); 在 API 级别 21 中引入
float2 native_sqrt(float2 v); 在 API 级别 21 中引入
float3 native_sqrt(float3 v); 在 API 级别 21 中引入
float4 native_sqrt(float4 v); 在 API 级别 21 中引入
half native_sqrt(half v); 在 API 级别 24 中引入
half2 native_sqrt(half2 v); 在 API 级别 24 中引入
half3 native_sqrt(half3 v); 在 API 级别 24 中引入
half4 native_sqrt(half4 v); 在 API 级别 24 中引入
返回近似 sqrt(v)。

另请参阅 sqrt()、half_sqrt()。

native_tan :近似正切
float native_tan(float v); 在 API 级别 21 中引入
float2 native_tan(float2 v); 在 API 级别 21 中引入
float3 native_tan(float3 v); 在 API 级别 21 中引入
float4 native_tan(float4 v); 在 API 级别 21 中引入
half native_tan(half v); 在 API 级别 24 中引入
half2 native_tan(half2 v); 在 API 级别 24 中引入
half3 native_tan(half3 v); 在 API 级别 24 中引入
half4 native_tan(half4 v); 在 API 级别 24 中引入
返回以弧度表示的角度的近似正切值。

native_tanh :近似双曲正切
float native_tanh(float v); 在 API 级别 21 中引入
float2 native_tanh(float2 v); 在 API 级别 21 中引入
float3 native_tanh(float3 v); 在 API 级别 21 中引入
float4 native_tanh(float4 v); 在 API 级别 21 中引入
half native_tanh(half v); 在 API 级别 24 中引入
half2 native_tanh(half2 v); 在 API 级别 24 中引入
half3 native_tanh(half3 v); 在 API 级别 24 中引入
half4 native_tanh(half4 v); 在 API 级别 24 中引入
返回数值的近似双曲正切值。

另请参阅 tanh()。

native_tanpi :数值乘以 pi 的近似正切值
float native_tanpi(float v); 在 API 级别 21 中引入
float2 native_tanpi(float2 v); 在 API 级别 21 中引入
float3 native_tanpi(float3 v); 在 API 级别 21 中引入
float4 native_tanpi(float4 v); 在 API 级别 21 中引入
half native_tanpi(half v); 在 API 级别 24 中引入
half2 native_tanpi(half2 v); 在 API 级别 24 中引入
half3 native_tanpi(half3 v); 在 API 级别 24 中引入
half4 native_tanpi(half4 v); 在 API 级别 24 中引入
返回 (v * pi) 的近似正切值,其中 (v * pi) 以弧度为单位。

如需获取以度为单位的值的正切值,请调用 tanpi(v / 180.f)。

另请参阅 tanpi()。

nextafter :下一个浮点数
float nextafter(float v, float target);
float2 nextafter(float2 v, float2 target);
float3 nextafter(float3 v, float3 target);
float4 nextafter(float4 v, float4 target);
half nextafter(half v, half target); 在 API 级别 24 中引入
half2 nextafter(half2 v, half2 target); 在 API 级别 24 中引入
half3 nextafter(half3 v, half3 target); 在 API 级别 24 中引入
half4 nextafter(half4 v, half4 target); 在 API 级别 24 中引入
返回从 v 指向目标的下一个可表示浮点数。

在 rs_fp_relaxed 模式下,反规范化的输入值可能不会产生下一个反规范化的值,因为在放宽模式下支持反规范化值是可选的。

pow :基数为指数的幂
float pow(float base, float exponent);
float2 pow(float2 base, float2 exponent);
float3 pow(float3 base, float3 exponent);
float4 pow(float4 base, float4 exponent);
half pow(半底, 半指数); 在 API 级别 24 中引入
half2 pow(half2 底数, half2 指数); 在 API 级别 24 中引入
half3 pow(half3 底数, half3 指数); 在 API 级别 24 中引入
half4 pow(half4 底数, half4 指数); 在 API 级别 24 中引入
返回求底数的幂指数(即底数 ^ 指数)。

pown() 和 powr() 类似。pown() 可接受整数指数。powr() 假定底数为非负数。

pown :基数为整数指数
float pown(float base, int exponent);
float2 pown(float2 底数, int2 指数);
float3 pown(float3 底数, int3 指数);
float4 pown(float4 底数, int4 指数);
half pown(half base, int exponent); 在 API 级别 24 中引入
half2 pown(half2 底数, int2 指数); 在 API 级别 24 中引入
half3 pown(half3 底数, int3 指数); 在 API 级别 24 中引入
half4 pown(half4 底数, int4 指数); 在 API 级别 24 中引入
返回求底数的幂指数(即底数 ^ 指数)。

pow() 和 powr() 类似。两者都采用浮点指数。powr() 还假定底数为非负数。

powr :以正数作为指数的底数
float powr(float base, float exponent);
float2 powr(float2 base, float2 exponent);
float3 powr(float3 base, float3 exponent);
float4 powr(float4 base, float4 exponent);
half powr(半底, 半指数); 在 API 级别 24 中引入
half2 powr(half2 底数, half2 指数); 在 API 级别 24 中引入
half3 powr(half3 底数, half3 指数); 在 API 级别 24 中引入
half4 powr(half4 底数, half4 指数); 在 API 级别 24 中引入
返回指定的幂指数(即底数 ^ 指数)的底数。底数必须 >= 0。

pow() 和 pown() 类似。两者都没有关于底数的任何假设。pow() 采用浮点指数,而 pown() 采用整数。

另请参阅 native_powr()。

弧度 :将角度转换为弧度
float radians(float v);
float2 弧度(float2 v);
float3 弧度(float3 v);
float4 弧度(float4 v);
half 弧度(half v); 在 API 级别 24 中引入
half2 弧度(half2 v); 在 API 级别 24 中引入
half3 弧度(half3 v); 在 API 级别 24 中引入
half4 弧度(half4 v); 在 API 级别 24 中引入
从角度转换为弧度。

remainder :除法的余数
floatfloat(float numerator, float denominator);
float2 fill(float2 分子, float2 分母);
float3 fill(float3 分子, float3 分母);
float4 fill(float4 分子, float4 分母);
half 余数(分子,半分母); 在 API 级别 24 中引入
half2 余数(half2 分子,half2 分母); 在 API 级别 24 中引入
half3 余数(half3 分子,half3 分母); 在 API 级别 24 中引入
half4 余数(half4 分子,half4 分母); 在 API 级别 24 中引入
返回(分子 / 分母)的余数,其中商数向最接近的整数四舍五入。

函数 fmod() 与此类似,但会向最接近的整数四舍五入。例如,fmod(-3.8f, 2.f) 返回 -1.8f (-3.8f - -1.f * 2.f),而 remainder(-3.8f, 2.f) 返回 0.2f (-3.8f - -2.f * 2.f)。

remquo :除法的余数和商
float remquo(浮点分子, 浮点分母, 整数* 商);
float2 remquo(float2 分子, float2 分母, int2* 商数);
float3 remquo(float3 分子, float3 分母, int3* 商数);
float4 remquo(float4 分子, float4 分母, int4* 商数);
half remquo(half 分子, half 分母, int* 商); 在 API 级别 24 中引入
half2 remquo(half2 分子, half2 分母, int2* 商); 在 API 级别 24 中引入
half3 remquo(half3 分子, half3 分母, int3* 商); 在 API 级别 24 中引入
half4 remquo(half4 分子,half4 分母, int4* 商); 在 API 级别 24 中引入
参数
分子 分子。
分母 分母。
商 *商将设置为整数商。
返回
余数,仅针对低 3 位精确。
返回商和余数(分子 / 分母)。

只有商数的符号和最低三位可以保证准确。

此函数对于实现定期函数非常有用。商的低三位表示象限,余数为象限内的距离。例如,sin(x) 的实现可以调用 remquo(x, PI / 2.f, &quadrant) 将非常大的 x 值缩减为有限范围内的某个值。

示例:remquo(-23.5f, 8.f, &quot) 将商数的最低三位设为 3 且符号负数。它返回 0.5f。

rint :舍入到偶数
float rint(float v);
float2 rint(float2 v);
float3 rint(float3 v);
float4 rint(float4 v);
half rint(half v); 在 API 级别 24 中引入
half2 rint(half2 v); 在 API 级别 24 中引入
half3 rint(half3 v); 在 API 级别 24 中引入
half4 rint(half4 v); 在 API 级别 24 中引入
四舍五入为最接近的整数值。

rint() 将一半的值四舍五入为偶数。例如,rint(0.5f) 会返回 0.f,而 rint(1.5f) 会返回 2.f。同样,rint(-0.5f) 会返回 -0.f,而 rint(-1.5f) 会返回 -2.f。

round() 与此类似,但会远离 0。trunc() 会截断十进制分数。

rootn :第 N 个根
float rootn(float v, int n);
float2 rootn(float2 v, int2 n);
float3 rootn(float3 v, int3 n);
float4 rootn(float4 v, int4 n);
half rootn(half v, int n); 在 API 级别 24 中引入
half2 rootn(half2 v, int2 n); 在 API 级别 24 中引入
half3 rootn(half3 v, int3 n); 在 API 级别 24 中引入
half4 rootn(half4 v, int4 n); 在 API 级别 24 中引入
计算某个值的 N 次方根。

另请参阅 native_rootn()。

round :向远离 0 的方向舍入
float round(float v);
float2 round(float2 v);
float3 round(float3 v);
float4 round(float4 v);
half round(half v); 在 API 级别 24 中引入
half2 round(half2 v); 在 API 级别 24 中引入
half3 round(half3 v); 在 API 级别 24 中引入
half4 round(half4 v); 在 API 级别 24 中引入
四舍五入到最接近的整数值。

round() 向远离零的值舍入。例如,round(0.5f) 会返回 1.f,而 round(1.5f) 会返回 2.f。同样,round(-0.5f) 会返回 -1.f,而 round(-1.5f) 会返回 -2.f。

rint() 与此类似,但会将一半的值四舍五入为偶数。trunc() 会截断十进制分数。

rsClamp :将值限制在某个范围内
char rsClamp(char amount, char low, char high);
int rsClamp(int amount, int low, int high);
Shorts rsClamp(short amount, short amount, short, short, short)、
uchar rsClamp(uchar amount, uchar low, uchar high);
uint rsClamp(uint amount, uint low, uint high);
ushort rsClamp(ushort amount, ushort low, ushort high);
参数
金额 要限定的值。
低 下限。
高 上限。
已弃用。请改用 clamp()。

限定一个值,使其介于低值和高值之间。

rsFrac :返回浮点数的小数部分
float rsFrac(float v);
已弃用。请改用 fract()。

返回浮点数的小数部分

rsRand :伪随机数
float rsRand(float max_value);
float rsRand(float min_value, float max_value);
int rsRand(int max_value);
int rsRand(int min_value, int max_value);
返回 0(或 min_value)和 max_malue 之间的随机值。

rsqrt :平方根的倒数
float rsqrt(float v);
float2 rsqrt(float2 v);
float3 rsqrt(float3 v);
float4 rsqrt(float4 v);
half rsqrt(half v); 在 API 级别 24 中引入
half2 rsqrt(half2 v); 在 API 级别 24 中引入
half3 rsqrt(half3 v); 在 API 级别 24 中引入
half4 rsqrt(half4 v); 在 API 级别 24 中引入
返回 (1 / sqrt(v))。

另请参阅 half_rsqrt()、native_rsqrt()。

sign :值的符号
float sign(float v);
float2 符号(float2 v);
float3 符号(float3 v);
float4 符号(float4 v);
half 符号(half v); 在 API 级别 24 中引入
half2 符号(half2 v); 在 API 级别 24 中引入
half3 符号(half3 v); 在 API 级别 24 中引入
half4 符号(half4 v); 在 API 级别 24 中引入
返回数值的符号。

if (v < 0) return -1.f; else if (v > 0) return 1.f; else return 0.f;

sin :正弦
float sin(float v);
float2 sin(float2 v);
float3 sin(float3 v);
float4 sin(float4 v);
half sin(half v); 在 API 级别 24 中引入
half2 sin(half2 v); 在 API 级别 24 中引入
half3 sin(half3 v); 在 API 级别 24 中引入
half4 sin(half4 v); 在 API 级别 24 中引入
返回以弧度表示的角度的正弦值。

另请参阅 native_sin()。

正弦 :正弦和余弦
float sincos(float v, float* cos);
float2 sincos(float2 v, float2* cos);
float3 sincos(float3 v, float3* cos);
float4 sincos(float4 v, float4* cos);
half sincos(half v, half* cos); 在 API 级别 24 中引入
half2 sincos(half2 v, half2* cos); 在 API 级别 24 中引入
half3 sincos(half3 v, half3* cos); 在 API 级别 24 中引入
half4 sincos(half4 v, half4* cos); 在 API 级别 24 中引入
参数
v 传入值(以弧度为单位)。
cos *cos 将设置为余弦值。
返回
v.
返回数值的正弦和余弦。

另请参阅 native_sincos()。

sinh :双曲正弦
float sinh(float v);
float2 sinh(float2 v);
float3 sinh(float3 v);
float4 sinh(float4 v);
half sinh(half v); 在 API 级别 24 中引入
half2 sinh(half2 v); 在 API 级别 24 中引入
half3 sinh(half3 v); 在 API 级别 24 中引入
half4 sinh(half4 v); 在 API 级别 24 中引入
返回 v 的双曲正弦值,其中 v 以弧度为单位。

另请参阅 native_sinh()。

sinpi :数值的正弦与 pi 的乘积
float sinpi(float v);
float2 sinpi(float2 v);
float3 sinpi(float3 v);
float4 sinpi(float4 v);
half sinpi(half v); 在 API 级别 24 中引入
half2 sinpi(half2 v); 在 API 级别 24 中引入
half3 sinpi(half3 v); 在 API 级别 24 中引入
half4 sinpi(half4 v); 在 API 级别 24 中引入
返回 (v * pi) 的正弦值,其中 (v * pi) 以弧度为单位。

如需获取以度为单位的值的正弦值,请调用 sinpi(v / 180.f)。

另请参阅 native_sinpi()。

sqrt :平方根
float sqrt(float v);
float2 sqrt(float2 v);
float3 sqrt(float3 v);
float4 sqrt(float4 v);
half sqrt(half v); 在 API 级别 24 中引入
half2 sqrt(half2 v); 在 API 级别 24 中引入
half3 sqrt(half3 v); 在 API 级别 24 中引入
half4 sqrt(half4 v); 在 API 级别 24 中引入
返回数值的平方根。

另请参阅 half_sqrt()、native_sqrt()。

step :如果小于值,则为 0,否则为 1
float step(float Edge, float v);
float2 step(float edge, float2 v); 在 API 级别 21 中引入
float2 step(float2 edge, float v);
float2 step(float2 edge, float2 v);
float3 step(float edge, float3 v); 在 API 级别 21 中引入
float3 step(float3 edge, float v);
float3 step(float3 edge, float3 v);
float4 step(float edge, float4 v); 在 API 级别 21 中引入
float4 step(float4 edge, float v);
float4 step(float4 edge, float4 v);
半步(半边缘, 半 v); 在 API 级别 24 中引入
half2 步(半边缘, half2 v); 在 API 级别 24 中引入
half2 step(half2 Edge, half v); 在 API 级别 24 中引入
half2 step(half2 Edge, half2 v); 在 API 级别 24 中引入
half3 步(半边缘, half3 v); 在 API 级别 24 中引入
half3 step(half3 Edge, half v); 在 API 级别 24 中引入
half3 step(half3 Edge, half3 v); 在 API 级别 24 中引入
half4 步(半边缘, half4 v); 在 API 级别 24 中引入
half4 step(half4 Edge, half v); 在 API 级别 24 中引入
half4 步(half4 Edge, half4 v); 在 API 级别 24 中引入
如果 v < Edge 为 0.f,否则返回 1.f。

这有助于在不使用循环和分支指令的情况下创建条件计算。例如,您可以改用 step(a, b) * atan2(a, b),而不是计算向量的相应元素的 (a[i] < b[i]) ? 0.f : atan2(a[i], b[i])。

tan :正切
float tan(float v);
float2 tan(float2 v);
float3 tan(float3 v);
float4 tan(float4 v);
half tan(half v); 在 API 级别 24 中引入
half2 tan(half2 v); 在 API 级别 24 中引入
half3 tan(half3 v); 在 API 级别 24 中引入
half4 tan(half4 v); 在 API 级别 24 中引入
返回以弧度表示的角度的正切值。

另请参阅 native_tan()。

tanh :双曲正切
float tanh(float v);
float2 tanh(float2 v);
float3 tanh(float3 v);
float4 tanh(float4 v);
half tanh(half v); 在 API 级别 24 中引入
half2 tanh(half2 v); 在 API 级别 24 中引入
half3 tanh(half3 v); 在 API 级别 24 中引入
half4 tanh(half4 v); 在 API 级别 24 中引入
返回数值的双曲正切值。

另请参阅 native_tanh()。

tanpi :数值与 pi 的乘积的正切值
float tanpi(float v);
float2 tanpi(float2 v);
float3 tanpi(float3 v);
float4 tanpi(float4 v);
half tanpi(half v); 在 API 级别 24 中引入
half2 tanpi(half2 v); 在 API 级别 24 中引入
half3 tanpi(half3 v); 在 API 级别 24 中引入
half4 tanpi(half4 v); 在 API 级别 24 中引入
返回 (v * pi) 的正切值,其中 (v * pi) 以弧度为单位进行测量。

如需获取以度为单位的值的正切值,请调用 tanpi(v / 180.f)。

另请参阅 native_tanpi()。

tgamma :Gamma 函数
float tgamma(float v);
float2 tgamma(float2 v);
float3 tgamma(float3 v);
float4 tgamma(float4 v);
half tgamma(half v); 在 API 级别 24 中引入
half2 tgamma(half2 v); 在 API 级别 24 中引入
half3 tgamma(half3 v); 在 API 级别 24 中引入
half4 tgamma(half4 v); 在 API 级别 24 中引入
返回相应值的伽马函数。

另请参阅 lgamma()。

trunc :截断浮点
float trunc(float v);
float2 trunc(float2 v);
float3 trunc(float3 v);
float4 trunc(float4 v);
half trunc(half v); 在 API 级别 24 中引入
half2 trunc(half2 v); 在 API 级别 24 中引入
half3 trunc(half3 v); 在 API 级别 24 中引入
half4 trunc(half4 v); 在 API 级别 24 中引入
通过截断将四舍五入为积分。

例如,trunc(1.7f) 会返回 1.f,而 trunc(-1.7f) 会返回 -1.f。

请参阅 rint() 和 round() 了解其他舍入选项。

本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。

最后更新时间 (UTC):2023-10-18。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

五一编程

程序之路有我与你同行

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值