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
Use _mul_long Matrix*int #25079
Comments
comment:2
In the current branch, I am basically copying relevant parts of Without the branch:
With the branch:
I didn't run the test suite yet, but for now I am asking for review... New commits:
|
Commit: |
Author: Simon King |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:5
Sorry, I had forgotten to add a test. So, I changed the last commit (sorry for the forced push, but nobody was using the old commit yet). Here is what happens for other matrix types:
Without the branch:
So, it seems that enabling _mul_long (which basically means: Using the existing default _mul_long) seems to not slow down the old code substantially. |
comment:6
All tests pass (with meataxe installed)... |
comment:7
I might review this, but I would rather do that after the dependencies have been merged. |
comment:8
Already this comment is wrong:
It's certainly not a Python integer, it's a C |
comment:9
The code in |
comment:10
Replying to @jdemeyer:
This ticket is related with an error that was actually solved (but not via But if you prefer "C long", I'm fine with it. |
comment:11
Replying to @simon-king-jena:
Right, this ticket fixes a problem involving a Python integer. But the function
Either that or revert to the old wording. |
comment:12
Replying to @jdemeyer:
I copied it from some other place of And I'll return to the original wording. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:14
Done! |
comment:15
PS: I repeated the timings that I provided in comment:2 and comment:5.
Hence, there is now a slight improvement for Matrix_modn_dense_float (with the old branch, there was a small deterioration), and the improvement for Matrix_gfpn_dense is now even better. So, thank you for spotting the issue with |
Reviewer: Jeroen Demeyer |
comment:19
Do you have any idea why the patchbot reports failing tests? I don't get those failures. |
Changed dependencies from #25076 to none |
comment:21
Please add tests for multiplying with a negative integer. |
comment:22
Code looks good to me. So once you add the negative integer tests for meataxe, I will run full doctests. If that passes => positive review |
comment:23
Replying to @jdemeyer:
Good catch --- there is in fact a bug for multiplication with a negative Python long. |
comment:24
Problem: Apparently |
comment:25
Strange enough: I just tried to create cython code in which |
comment:26
Replying to @simon-king-jena:
The Python convention is rounding down, so -1 divided by 3 gives quotient -1 and remainder 2. The C convention is truncating, so -1 divided by 3 gives quotient 0 and remainder -1. Cython always uses the Python convention, unless the Examples: Python integers, always Python convention:
C integers, result depends on
In fact, it suffices that one of the arguments is a C integer:
Sage is compiled with |
comment:27
Replying to @jdemeyer:
So, the easiest way out is to use |
comment:28
Replying to @simon-king-jena:
Sure. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:30
Thank you for pointing me to the cdivision directive. I added a test showing that multiplication with a negative int works, and with that |
Changed branch from u/SimonKing/use__mul_long_matrix_int to u/jdemeyer/use__mul_long_matrix_int |
Dependencies: #25476 |
Changed branch from u/jdemeyer/use__mul_long_matrix_int to |
sage.structure.element does support the use of _mul_long for a multiplication of the form Elementint. However, the multiplication of Matrixint does not use that short-cut.
In fact, currently only one matrix type implements _mul_long, namely Matrix_gfpn_dense. Unfortunately it uses a conversion that does not coincide with the coercion into the base ring.
So, this ticket is about fixing both issues.
Depends on #25476
Component: coercion
Keywords: Matrix _mul_long
Author: Simon King
Branch/Commit:
3c4a06d
Reviewer: Jeroen Demeyer
Issue created by migration from https://trac.sagemath.org/ticket/25079
The text was updated successfully, but these errors were encountered: