Opened 14 years ago

Closed 13 years ago

#5652 closed defect (duplicate)

powermod is slower than Integer.power_mod

Reported by: Jonathan Bober Owned by: somebody
Priority: minor Milestone: sage-duplicate/invalid/wontfix
Component: basic arithmetic Keywords:
Cc: Minh Van Nguyen, William Stein Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

Consider the following example:

sage: time a = power_mod(5, 10^2000, 10^3000)
CPU times: user 3.67 s, sys: 0.00 s, total: 3.67 s
Wall time: 3.67 s
sage: time b = 5.powermod(10^2000, 10^3000)  
CPU times: user 2.82 s, sys: 0.00 s, total: 2.83 s
Wall time: 2.84 s
sage: a == b
True
sage: time a = power_mod(5, 10^4000, 10^7000)
CPU times: user 27.17 s, sys: 0.01 s, total: 27.18 s
Wall time: 27.30 s
sage: time b = 5.powermod(10^4000, 10^7000)  
CPU times: user 21.38 s, sys: 0.04 s, total: 21.42 s
Wall time: 21.44 s
sage: a == b
True

(The problem is that power_mod() uses generic code, while Integer.powermod() uses gmp, which is faster.)

Change History (3)

comment:1 Changed 13 years ago by Burcin Erocal

Cc: Minh Van Nguyen William Stein added
Summary: powermod is slower than Integer.power_mod[duplicate] powermod is slower than Integer.power_mod

This is a duplicate of #5082.

I suggest it is closed as a duplicate. Since trac doesn't let me, Minh or William, as release managers, can you close this?

comment:2 in reply to:  1 Changed 13 years ago by Minh Van Nguyen

Replying to burcin:

This is a duplicate of #5082.

I suggest it is closed as a duplicate. Since trac doesn't let me, Minh or William, as release managers, can you close this?

I don't have admin privileges on trac, so I can't close tickets at the moment. I've merged about 5 tickets so far, but their status has not been set accordingly.

comment:3 Changed 13 years ago by Minh Van Nguyen

Milestone: sage-4.1.1sage-duplicate/invalid/wontfix
Resolution: duplicate
Status: newclosed
Summary: [duplicate] powermod is slower than Integer.power_modpowermod is slower than Integer.power_mod
Note: See TracTickets for help on using tickets.