Simon, Thanks. I think that in order for this to work, that finite field should have a new method, something like
@cached_method _cofactor_information(self): N = self.order() return [ (N//p**r,p) for p,r in arith.factor(N)] which would factor the order, and then return all the cofactors and prime associated with them, and then change multiplicative order to use that method. Victor On Jul 31, 11:16 am, Simon King <simon.k...@nuigalway.ie> wrote: > Hi Victor, > > On Jul 31, 3:59 pm, VictorMiller <victorsmil...@gmail.com> wrote: > > > I was just looking at the code for multiplicative_order in > > finite_field_element.py, and noticed that it factors the group order, > > and find the "cofactors" corresponding to each prime power dividing > > the order (which is really the only algorithm that I know to do > > this). To avoid repeating this calculation for elements of finite > > fields it would be nice if the finite field could cache this > > information, so that it wouldn't have to be recalculated. The same > > remark should hold for finite abelian groups (since it's really the > > same algorithm). > > Do you know the cached_method decorator? In order to cache the field > (or group) order, you just need to import the decorator by > from sage.misc.cachefunc import cached_method > and then, right in front of the method definition, put @cached_method: > > @cached_method > def multiplicative_order(FiniteField_givaroElement self): > ... > > Cheers, > Simon --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---