-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
Implement __pow__ in the coercion model #24247
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Commit: |
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:
|
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:
|
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:62
Replying to @tscrim:
First of all, it is important to state that this ticket only changes powering for certain parents. It allows to implement powering using the coercion model, but many parents with a custom Now the timings. The conclusion seems to be that powering for equal parents is slightly faster than before but that powering with non-equal parents is slower than before. This is because the latter goes through the coercion model now. ZZZZ Before:
After:
GF(2n)ZZ Before:
After:
RDFRDF Before:
After:
RDFZZ Before:
After:
idealZZ Before:
After:
|
comment:63
Part of the slowdown is caused by
to
and from
to
|
comment:65
I like very much the idea of moving powering inside the coercion model. Though, it is not a binary operator
|
comment:66
Replying to @videlec:
Copying from [comment:34]: I think that coercing to a common parent does make sense because:
|
comment:67
Thank for the timings and explanation. I am the most concerned with the GF(2n)ZZ timings being ~2x slower as I would expect exponentiation to be a fairly common operation. For me personally, it is not important, but I know for the number theorist using Sage, it could have a much bigger impact. However, you know that area of math/Sage better than I, so if you think it will be okay, then no objection from me. |
comment:68
Replying to @tscrim:
It's actually only a factor 1.61 slower but that will improve significantly after #24500. Possibly, other optimizations in the coercion model are possible. It is also important to note that I intentionally took the worst case of |
comment:69
Okay, then positive review from me. Does anyone else have any other objections or questions? |
comment:70
fine for me |
Reviewer: Travis Scrimshaw, Vincent Delecroix |
Changed branch from u/jdemeyer/implement___pow___in_the_coercion_model to |
…s Integer The `absolute_discriminant()` of any number field should be a Sage `Integer`. This is currently not properly doctested, leading to a subtle failure in sagemath#24247. URL: https://trac.sagemath.org/24462 Reported by: jdemeyer Ticket author(s): Frédéric Chapoton Reviewer(s): Travis Scrimshaw
We implement powering in the coercion model. One important difference between powering and other operators is that the most common use case for powering is powering something to an integer exponent.
To deal with this integer powering, we implement an action
IntegerPowAction
. This action calls a special method_pow_int()
on the element. In other words,x ^ n
for an integern
becomesx._pow_int(n)
. We also provide a default implementation of_pow_int
forMonoidElement
andRingElement
which uses the square-and-multiply algorithm implemented ingeneric_power()
.For backward compatibility reasons, we also call this action for elements of
IntegerModRing(m)
. In the future, we may rethink what to do here, see #15709.Apart from this, powering behaves like other binary operators: coercion to a common parent is done if no action is defined.
Note that the 3-argument version of
pow()
is not supported in the coercion model. Only specific types likeInteger
implement it. See also #5082.Fixing powering for specific parents is not within the scope of this ticket, except where it was needed to fix doctest failures. For example, we fix various serious bugs in powering for
RDF
such as:Depends on #24467
Component: coercion
Author: Jeroen Demeyer
Branch/Commit:
74d6700
Reviewer: Travis Scrimshaw, Vincent Delecroix
Issue created by migration from https://trac.sagemath.org/ticket/24247
The text was updated successfully, but these errors were encountered: