Hi!

In order to let Rob use IntegerModRing(n) as example of finite
additive group for his cool Cayley graph feature (#7555), I just wrote
a patch (#8562) letting IntegerModRing(n) use the category
framework. That was essentially a one liner, plus minor updates here
and there, and all test pass.

There is just a single issue for which I would like feedback.
Namely, what shall be the result of:

        sage: IntegerModRing(5).category()

It used to be "CommutativeRings()", which feels a bit disappointing.
So the current patch whether n is prime, and if yes sets the category
to Fields(). This sounds natural, but there is one drawback: the
category needs to be set at construction time, and the primality test
can possibly be costly. And indeed, the Sage tests contain one use
case where this is not acceptable (sage/tests/book_stein_ent.py, l.122):

    sage: def is_prime_lucas_lehmer(p):
    ...    s = Mod(4, 2^p - 1)
    ...    for i in range(3, p+1): 
    ...        s = s^2 - 2
    ...    return s == 0
    sage: # Check primality of 2^9941 - 1
    sage: is_prime_lucas_lehmer(9941)
    True

The Mod call constructs IntegerModRing(2^9941) and the primality test
triggers a timeout or pari overflow.

What strategy would you recommend?

(1) We don't care about the usecase above (hmm)

(2) IntegerModRing(n) is always in CommutativeRings()

(3) Same thing, unless the user specifies the category:

    IntegerModRing(5, Fields())

    Although in that case, he might as well call GF(5).

(4) IntegerModRing(n) always do a primality test, unless the user
    specifies himself the category.

(5) When n is not too big, IntegerModRing(n) checks the primality of
    n, and sets the category accordingly. Otherwise it always uses
    CommutativeRings().

(6) When n is not too big, IntegerModRing(n) checks the primality of
    n, and returns GF(n) or a plain IntegerModRing(n) accordingly.

(7) Something else?

I vote for (6), but only with a very light preference.

Thanks!
                                Nicolas
--
Nicolas M. ThiƩry "Isil" <nthi...@users.sf.net>
http://Nicolas.Thiery.name/

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-devel+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to