Re: pow(3): warn against ineffecient uses?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Joachim Wuttke:

> Maybe it would be appropriate to warn against inefficient
> uses of the function pow. To make a very first proposal
> for a paragraph to be added to pow(3):
>
> In time-critical code, pow with small integer or simple
> fractional exponents should be avoided in favor of
> straightforward multiplication, division or square or
> cubic roots: prefer x*x over pow(x,2), 1/x over pow(x,-1),
> sqrt(x) over pow(x,0.5), or cbrt(x*x) over pow(x,2.0/3).

I don't think transforming pow (x, 2.0 / 3) to cbrt (x * x) is correct
because the result is not correctly rounded.  I'm not sure if it is a
good idea to add those examples to the manual page without discussing
the cases where the transformations might not be valid.

If GCC does not handle some of the common cases from real-world code,
that could be fixed in GCC (and GCC can do more transformations under
-ffast-math, too).
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux