Hi Martin,
>
> I just reviewed #8276 based on the discussion in
> http://groups.google.com/group/sage-devel/browse_frm/thread/1042edd11b3854b2
> .
> For me a great problem arises with this change, though the majority
> voted for it. I think about it as follows.
>
> The categories framework has introduced a function zero for every
> commutative monoid. Its standard definition is return self(0).
I won't call it a "standard definition" but more a "default definition"
meaning:
- If you have a better way, do it !
- This implementation may be not suitable for you !
Supporting this Nicolas wrote:
The default implementation is to coerce 0 into self.
It is recommended to override this method because the
coercion from the integers:
- is not always meaningful (except for `0`),
- often uses self.zero() otherwise.
> MatrixSpace(...)(0) is mutable. Now, we overwrite this in
> matrix_space.py, which is an object of this category by zero =
> zero_matrix and zero_matrix returns an immutable matrix.
Note that if you wan't to construct a matrix from scratch by setting element
in an empty matrix, IMHO the good way to write it is:
MatrixSpace(....)()
^
Nothing here !!!
Take an empty matrix and fill it ! It my opinion MatrixSpace(...)(0) should
returns an immutable matrix. Now there are so many example in the doc of
people contructing a matrix from 0 rather than from nothing, that changing
this would be a major non backward compatible change. I don't want to break
this.
> Hence, zero returns a different value, than the framework implies and
> I am concerned about this. Still Sage lacks unification and for me the
> categories framework promised to change this by defining standard
> functions and their return values. I am not opposed to optimized
> implementation, but I am opposed to changing return values. Since,
> now, I will have to explain my students, that normally zero will
> return the same as self(0), but for MatrixSpaces the situation is
> slightly different. This is Pandora's box.
First of all see my argument up there ! What do you mean by same ? They are
mathematically equal.
> I suggest to make zero as well as one just synonyms for self(0) and
> self(1), respectively, and leave zero_matrix and identity_matrix as
> they are.
> An alternative is to introduce a parameter for these last two
> functions immutable=True/False.
In my opinion, mutable matrices are something which is needed to be practical,
and the notation M[i,j] = ... is so pratical than we cannot avoid it. However
any matrix which goes in and out of a mathematical computation should be
immutable.
Cheers,
Florent
--
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