On Wednesday, June 4, 2014 8:58:37 AM UTC-7, Nils Bruin wrote:
>
>
> This suggests that element_from_data uses significant time. This is a
> generic conversion routine! Looking around in the call graph would probably
> show where this happens. Given most elements lie in the right ring already,
> it may well be possible to avoid it and/or optimize the code path through
> it for frequent cases ( little tip-off is the freqent use of is_GapElement,
> which probably should not be checked at all, because this code doesn't ever
> seem to come near GapLib. It's also cheap, though, so by itself not really
> responsible for a lot of time use)
>
> As it turns out, this gets triggered by
sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_univariate.__normalize,
because it wants to know the valuation of the underlying polynomial. It has
this little loop, which you would think is pretty fast:
for k from 0 <= k <= self.degree():
if self[k]:
return ZZ(k)
However, this ends up executing Polynomial_ZZ_pEX.__getitem__, which leads
to:
K = self._parent.base_ring()
return K(ZZ_pE_c_to_list(c_pE))
triggering conversion of a list to a Givaro finite field: the slow case. So
the problem (if there is any) seems to be that retrieving coefficients of a
polynomial is relatively slow, because apparently the coefficients of the
polynomial are not stored exactly as elements of the base field.
In general, it seems it would be good if the sequence
K(ZZ_pE_c_to_list(ZZ_pEX_coeff(self.x,i))) could be shortcut a bit if self
is an NTL poly over a Givaro field K. Given that polynomial_zz_pex seems to
ensure it always uses the same minimal polynomial for its coefficients as
the base field does, it should be possible to shortcut the conversion by
quite a bit. The profile above does indicate that in certain cases, these
conversions can end up being quite dominant in runtimes.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.