On 03/28/2012 06:14 PM, Mark Shimozono wrote:
Suppose I want to create a custom subclass of a polynomial ring.
 From which class should it inherit? It should not care so much about
the
eventual base ring.

I'm a sage development newbie.
Where can I read about the class hierarchy for sage polynomials?
I'm a little confused at the organizational principle behind the
following output.

I can answer half of your question: the documentation is either in the reference manual,

  http://sagemath.org/doc/reference/polynomial_rings.html

or the source code:

  sage: R = PolynomialRing(QQ,['x'])
  sage: R?

At the top, you'll see something like,

  Source File:    /home/mjo/src/sage-5.0.beta9/devel/sage/sage/rings
  /polynomial/polynomial_ring.py

Which should give you a hint where to look. In this case, I think you would find your way to,

  sage/rings/polynomial/polynomial_ring_constructor.py

where the real magic happens.



sage: R = PolynomialRing(QQ,['x'])
sage: R.__class__
<class
'sage.rings.polynomial.polynomial_ring.PolynomialRing_field_with_category'>

sage: R.an_element().__class__
<type
'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'>

Sage uses different libraries for different types of polynomials. It looks like we use flint for univariate over the rationals. If you construct it over the reals, you get something else.


sage: S = PolynomialRing(QQ,['x','y'])
sage: S.__class__
<type
'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular'>

sage: S.an_element().__class__
<type
'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'>

Multivariate polynomials over the rationals are implemented in libsingular instead, so they use a different class than in the univariate case.

The choice of which to use is made in the PolynomialRing() constructor, which hands off the work to either the _single_variate() or _multi_variate() functions accordingly.

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