Hi Nicolas, hi all, On 11 Jan., 11:50, "Nicolas M. Thiery" <[email protected]> wrote: > > Question to you: Do you see an obvious reason why matrix spaces should > > not be unique parents? > > If at all possible, I for myself would rather have them as unique > parents. > > On the other hand, I remember it was argued against it for > VectorSpaces: indeed users might want to create several copies of a > given vector space, in particular to use different scalar products. > I don't know if there are similar needs/use for matrix spaces.
Here, the only extra structure is "sparse versus dense". Namely, currently, a matrix space is determined as unique object by base_ring, nrows, ncols, sparse but equality is tested by base_ring, nrows, ncols only. Of course, "dense versus sparse" is not a mathematical property, but only concerns implementation (so, it is different from a scalar product, which carries mathematical information). >From my perspective, it only matters whether one can do arithmetic involving a sparse and a dense matrix -- that's to say, whether the coercion model is easily able to handle it. And for the coercion model, it is easier when the parents are unique. Two remarks: 1) With my patch from #12290, the time for returning the hash of a matrix space drops from 13.8 µs to 547 ns. But when using UniqueRepresentation as a base class of matrix spaces, then one even comes to 489 ns. So, if you mainly care for speed then using UniqueRepresentation is the way to go. 2) A more general consideration: The coercion model prefers to have unique parents. But many people think that "A == B" should mean "A and B are canonically isomorphic", and not just "A is B". That could be solved by making the coercion model consequently use containers that compare by "is" and not by "==". For example, consequently use sage.structure.coerce_dict.TripleDict and not dict. In that way, we could both strengthen the coercion model and make the people happy. But it would probably involve some tedious work... Best regards, Simon -- To post to this group, send an email to [email protected] To unsubscribe from this group, send an email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
