On Mar 5, 7:13 pm, Carl Witty <[EMAIL PROTECTED]> wrote:
> Here's a nicely overengineered rough proposal. The idea is to make it
> easy to write _sage_init_ methods, and get very nice output; without
> worrying much about how hard it is to write the framework. (I would
> probably write the framework, since I enjoy that sort of thing...)
>
> Here is a sample _sage_init_ method, for IntegerMod_abstract:
>
> def _sage_init_(pp, coerced):
> if coerced:
> return pp(self.lift())
> elif is_FiniteField(self.parent()):
> return pp(self.parent)(self.lift())
> else:
> return pp.lit('mod')(pp(self.lift()), pp(self.modulus()))
William requested an example of matrices over a base ring, so here's
what the _sage_init_ method on dense matrices might look like.
def _sage_init(self, pp, coerced):
pp_base_ring = pp(self.base_ring())
pp_elts = [pp(elt, True) for elt in self.list()]
return pp.lit('matrix')(pp_base_ring, pp(self.nrows()),
pp(self.ncols()), pp_elts)
Carl
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---