#19792: Implement get_data for is_power_of
--------------------------------+----------------------------
Reporter: vdelecroix | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-7.0
Component: basic arithmetic | Keywords:
Merged in: | Authors:
Reviewers: | Report Upstream: N/A
Work issues: | Branch:
Commit: | Dependencies:
Stopgaps: |
--------------------------------+----------------------------
The method `is_power_of` of integers does not allow to get the actual
power. We introduce an option `get_data` in order that `n.is_power_of(m)`
returns the number `b` so that `n = m^b`. The name of the option is
inspired from `is_prime_power`
{{{
sage: 16.is_prime_power()
True
sage: 16.is_prime_power(get_data=True)
(2, 4)
}}}
Moreover, it is not clear that `fmpz_remove` currently used in
`_is_power_of` is the fastest way of checking whether an integer is a
power of another.
Alternative: one can implement `n.logrem(b)` similar to `sqrtrem` that
returns the pair of integers `(m,r)` so that `n = b^m + r` where `0 <= r <
b^m+1 - b^m`
Remark: there exists in FLINT `fmpz_flog` and `fmpz_clog` that returns the
floor and the ceil of the logarithm in a given base (assuming that it fits
into an `slong`).
--
Ticket URL: <http://trac.sagemath.org/ticket/19792>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.