Pari/GP Exceptions/break loops

525 views Asked by At

ellpow(E, P, m) will always throw an exception:

*** ellpow: impossible inverse modulo: Mod(x, y).
***   Break loop: type 'break' to go back to GP

where x and y are integers.

I want to trap the value x, without finishing the program in order to use it later.

The snippet of the code is:

trap(invmoder,
    x,
    ellpow(E, P, m)
), n);

The whole program is:

ellcurv(n) = {
    local(B, a1, a2, a3, a4, a6, b, E, P, m, x);

    B = 20;

    a4 = Mod(random(n), n);
    b = 4*a4^3 + 27;
    b = 1/b;

    a1 = a2 = a3 = Mod(0, n);
    a6 = Mod(1, n);

    E = ellinit([a1, a2, a3, a4, a6]);
    P = [0,1];

    ellisoncurve(E, P);
    m = 1;
    for(i = 1, B,
        m = lcm(m, i));
    print(m);

    x = gcd(
        trap(,
            ellpow(E, P, m),
            ellpow(E, P, m)
        ), n);

}
0

There are 0 answers