Hi Robert!

On Nov 26, 10:20 am, Robert Bradshaw <rober...@math.washington.edu>
wrote:
[...]
> With over-allocation one might not even need the dense/sparse  
> distinction--creating 1000 variables in a "sparse" manner would only  
> need 10 reallocations. (There could still be the question of how  
> expensive it is to do arithmetic between very old and very new  
> variables, without timing and looking at the actual code I'm not sure  
> if this is a concern.)

I just remembered one important detail: In the sparse implementation,
any element of an InfinitePolynomialRing has its own underlying
polynomial ring. Continuing the example from my post above:

  sage: x[100].polynomial().parent()
  Univariate Polynomial Ring in x100 over Real Field with 53 bits of
precision
  sage: x[1].polynomial().parent()
  Univariate Polynomial Ring in x1 over Real Field with 53 bits of
precision
  sage: x[10].polynomial().parent()
  Univariate Polynomial Ring in x10 over Real Field with 53 bits of
precision
  sage: (x[1]+x[10]).polynomial().parent()
  Multivariate Polynomial Ring in x10, x1 over Real Field with 53 bits
of precision
  sage: x[5].polynomial().parent()
  Univariate Polynomial Ring in x5 over Real Field with 53 bits of
precision
  sage: (x[5]+x[10]).polynomial().parent()
  Multivariate Polynomial Ring in x10, x5 over Real Field with 53 bits
of precision

This is why the sparse implementation is so slow.

In the dense implementation, the InfinitePolynomialRing has an
underlying ring by itself:
  sage: Y.polynomial_ring()
  Multivariate Polynomial Ring in b10, b9, b8, b7, b6, b5, b4, b3, b2,
b1, b0, a10, a9, a8, a7, a6, a5, a4, a3, a2, a1, a0 over Real Field
with 53 bits of precision

Perhaps it would be better if the InfinitePolynomialRing had a
*common* underlying ring also in the sparse implementation? In the
sparse implementation that ring would just be slimmer than in the
dense implementation?

Provided that I find the time, I'll try to implement it. Thank you for
pointing me to it!

Cheers,
Simon

-- 
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

Reply via email to