Currently in Sage one can do the following:
sage: M = (ZZ^2)*(1/2)
sage: M
Free module of degree 2 and rank 2 over Integer Ring
Echelon basis matrix:
[1/2 0]
[ 0 1/2]
sage: v = M.basis()[0]
sage: v.base_ring()
Integer Ring
sage: v[0].parent()
Rational Field
I assume that this behaviour is intentional and desired (it certainly
makes sense mathematically).
One sees that really two rings are involved:
(1) the ring ZZ which is the ring of scalars, the ring R such that we
have an R-module.
(2) the ring QQ from which the elements (the coefficients of the
vectors) come.
Sage really only knows about one ring, the base_ring() which currently
corresponds to (1). Unfortunately, having two different rings is almost
completely undoctested, leading to breakage. As a simple example, continued:
sage: matrix(v)
TypeError: no conversion of this rational to integer
This needs to be fixed, it's clear that we need two methods, one
returning ring (1) and one returning ring (2). The question is: what to
do with base_ring()? Currently, base_ring() is a method of both the
parent (FreeModule) and element (FreeModuleElement) which answers (1).
(A) keep base_ring() for the ring of scalars (1)
(B) change base_ring() to return the ring of elements (2)
(C) make base_ring() of the parent (the FreeModule) return (1) and the
base_ring() of the elements (FreeModuleElement) return (2)
(D) deprecate base_ring() and use new methods for both
(E) add a argument to base_ring() choosing between (1) and (2)
(F) something more complicated
Names for the new method could be:
for (1): scalar_ring()
for (2): element_ring() or coefficient_ring() or basis_ring()
My opinion goes to (D) because I think that's clearest. I also forces to
re-think every use of base_ring().
Jeroen.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.