Menu

#395 ipow (integer exponentiation) support for 64bit index support

normal
closed-fixed
None
5
2015-11-23
2015-08-31
No

PDL doesn't support integer exponentiation (it uses the pow() function and generic type D).
This causes problems for calculations like this:

$bignum = longlong(2)**55;

$bignum is type double and the value is rounded. It would be helpful if PDL supported
binary exponentiation for integer data types and/or exponent values. At the moment,
an ipow() implementation using repeated squares and multiplies would be nice to
have even without seamless handling of the various edge cases to do what I mean.

Ideally this would be added to the longlong-double-fix branch before merging into master
for a CPAN release.

Discussion

  • Chris Marshall

    Chris Marshall - 2015-09-21

    NOTE: that without arbitrary precision integer support, the range of exponents to calculate is very limited with the greatest being for powers of 2 where the largest exponent is 64. Hence this is the largest exact value needed to calculate by ipow(), ~7bits binary. If one takes advantage of the range of values for which the double precision result of pow() is exact, then the ipow() calculation would only be needed for less than 12 or so integer values.

     
  • Chris Marshall

    Chris Marshall - 2015-09-22

    Attached is a perl implementation from Wikipedia that only works for scalar values at the moment. Needs to be modified to support pdl arguments.

     
  • Chris Marshall

    Chris Marshall - 2015-10-06
    • status: open --> pending-fixed
    • assigned_to: Chris Marshall
     
  • Chris Marshall

    Chris Marshall - 2015-10-06

    A basic ipow() PDL::PP implementation is in git master and will appear in the next CPAN release.

     
  • Chris Marshall

    Chris Marshall - 2015-11-23
    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.