On Apr 6, 2010, at 11:22 PM, Rolandb wrote:
Hi, some experiences.
I moved from Vista 32 to Windows 7 64 during Easter. I have a Q6700
PC.
Three issues are maybe of general interest.
1) Virtualbox 4.3.4: A clumsy environment so I switched back to (the
new) VMware player 3.01 and (the old) Sage 4.1. Now I was positively
surprised how cool Sage works, and also the fact that I could run
multiple Sage sessions all calculating ... But maybe my Virtualbox
isn't properly installed?
Probably, though Virtualbox is rough around the edges (as are all
options of running Sage on Windows).
2) I hoped for a considerable increase in speed, because 64bit
optimized c code or assembly instructions are superior to 32bit. So I
tested a few simple operations, and I noticed hardly any improvement!
Did I installed the wrong version of Sage 4.1? I used sage-
vmware-4.1.7z.
Without recompiling for your machine, you won't be able to fully take
advantage of all it has to offer. In any case, you're running it
inside a VM which is probably fixed to be either 32 or 64 bit.
3) Whilst looking for "need for speed", I found that many relatively
simple standard sage functions aren't optimized. For instance
CRT_list(v,moduli)?? states:
if len(v) == 0:
return 0
x = v[0]
m = moduli[0]
for i in range(1,len(v)):
x = CRT(x,v[i],m,moduli[i])
m *= moduli[i]
return x%m
And CRT(a,b,m,n)??:
if isinstance(a,list):
return CRT_list(a,b)
g, alpha, beta = XGCD(m,n)
if g != 1:
raise ValueError, "arguments a and b must be coprime"
return a+(b-a)*alpha*m
Just combining both gives:
def crt_faster(v,moduli):
x = v[0]
m = moduli[0]
for i in range(1,len(v)):
x +=(v[i]-x)*xgcd(m,moduli[i])[1]*m
m *= moduli[i]
return x%m
This improves speed by a factor of 1.5 to 2.
I'm assuming you're timing very small examples?
- Is there in the near future an effort to optimize those relatively
simple, but probably often used, routines?
Yes, you just did it :) We'd love for you to submit a patch. There's
tons of stuff in Sage that could use optimization and cleanup (and
sage/rings/arith.py is high on the list). Often what happens is
someone needs some functionality, so they implement it, and then later
someone else needs it to be fast, so they optimize it.
Some areas for future improvement may be using CRT_basis, and it's
asymptotically faster (for a single call at least) to to CRT in a
binary tree rather than linearly.
- What is the best way to check the most efficient routine? Installing
packages like FLINT?
FLINT is installed by default already. If your list consists of
elements of Z[x], it will be used already under the hood.
- Robert
--
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-support
URL: http://www.sagemath.org
To unsubscribe, reply using "remove me" as the subject.