The irony... Rosetta not translating...
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    Is this a doomed example or is there a simple fix to produce the desired output?

    https://rosettacode.org/wiki/Elliptic_curve_arithmetic

    I can't even compile it under MorphOS and on Linux all but the fixed co-ordinates are Not-A-Numbers.
    PPC assembly ain't so bad... ;)
  • »26.05.15 - 12:07
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    igracki
    Posts: 389 from 2003/2/25
    From: Berlin
    The python version works here!
    Code:

    0:00.60 [ 1] MOSBOOT:> c:python3 rosetta.py
    a = (-1.817, 1.000)
    b = (-1.442, 2.000)
    c = a + b = (10.375, -33.525)
    d = -c = (10.375, 33.525)
    c + d = Zero
    a + b + d = Zero
    a * 12345 = (10.759, 35.387)
  • »26.05.15 - 12:40
    Profile Visit Website
  • MorphOS Developer
    bigfoot
    Posts: 508 from 2003/4/11
    There's a bug in the C code, or at least a difference from how the Python version works.

    In the from_y() function, replace
    Code:

    r.x = pow(y * y - C, 1.0/3);

    with
    Code:

    double tmp;
    tmp = y * y - C;
    if (tmp >= 0)
    r.x = pow(tmp, 1.0/3);
    else
    r.x = -pow(-tmp, 1.0/3);


    That'll make it behave identically to the Python version, and also give an identical result.

    The code as it is compiles fine for MorphOS, at least if you use GCC 4.
    I rarely log in to MorphZone which means that I often miss private messages sent on here. If you wish to contact me, please email me at [username]@asgaard.morphos-team.net, where [username] is my username here on MorphZone.
  • »26.05.15 - 19:44
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    Thank you. Now I get the expected output when compiled on Linux (gcc 4.8.2) but I might be experiencing a corrupted SDK. I'm downloading the sdk again and will do a checksum against the file I installed from...
    PPC assembly ain't so bad... ;)
  • »27.05.15 - 02:00
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    The sdk archive I installed from seems to be the same as the newly downloaded one but gccselect isn't behaving as expected. I only managed to compile the fixed source code by entering ppc-morphos-gcc-4

    Are gccselect and gccselect4 supposed to require a full path to work? After trying:

    > sdk:gccselect4 4.4.5

    and:

    > gcc --version

    it still reported 2.95.3
    PPC assembly ain't so bad... ;)
  • »27.05.15 - 02:59
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 2971 from 2003/3/5
    From: Canada
    gccselect4 selects the version to use when invoking ppc-morphos-gcc-4. To change the default gcc link, use gccselect.
  • »27.05.15 - 07:13
    Profile Visit Website