Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: [Fwd: ISL: M0010.02 Elementary Functions]



Dan Zuras Intervals wrote:
  - rSqrt. Maybe I just don't know what application crucially
    requires the extra ulp of accuracy this may give compared
    with doing 1/sqrt(xx). At present I support moving it to
    "recommended", but am persuadable.

The reason for this to exist is to provide normalization
in homogeneous transformations.  Things that take
(x, y, z, w) into (x, y, z, w)/sqrt(x^2 + y^2 + z^2 + w^2)
by doing (x, y, z, w)*rSqrt(x^2 + y^2 + z^2 + w^2).

It is commonly used in graphics & is there more for speed
than accuracy (to avoid the often not parallizable divide).

The last ULP is seldom needed in graphics.  An interesting
exception is tracing a ray as it bounces off of multiple
quadradic surfaces as between two reflecting spheres.  But
even in this case, correct rounding only buys you
consistency not correctness.  And the eye cannot see the
difference if the calculation is at least double precision.

I agree this could go into the recommended list but Nate
is the expert in this area.  Nate: what are your thoughts?

I don't have strong opinion one way or the other, although I agree with all Dan's reasons why its a useful primitve. Its worth noting that rsqrt(x) is already enshrined as a standard function in the major shading languages for computer graphics, i.e., OpenGL, Cg, etc. I believe this is because most GPUs already support this primitive in hardware.




  - Nate Hayes makes a good point arguing for "nint" and "trunc" in
    addition to "ceil" and "floor", so that all four rounding modes
    are catered for.

Agreed.

My personal preference would also be to make these required
rather than recommended...

FWIW:

The floor, ceil, nint and trunc are all standard routines in the above-mentioned shading language standards, too, as well as abs and sign.

A few variants of these basic functions, such as clamp, step, repeat, fraction, etc. are also parts of these various standards and typically implemented as (or map to) hardware primitives on the GPU. However, these functions may be too specialized to the field of computer graphics to be worth considering for 1788.

But floor, ceil, nint, trunc, abs and sign I think are general enough to include in 1788, and simple enough it probably isn't any harm to make them required. As I mentioned, I don't have strong feelings on this, but that's my .02.

Nate