Karim Belabas on Thu, 13 Mar 2014 00:01:53 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: reverse of digits()


* Max Alekseyev [2013-12-03 16:48]:
> Btw, is there a reason why sumdigits(), unlike digits(), does not have
> the second optional argument of base?

... now available for testing in development branch 

  origin/kb-digits

which 

- improves digits(x, B)  (by 10%-20% or so for general B, by orders of
  magnitude for B = 2^k, k > 1)

- implement sumdigits(x, {B = 10}) to sum digits in base B  (= 10 by default).

I didn't bother to optimize for other small bases than the default B = 10
or powers of 2 -- not even powers of 10:-) --; the algorithm is almost
linear time wrt input size anyway.

Cheers,

    K.B.

P.S. This patch won't be included in forthcoming release 2.7-stable:
it needs testing, and we're well into feature freeze time.
--
Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux1.fr/~kbelabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux1.fr/  [PARI/GP]
`