On Jun 4, 2009, at 9:42 PM, Craig Citro wrote: > >>> How do you generally use the matrix after you call change_ring >>> ()? It >>> seems like the normal thing to do would be to change the matrix in >>> some >>> way. In that case, it is a huge bonus to have consistency between >>> returning the original object and returning a copy. >> >> I usually use change_ring on polynomials, after which I extract >> coefficients/find roots/factor/etc. It's also nice to change the ring >> to be over a fraction field (i.e. M.change_ring(M.base_ring >> ().fraction_field())) before taking the echelon form. >> > > Yeah, I can see that it makes sense there (because you're calling to > something that will give you back a new matrix regardless). The use > case I had in mind when I voted +1 was that I have a matrix over a > number field or finite field, and I want to play with it in an > extension where some polynomial has a root. So change ring to the > extension, and manipulate the result -- here I think it's more > surprising when the behavior is different when the polynomial does or > doesn't have a root. > > I don't think that one choice is clearly better than the other -- I > vote for adding a flag to change_ring, called copy. Now, of course, > what should the default be? I (obviously) vote for True; my reasoning > is this: if you wanted copy=False, and you get copy=True, then all you > get is a slowdown; if you wanted copy=True, and you get copy=False, > then you have possibly hard to find bugs. So the principle of least > surprise says we want copy=True, I think.
That is a good point. >> In general I view X.change_ring(R) as shorthand for X.parent >> ().change_ring(R)(X), and given a parent R, R(x) generally returns x >> if x is already an element of R. > > That's interesting -- I actually think of it as "tensor X.parent() > with R, and take the natural image of X in that tensor product" > (because I think of change_ring as a shorthand for base_change on the > parent). So I'd generally expect to get a (naturally isomorphic) copy > back. change_ring can be used for lifting and any non-canonical conversions as well. - Robert --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---