To resurrect an old thread... On 2014-Mar-25 17:22:05 -0700, Steve Kargl <s...@troutmask.apl.washington.edu> wrote: >It appears that clang developers have chosen the naive >complex division algorithm, and it does not matter whether >one turns CX_LIMITED_RANGE on or off. This means that >if one uses clang with complex types, one must be careful >with the range of values allowed in complex division. In >other words, implementation of complex libm routines cannot >use complex data types and must fallback to a decomposition >into real and imaginary components.
Whilst the fixes don't seem to have made it into FreeBSD yet, it seems that this has been improved in recent Clang/LLVM - see http://reviews.llvm.org/D5698, committed as rL219557. I re-implemented their division algorithm in C and checked it against the algorithms listed in http://arxiv.org/pdf/1210.4539v2.pdf. Whilst it fails on same of the difficult values listed in that paper, when faced with a range of random arguments, it seems to perform better[*] than the "robust" algorithm. I didn't look closely at the multiplication algorithm but, based on a quick look, it seems that it's still susceptable to spurious overflows. [*] or at least closer to the result given by the naive algorithm using x87 long doubles. -- Peter Jeremy
pgpvKBy2_8dn6.pgp
Description: PGP signature