Wow, this opened up a can of worms I hadn't expected, but reading your comments, I really agree.
> When I was working on similar issues for printing real numbers (i.e., > whether to truncate digits, etc.), Carl Witty brought up a very good > point. Printing representation options should be global session-wide > defaults that apply to all output in a session, rather than options > stored with the objects. For example, it seems better to do something like: > > sage.print_options['finite field repr']='int' > > or > > sage.rings.finite_rings.finite_field_base.printing_style='int' Yes! That would be a much better way of doing it. And then thinking it through to make sure that it could work in all the places we would like such a thing. > You need to be careful that the generator, which currently is only > required to have irreducible characteristic polynomial over the base > field, is actually a multiplicative generator for the field: > sage: R.<x> = ZZ[] > sage: k.<a> = GF(49,modulus=x^2+5*x+2) > sage: a.multiplicative_order() > 24 > > I certainly like "<generator>^<exponent>" more, but we can't use the > same name here as for the generator above. Maybe we should have > mult_gen_name as an option to pass to GF, with a sensible default? I didn't realise that. That probably saved me some hours in debugging sometime in the future ;-) Is it completely insane to change the default field constructor to always return a multiplicative generator instead of the above (polynomial?) generator? The above concept certainly decreases the usefulness of printing generator^exponent. I think it would be quite unintuitive if the user saw something like > sage: R.<x> = ZZ[] > sage: k.<a> = GF(49,modulus=x^2+5*x+2) > sage: a > beta^10 assuming that "beta" was the sensible default mult_gen_name. On could of course also output > sage: a > (5*a+3)^10 seeing as 5a+3 is a multiplicative generator of k, but I'm not sure we're really helping things here... > In fact, I think it makes sense to have printing objects inherit from > each other, so that we don't have to continually write code like > ' + '.join(["%s * x^i"%(c.list()[i] for i in range(len(c.list()))]) > and make sure to debug all the corner cases. Yes! Alternatively/Relatedly, use a sort of interface for printing objects that print utility functions could use. In the above example, useful features to ask for is when the exponent is 0 or 1, and whether the coefficient needs parentheses around it. There are, as you point out, _many_ places in the sage source code that implements printing polynomial-like objects, and they all have special handling of various cases. Would be nice to unify. Cheers, Johan -- 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