Opened 4 years ago

Last modified 3 years ago

#26589 needs_work enhancement

allow custom multiplication function in power

Reported by: vdelecroix Owned by:
Priority: major Milestone: sage-8.5
Component: basic arithmetic Keywords:
Cc: cpernet, jdemeyer Merged in:
Authors: Vincent Delecroix Reviewers: Daniel Krenn
Report Upstream: N/A Work issues:
Branch: u/vdelecroix/26589 (Commits, GitHub, GitLab) Commit: 6a86800c69eaa378bdabdff46f116f8b4d74d8f0
Dependencies: Stopgaps:

Status badges


Add an option in sage.arith.power.generic_power for custom multiplication function.

Change History (6)

comment:1 Changed 4 years ago by vdelecroix

  • Branch set to u/vdelecroix/26589
  • Commit set to b026a18b8f52ac559b0b22409397c68628c45c3f
  • Status changed from new to needs_review

New commits:

9dc0772patch for openblas
b026a1826589: custom mul/inv functions in generic power

comment:2 Changed 4 years ago by git

  • Commit changed from b026a18b8f52ac559b0b22409397c68628c45c3f to 6a86800c69eaa378bdabdff46f116f8b4d74d8f0

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

6a8680026589: custom mul/inv functions in generic power

comment:3 Changed 4 years ago by jdemeyer

It would be cool if you could pass a C function pointer. That way, you would strictly generalize the existing code (using PyNumber_Multiply in place of *).

comment:4 Changed 4 years ago by vdelecroix


comment:5 Changed 3 years ago by dkrenn

  • Reviewers set to Daniel Krenn
  • Status changed from needs_review to needs_work

Looks almost good to me, three very minor comments:

  1. Is this kind of a convention to name function with postfix 2?
     cdef generic_power_pos(a, ulong_or_object n)  # n > 0
    +cdef generic_power_pos2(a, ulong_or_object n, mul)
    Could something more descriptive be found easily?
  1. parameter is called inv, isn't it?
    +    - ``invert`` -- an optional function for inversion (only used
  1. This is more like a question:
    +cdef generic_power_pos2(a, ulong_or_object n, mul):
    +    """
    +    Return `a^n` where `n > 0`.
    +    """
    Are there no doctests required here? What is the rule? (Coverage is happy)

comment:6 Changed 3 years ago by vdelecroix

I think that comment:3 should also be considered. But we thought about it and did not arrive to any reasonable conclusion.

Note: See TracTickets for help on using tickets.