On Thursday 21 June 2007 10:43, David Harvey wrote: > So my feeling is that: > (1) the vector_times_matrix_c() function should be able to assume > that the vector is over the same ring as the matrix, > (2) therefore there is a bug in Vector.__mul__(). It shouldn't just > be checking the types, it should also be checking the base rings, and > if they don't agree, some coercion should be kicking in. > > Thoughts? > > My only concern is the whole question about multiple representation > formats... like what happens if a parent (say vectors over some ring) > has more than one way of representing elements. Is Vector.__mul__ > responsible for the conversion in this case, or is it the vector/ > matrix multiply operation?
I was wondering about very similar questions in conversations with David Roe about number fields. It seems to me that when you get to an __mul__ in an element, it should be very well defined exactly what you are multiplying. Indeed, I think that there should be seperate functions for each of the multiplications that an element handles -- e.g. a matrix should have: 1) __mul__by_vector_ (multiplication by a vector with entries the same type as the matrix entries.) 2) __mul__by_scalar_ (multiplication by a scalar with same type as matrix) 3) __mul__ (multiplication by -- properly sized -- matrix) Actually, all three of these should be able to assume that that not only the mathematical types match, but that the actual representation should match (i.e. both dense or both sparse). That is, I'm saying that all the coercion should have already been done by higher level functions. This is so that the actual __mul__* functions can be extremely optimized. There is already some precedent for this in the element class, but it seemed just a touch primitive to me. I don't have concrete ways in mind that it was too primitive (although it didn't appear to support the 3 methods I mentioned to matrices above -- just scalar multiplication and ordinary multiplication). It just seemed that the code was too simple to have dealt with all the cases. It does seem like only the ring could know of all the ways we could multiply by some sort of scalar since __mul__by_vector_ seems unique to matrices. I think that means that I'm agreeing with David's feeling expressed above. -- Joel --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---
