|
From: | Juergen Sauermann |
Subject: | Re: [Bug-apl] Strange domain error |
Date: | Wed, 11 Jun 2014 18:58:48 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 |
Hi Blake,
GNU APL normally chooses the generic way. The reason is simple: there are 3x3 = 9 combinations of INT REAL and COMPLEX arguments of a dyadic functions (or 3×3×3=27 if you also count the axis). With 24 or so scalar functions this would give more than 200 cases - too much for a lazy guy like me. Another problem is that real arithmetic can lead to complex results, eg. ¯1⋆.5. What GNU APL does is checking of the result type (INT, REAL, or COMPLEX) rather than the argument types, and to demote complex near-real results to real and real near-int values to int. Contrary to your opinion below, the most generic number type in GNU APL is not double but complex<double>. And that causes the failure that was fixed in SVN 219. The internal 0J0 result was not properly recognized as near-real, so it was left as is. Type specific functions are only used if: 1. they have considerably better performance than a generic variant, and 2. they are frequently used with large arguments That was not the case for Encode. So the clear integer 0 was 0J0 (to be generic) and was not converted back to 0 by mistake. There is a serious problem with ⎕CT as such. ⎕CT is 1E¯13 by default but our numbers can be as small as 1E¯308. So we cannot simply set everything small (say < 1E¯13) to 0, or make complex numbers with small imaginary parts real, because we would loose precision when doing so. The strategy of GNU APL is to keep internal precision as long as possible and to demote only if absolutely necessary. This decision is on a per-primitive base. Encode was actually demoted, except that demotion of 0J0 did not result in integer 0. I would also say that your rules below are implemented in GNU APL to the extent that they are correct. They are not, though, since Integer + Integer can be double if the maximum integer is exceeded (and so on...). /// Jürgen On 06/11/2014 05:52 PM, Blake McBride wrote:
|
[Prev in Thread] | Current Thread | [Next in Thread] |