[英]remquo: argument reduction?
In the C99 spec it says of remquo: 在C99规范中它说的是remquo:
The remquo functions are intended for implementing argument reductions which can exploit a few low-order bits of the quotient.
remquo函数用于实现参数减少,这可以利用商的一些低阶位。 Note that x may be so large in magnitude relative to y that an exact representation of the quotient is not practical.
注意,x相对于y的幅度可能如此之大,以至于商的精确表示是不实际的。
What is an "argument reduction" in this context, and what is an example of one that can exploit a few low-order bits of the quotient? 在这种情况下什么是“参数减少”,什么是可以利用商的一些低阶位的例子?
Argument reduction means mapping the argument of a periodic function into the canonical period (for example, (-π,π] or similar). If you used π/2 as the divisor, the low bits of the quotient would be sufficient for determining the right sign/etc. for trig functions. 参数减少意味着将周期函数的参数映射到规范周期(例如,( - π,π)或类似)。如果使用π/ 2作为除数,则商的低位足以确定对于trig函数的右符号/ etc。
Unfortunately, however, remquo
is useless for implementing standard trigonometric argument reduction, because π
is irrational; 然而不幸的是,
remquo
对于实现标准三角参数减少是没有用的,因为π
是不合理的; reducing large arguments modulo an approximation of π will give you results with no significant bits , ie all error. 减少大的参数模数π的近似值将给出没有有效位的结果,即所有误差。
If however you're writing a function f(x)
defined as sin(πx) or similar, the period is now exactly representable in floating point, and remquo
can do exactly what you need, whereas calling sin(2*M_PI*x)
directly will give results with no significant bits (ie all error) when x
is large. 但是,如果您正在编写定义为sin(πx)或类似函数的函数
f(x)
,则现在可以在浮点中精确表示句点,并且remquo
可以完全满足您的需要,而调用sin(2*M_PI*x)
当x
很大时,直接给出没有有效位(即所有错误)的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.