-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Add __mod__ to coercion model #269
Comments
Replying to @sagetrac-dmharvey:
Is exact division (that is, division where the caller knows that there is no remainder) common enough to belong here? (There's an implementation for Integer already, where the method is called divide_knowing_divisible_by() and calls mpz_divexact().) |
comment:4
Replying to @sagetrac-cwitty:
I definitely think that exact division should be included in the arithmetic architecture. This is not because it's common, but because there is a bunch of daft coercion code in most !floordiv! implementations. All this needs to be fixed and the fix is a common boiler-plate prefix on these functions. Or, a much better alternative is to include it in the arithmetic hierarchy and write that boilerplate coercion once at the head of the tree. I think that gcd (and maybe xgcd) should also be on this list. |
comment:5
Oh, and quo_rem should be here too -- #383 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Dependencies: #2034 |
Author: Jeroen Demeyer |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
comment:27
About comment:19 I guess that the rationale is that we should follow what was done until now. If you want to change the |
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:
|
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:32
Please, add doctests for |
Reviewer: Vincent Delecroix |
Branch pushed to git repo; I updated commit sha1. New commits:
|
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. New commits:
|
comment:38
Thanks! |
Changed branch from u/jdemeyer/add___mod___to_coercion_model to |
Add
__mod__
to the coercion model forElement
and change__mod__
to_mod_
where applicable.We change the behaviour of
__mod__
for integer mod rings: the following (which is mathematically meaningless) is now an error:Apart from this, this branch does not change any semantics of remaindering.
As proof-of-concept for refactoring more generally the arithmetic methods on
Element
, the implementation of__mod__
is different from the usual implementation:_mod_
will be added toElement
and notRingElement
or similar.cpdef _mod_(self, other)
with no typing for the arguments or return value.__imod__
which is useless anyway with coercion.My intention is that eventually all arithmetic methods should be implemented like
__mod__
.CC: @videlec
Component: coercion
Author: Jeroen Demeyer
Branch/Commit:
aca3398
Reviewer: Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/269
The text was updated successfully, but these errors were encountered: