-
-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the one(), identity_matrix() and zero_matrix() cached and immutable #8276
Comments
This comment has been minimized.
This comment has been minimized.
comment:2
Correcting MatrixSpace is easy, however there are a lot of places in sage where people create a matrix from the one or zero and modify it after that. I nearly corrected all these occurences. However, I'm stuck with those three files which are very complicated and depend one of each other:
There are a lot of error but I can't find where it's coming from. I really Apply the patch in the following order:
Thanks for any suggestion. |
Attachment: trac_8276-fix_sagelib-fh.2.patch.gz |
comment:3
I finally manage to get those !!! It should be ready for review. Apply
Florent |
This comment has been minimized.
This comment has been minimized.
comment:5
I just added a third patch which fixes a non working optimization when creating the zero matrix from Apply this patch after the two others. |
comment:7
The last improvement patch breaks something... |
Attachment: trac_8276-MatrixSpace_one-fh.patch.gz Attachment: trac_8276-fix_sagelib-fh.patch.gz |
comment:8
At last thing should be OK ! Please apply in the following order:
Depends on #8294 The first patch makes the matrices immutable, the second one fixes Sage's lib accordingly the thirds patch simplifies and optimizes the creation of the zero matrix. |
This comment has been minimized.
This comment has been minimized.
Attachment: trac_8276-fix_zero_matrix_creation-fh.patch.gz |
comment:10
Oups ! I just realize I forgot to reupload
Again, sorry for any inconvenience. Florent |
comment:11
Martin Raum: I understand from #8294 that you intend to review this ticket quickly ! I allowed myself to put you in CC of this ticket ! Please make sure that you have the latest version of Thanks for your help ! |
comment:12
Applied the following patches (in the order below). trac_8276-MatrixSpace_one-fh.patch trac_8276-fix_sagelib-fh.patch trac_8276-fix_zero_matrix_creation-fh.patch trac_8294-matrix_2x2_copy_mutability_fix-fh.patch Almost everything seems straightforward and correct but... Seems that MM(0) which has a "mutable == True" property/value should be updatable but the example "MM(0)[1,2] = 3" doesnt update MM(0) (see example below) Is that right?
|
comment:13
Just saw the "updated patch" reference. Will include replace old patch with new tomorrow and re-test |
comment:14
Replying to @sagetrac-rossk:
Sure ! What wasn't straightforward was to correctly find all the places which needed to be patched and to distinguish them from those who doesn't. Note that the speed regression when calling
This is perfectly normal.
Construct a matrix, modify it and forget about the result so that the next call to
Florent |
Attachment: trac-8276-MatrixSpace_one-review.patch.gz First reviewed patch |
Attachment: trac-8276-fix_sagelib-review.patch.gz Seconded reviewed patch. |
comment:15
Used the new patches (as well as trac_8294-matrix_2x2_copy_mutability_fix-fh.patch). All were applied and compiled with no errors.
Re-tested each and got the following for the first 2 (but the 3rd one passed).
I get this "mysterious error" a number of times and have seen many tickets mention it. Can anyone give any advice about it? Given its not always reproduceable, should it block a positive review if the tickets functionality proves good? |
comment:16
I just have have a query now that Im looking at the ticket that someone may care to answer.
|
Changed keywords from One mutable. to One Zero mutable. |
comment:17
The reason is the categorie framework. MatrixSpaces are vector spaces, so they implement zero(). In my oppinion this should absolutely coinside with MM(0) since everybody will expect it so do so. Hence, it should be mutable. Could I hear your oppinion? If nobody is opposed I will set this to positive review tomorrow evening and I will open a follow up which sets one = lambda self : self(1) . |
comment:18
Is corrected by my last patch. It should be False Replying to @sagetrac-mraum:
No it isn't. See the comment in the doc of
Note that my last version of the patch also implement
My opinion which coincide with William's and Robert Bradshaw is that one and zero should be immutable. It was not discussed whether |
Attachment: trac-8276-fix_zero_matrix_creation-review.patch.gz Replacing old review; now with zero=zero_matrix |
Reviewer: Martin Raum, rossk |
comment:19
Ok, I didn't read this thread this way, but yes, you're right, a majority seems to want exactly this behaviour. I'm personally strongly opposed to this, so I am going to open a brief discussion on sage-devel, just to make sure that this is a general policy towards the categories framework. I hope to read your opinion there, too. rossk: I guess it's fair to say, that you also contributed to this review, so please expand your name in the review field. |
Changed reviewer from Martin Raum, rossk to Martin Raum, Ross Kyprianou |
comment:21
Merged in this order: |
Merged: sage-4.3.4.alpha0 |
After I found the following bug, it was decided on sage-devel that in a
MatrixSpace
the methods.one()
,.identity_matrix()
and.zero_matrix()
should returns a cached immutable matrix. I had to update sage's library accordingly.So here is now the current behavior:
Note that calling
MM(0)
orMM(1)
was a bad idea:And for identity:
I took the chance to optimize those. The extra cost of calling
MM()
orM(0)
instead ofcopy(MM.zero_matrix())
is now very small.CC: @sagetrac-mraum
Component: linear algebra
Keywords: One Zero mutable.
Author: Florent Hivert
Reviewer: Martin Raum, Ross Kyprianou
Merged: sage-4.3.4.alpha0
Issue created by migration from https://trac.sagemath.org/ticket/8276
The text was updated successfully, but these errors were encountered: