id summary reporter owner description type status priority milestone component resolution keywords cc merged author reviewer upstream work_issues branch commit dependencies stopgaps
24247 Implement __pow__ in the coercion model jdemeyer "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 integer `n` becomes `x._pow_int(n)`. We also provide a default implementation of `_pow_int` for `MonoidElement` and `RingElement` which uses the square-and-multiply algorithm implemented in `generic_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.
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 like `Integer` implement it.
We also fix various serious bugs in powering for `RDF` such as:
{{{
sage: RDF(0) ^ RDF(-1)
0.0
sage: RDF(-1) ^ RDF(2)
NaN
}}}" enhancement needs_review major sage-8.2 coercion Jeroen Demeyer N/A u/jdemeyer/implement___pow___in_the_coercion_model c5b1be1372141cf3447ea4c28208b60aeaa3ae03 #24467