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

Fw: [IEEE P1788 modal subgroup]: Re: Division in Draft Standard Text, V02.1 - interval pairs



Michel Hack>>      Divp(xx, yy)  =def  Div(xx, (yy Intersect [0, +oo]))
Michel Hack>>      Divn(xx, yy)  =def  Div(xx, (yy Intersect [-oo, 0]))


Arnold Neumaier>  1. In a program, division with gaps must always be called as a
Arnold Neumaier>  function, whereas ordinary division (divideHull) will usually
Arnold Neumaier>  be called by overloading.


An alternative that most programming language bindings can include is a divide function that returns a structure or array containing two intervals. Some languages could also include an overloaded divide operator that returns a pair of intervals.

With either, there needs to be a way to extract each of the two intervals. That could be by structure member (.negative and .positive), by array element ([0] and [1]), or both ways.

With either, one advantage is that the compiler doesn't need to find pairs of calls and optimize them into one.

If you want to handle both results the obvious way is to store the interval pair into a variable, then write code to handle both parts.

A possible improvement is to define all the other interval operations on integer pairs, so you could write code like

Interval a, b, c;
a = ...
b = ...
c = ...
IntervalPair x = a/b + c;

The "a/b" would return an IntervalPair, the "+ c" would add an IntervalPair left side to an Interval right side producing an IntervalPair, and the "x =" would store the IntervalPair "a/b + c" into IntervalPair variable x.

Allowing a divide on IntervalPair s would only be valid if you defined an IntervalQuad type and operations, and so on, and I wouldn't recommend that, but pairs could be useful.

Arnold Neumaier>  2. Similarly, one may provide perhaps implementations of inverse
Arnold Neumaier>  with gap, atan2 with gap, and inverse trigonometric or hyperbolic
Arnold Neumaier>  functions with gaps.


Those functions could also produce IntervalPair results.

- Ian McIntosh IBM Canada Lab Compiler Back End Support and Development


Inactive hide details for Arnold Neumaier ---03/17/2010 04:43:30 AM---Michel Hack wrote: > I agree with Jürgen's suggestion thaArnold Neumaier ---03/17/2010 04:43:30 AM---Michel Hack wrote: > I agree with Jürgen's suggestion that there should be an easy way to

From:

Arnold Neumaier <Arnold.Neumaier@xxxxxxxxxxxx>

To:

Ian McIntosh/Toronto/IBM@IBMCA

Date:

03/17/2010 04:43 AM

Subject:

Re: Division in Draft Standard Text, V02.1





Michel Hack wrote:
> I agree with Jürgen's suggestion that there should be an easy way to
> obtain the two disjoint intervals resulting from complete division by
> an interval containing zero.  Here is a possibility:
>
>     Divp(xx, yy)  =def  Div(xx, (yy Intersect [0, +oo]))
>     Divn(xx, yy)  =def  Div(xx, (yy Intersect [-oo, 0]))
>
> A compiler may recognise when both are used near each other for the
> same arguments, and perform a single division, just as compilers tend
> to recognize joint use of div (/) and rem (%) integer operations.

This is a useful way of presenting the solution set of division.
The Vienna proposal gives another option in Section 5.7:

5.7. Division with gap
There is an operation divisionWithGap(xx,yy) that returns for any two
intervals xx=[l,u] and yy=[l’,u’] the interval zz=divideHull(xx,yy)
(see Section 3.11) and the gap gg, which is
- Empty if xx contains 0 or yy does not contain 0,
- Entire if xx or yy is Empty, and
- otherwise the widest subinterval whose interior cannot be
realized as quotient x/y with x in xx, y in yy.
Remarks.
1. In a program, division with gaps must always be called as a
function, whereas ordinary division (divideHull) will usually
be called by overloading.
2. Similarly, one may provide perhaps implementations of inverse
with gap, atan2 with gap, and inverse trigonometric or hyperbolic
functions with gaps.


Arnold Neumaier