Implement the "unum" representation in D ?
Anthony Di Franco via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 14 19:16:49 PDT 2015
On Wednesday, 22 July 2015 at 20:41:42 UTC, jmh530 wrote:
> On Wednesday, 22 July 2015 at 19:28:41 UTC, Andrei Alexandrescu
> wrote:
>> On 7/13/15 1:20 AM, Nick B wrote:
>>
>> All we can do now, with our limited resources, is to keep an
>> eye on developments and express cautious interest. If someone
>> able and willing comes along with a unum library for D, that
>> would be great.
>>
>
> The book has quite a bit of Mathematica code at the end. A
> first pass at a unum library could probably just involve
> porting that to D.
Here is a Python port of the Mathematica code which is that much
closer to D:
https://github.com/jrmuizel/pyunum
Regardless of whether the representation used follows the unum
bitwise format proposed in the book, having the semantics of
interval arithmetic that keeps proper account of amount of
precision, and exact values vs. open/closed ended intervals on
the extended real line would be quite valuable for verified
computation and for how it enables simple root finding /
optimization / differential equation solving via search, and
could build on hard float directly andor an extended precision
float library such as MPFR to keep performance close to raw
floats.
The bitwise format is intended to fit as much data as possible
through the time-energy bottleneck between main memory and the
processor. This would clearly be of great value if the format
were supported in hardware but of less clear value otherwise. The
semantic improvements would be quite welcome regardless. They go
much further than best practices with floats to put error bounds
on computations, handle over/underflow and infinity correctly,
and keep algorithms correct by default. We might also consider
small semantic improvements if not rigidly bound by the proposed
formats and the need to implement in hardware, such as having
division by an interval including zero return the union of the
results from the intervals on either side of the zero as well as
NaN (1-D intervals are strictly represented as the convex hull of
at most two points in the proposed format, so an interval such as
this made of a sentinel value unified with two disjoint
intervals, though it has better semantics, is not supported).
Anthony
More information about the Digitalmars-d
mailing list