Hi, I have an algebra defined over the Laurent polynomial ring Z[x,x**-1] which has three bases: F, P and C, for an algebra. The transition matrices between any two of these bases is unitriangular.
I have an expensive (cached) function which writes P(t)=F(t) + \sum_{s<t} r_sx^_{a_s}F(s), for a_s, r_s\in Z. The element C(t) is determined by starting with F(P(s))=F(s) + smaller terms, and then ensuring that the coefficient of F(s) is always of the form r_s'x^{a_s} where a_s<0. To compute this I am currently using the function @cached_method def _C_to_F_on_basis(self, t): F=self.realization_of().F() P=self.realization_of().P() ct=F(P.term(t)) k=1 terms=ct._monomial_coefficients.items() terms.sort(cmp=lambda a,b: my_cmp(a[0],b[0])) while k<len(terms): if terms[k][1].valuation()<0: k+=1 else: ct -= C.term(term[k][0],term[k][1]) # removes c_s, doesn't change higher terms, may change lower terms terms=ct._monomial_coefficients.items() # need to update terms terms.sort(cmp=lambda a,b: my_cmp(a[0],b[0])) return ct For reasons I don't understand this is ridiculously slow even when the number of terms is small. Is there a way to improve on this? I'm not sure if it's necessary to continually resort the indices in terms as my algebra does have a indices_cmp method. On the other hand, from some tracking messages that I have added it is beginning to look to me that the problem might be caused by my coercion set up. I have defined all of these coercions using triangular morphisms like C_to_F = Psi.module_morphism(C._C_to_F_on_basis, codomain=F, triangular = 'lower', unitriangular = True, cmp = my_cmp ) C_to_F.register_as_coercion() (~C_to_F).register_as_coercion() It looks to me as by calling F(C(t)) I am automatically triggering all of the expensive conversions F(P(s)) whenever F(s) appears in P(t) even though these conversions may not be necessary in order to compute F(C(t)). For example, this seems to happen even in the case where C(t)==P(t) so that only F(P(t)) is needed to compute C(t). Is some one able to tell me whether I am imaging this, or whether I have set things up badly and so am deserving of it! :) Cheers, Andrew -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To view this discussion on the web visit https://groups.google.com/d/msg/sage-combinat-devel/-/QL9mSyRi47AJ. To post to this group, send email to sage-combinat-devel@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.