#10596: Misc improvements to arithmetic
--------------------------------+-------------------------------------------
   Reporter:  spancratz         |       Owner:  AlexGhitza  
       Type:  enhancement       |      Status:  needs_review
   Priority:  major             |   Milestone:  sage-4.6.2  
  Component:  basic arithmetic  |    Keywords:              
     Author:  spancratz         |    Upstream:  N/A         
   Reviewer:                    |      Merged:              
Work_issues:                    |  
--------------------------------+-------------------------------------------
Changes (by spancratz):

  * status:  new => needs_review


Old description:

> Generic code clean-up such as line breaks, empty lines, use of GMP
> functions etc
>
> ``n.digits()``
>
> Before:
> {{{
> sage: n = 10**10000000-10**9999990
> sage: timeit('n.ndigits()')
> 625 loops, best of 3: 46.6 µs per loop
> sage: timeit('(-n).ndigits()')
> 25 loops, best of 3: 9.04 ms per loop
> }}}
> {{{
> sage: ZZ(0).ndigits()
> 0
> sage: ZZ(0).ndigits(base=2)
> 0
> sage: ZZ(0).nbits()
> 1
> }}}
>
> After:
> {{{
> sage: n = 10**10000000-10**9999990
> sage: timeit('n.ndigits()')
> 625 loops, best of 3: 1.02 µs per loop
> sage: timeit('(-n).ndigits()')
> 125 loops, best of 3: 4.57 ms per loop
> }}}
> {{{
> sage: ZZ(0).ndigits()
> 1
> sage: ZZ(0).ndigits(base=2)
> 1
> sage: ZZ(0).nbits()
> 1
> }}}
>
> Before:
> {{{
> sage: x = factorial(2**14)
> sage: timeit('y = odd_part(x)')
> 625 loops, best of 3: 10.6 µs per loop
> }}}
> {{{
> sage: odd_part(0)
> ---------------------------------------------------------------------------
> ...
> TypeError: unsupported operands for >>: 0, +Infinity
> }}}
> After:
> {{{
> sage: x = factorial(2**14)
> sage: timeit('y = x.odd_part()')
> 625 loops, best of 3: 4.52 µs per loop
> }}}
> {{{
> sage: ZZ(0).odd_part()
> 0
> }}}

New description:

 Generic code clean-up such as line breaks, empty lines, use of GMP
 functions etc

 ``n.digits()``

 Before:
 {{{
 sage: ZZ(0).ndigits()
 0
 sage: ZZ(0).ndigits(base=2)
 0
 sage: ZZ(0).nbits()
 1
 }}}

 After:
 {{{
 sage: ZZ(0).ndigits()
 1
 sage: ZZ(0).ndigits(base=2)
 1
 sage: ZZ(0).nbits()
 1
 }}}

 Before:
 {{{
 sage: x = factorial(2**14)
 sage: timeit('y = odd_part(x)')
 625 loops, best of 3: 10.6 µs per loop
 }}}
 {{{
 sage: odd_part(0)
 ---------------------------------------------------------------------------
 ...
 TypeError: unsupported operands for >>: 0, +Infinity
 }}}
 After:
 {{{
 sage: x = factorial(2**14)
 sage: timeit('y = x.odd_part()')
 625 loops, best of 3: 4.52 µs per loop
 }}}
 {{{
 sage: ZZ(0).odd_part()
 0
 }}}

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10596#comment:2>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to