I would say that you should never test for primality unless specifically required, e.g. if the user asks is_field() (after which the category could be upgraded? I don't know if that is possible).
I would always use GF(p) rather than IntegerMod(p) for when I know p is prime. it is is vital in teaching primality tests and the like that one can form IntegerModRing(n) without knowing (or automatically testing behind the scenes) whether or not n is prime. There are surely many other similar situations, for example when constructing a commutative ring it might be expensive to determine whether or not it is an Integral Domain. John PS This would be a suitable discussion for the newly-formed sage-algebra list! On 20 March 2010 15:35, Florent Hivert <florent.hiv...@univ-rouen.fr> wrote: > Hi There, > >> 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. > > [...] > > >> 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()) > > You probably mean > IntegerModRing(5, category=Fields()) > which is consitent with was we do in sevaral other places. > >> 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. > > What about: > > (6') if the user specifies a category with > IntegerModRing(5, category=Fields()) > then trust him and do no check otherwise (6). But maybe it is what you meant. > > Cheers, > > Florent > > -- > 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. > -- 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.