[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] ⍋ on complex data

From: Juergen Sauermann
Subject: Re: [Bug-apl] ⍋ on complex data
Date: Sun, 06 Mar 2016 11:45:12 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0


the missing *DOMAIN ERROR* is fixed in *SVN 702*.

Sorting like in J has the disadvantage that equal (within ⎕CT) numbers can
be quite far away from each other in the result. And it introduces asymmetry
between the real and imag direction which is mathematically unsatisfactorily.

You could also argue that sorting by magnitude then by angle should be used.

For all these reasons DOMAIN ERROR seems to be the cleanest approach.

If you really want to sort complex numbers then you can sort a complex B
first by *11○* and the result by *9○*

*     B←4 2J2 3 3J3 5**
**      B1[⍋9○B1←B[⍋11○B]]**
**2J2 3 3J3 4 5*

/// Jürgen

On 03/05/2016 03:50 PM, Louis de Forcrand wrote:
Hmm. In J they are sorted first by real part, then by imaginary part.


On 05 Mar 2016, at 15:46, Elias Mårtenson <address@hidden <mailto:address@hidden>> wrote:

On 5 March 2016 at 20:12, Alexey Veretennikov <address@hidden <mailto:address@hidden>> wrote:

    Complex numbers are incomparable in mathematical sense. In Dyalog APL
    this leads to DOMAIN ERROR however.

This is the intended behaviour in GNU APL as well. This can be seen in the function Bif_F12_SORT::sort():

    loop(bz, len_BZ)
         array[bz] = &B->get_ravel(bz*comp_len);
         if (array[bz]->is_complex_cell())
            return Token(TOK_ERROR, E_DOMAIN_ERROR);

I believe the problem is that this function returns a Token instead of directly raising DOMAIN ERROR.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]