[std-interval] list of functions for intervals

Sylvain Pion Sylvain.Pion at sophia.inria.fr
Sun May 28 22:44:14 PDT 2006


Dear all,

We have been thinking about the list of floating-point functions
which we could propose an interval version for.
More precisely, we have looked at the current list of floating-point
functions from the latest draft of C++0x
(http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2006/n2009.pdf).

As a starting point, here is the list of functions coming from
<cmath> which operate over floating-point types (page 794):

abs       cosh   fmod     logb       rint
acos      erf    frexp    lrint      round
acosh     erfc   hypot    lround     scalbln
asin      exp    ilogb    modf       scalbn
asinh     exp2   ldexp    nan        sin
atan      expm1  lgamma   nearbyint  sinh
atan2     fabs   llrint   nextafter  sqrt
atanh     fdim   llround  nexttoward tan
cbrt      floor  log      pow        tanh
ceil      fma    log10    remainder  tgamma
copysign  fmax   log1p    remquo     trunc
cos       fmin   log2
fpclassify  isgreaterequal  islessequal    isnan     isunordered
isfinite    isinf           islessgreater  isnormal  signbit
isgreater   isless

A description of those functions can be found in the following
almost-final draft of the ISO C99 standard:
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n869/n869.pdf.gz


We suggest to select the following functions for std::interval<T>:
abs       cosh     logb
acos
acosh     hypot    scalbln
asin      exp      scalbn
asinh     exp2     ldexp      sin
atan      expm1    sinh       cos
atan2     fabs     sqrt
atanh     fdim     tan
cbrt      log      pow        tanh
fma       log10    log2
fmin      fmax     log1p
erf       erfc     lgamma     tgamma


Notes:
- fmin, fmax : we propose to return interval<T>, while we could
   return double (the lower or upper bound), but we choose the
   consistency with the treatment done to other functions, and
   it is easy to extract the lower/upper bound of the resulting
   interval anyway.
- erf, erfc, lgamma, tgamma: we are not sure if interval versions
   of these functions would be useful.
- atan2, acos, asin: the range of the result interval should
   probably be specified differently than for floating-point
   (where it must be in [-pi,+pi] for atan2 for example).


We therefore propose to exclude the following functions,
for the following reasons:
- fmod, remainder, remquo : we do not see them useful for intervals.
   We did not find any good specification for interval counterparts.
- frexp, ilogb : because they would have to return an interval<int>,
   (or refer to it for ilogb) and they are probably not useful.
- copysign : no good specification found for intervals.
- rint, lrint, llrint, nearbyint, round, lround, llround, trunc,
   modf, floor, ceil:
   we believe that there is no typical use for intervals.
   It is however probably easy to define and implement them over
   intervals.
   In general, functions relating to Z (integers) probably do not make
   much sense for intervals, as intervals are expected to be used in a
   more numerical context.
- nan : does not make sense.
- nextafter, nexttoward : if an interval needs to be enlarged by
   one ulp (or more), then one can simply add interval<T>::min()
   (the smallest interval strictly containing 0 but not as bounds).
- fpclassify  isgreaterequal  islessequal    isnan     isunordered
   isfinite    isinf           islessgreater  isnormal  signbit
   isgreater   isless :
   do not make sense for intervals, as the treatment of NaNs,
   comparisons, infinities is different from what floating-point
   types do.



What do you think of these lists ?
Is something important excluded ?
Is there anything that should be excluded ?

Note that existing implementations do not necessarily offer all
proposed functions, so any comment on the implementation
difficulty (for interval<float>, interval<double> and
interval<long double>) would be appreciated.


-- 
Sylvain


More information about the Std-interval mailing list