On Thursday 17 May 2007 03:02, Michel wrote:
> > > sage: %timeit ((x+y+z)**3)(1/y,y,y**100)
> > > 10 loops, best of 3: 752 ms per loop    <=== look here!
> > > sage: %timeit ((u+v+w)**3)(1/v,v,v**100)
> > > 10 loops, best of 3: 48.2 ms per loop  <=== look here!
> >
> > It's not at all clear to me without further discussion and benchmarking
> > what the right optimization is so that rational functions over fields are
> > sufficiently fast.
>
> My point was that the above command over a number field is 15 times
> as fast as over the rationals. This is so counterintuitive that
> I think it is unacceptable.
>
> > Basically, are you suggesting that one
> > not call reduce until, e.g., printing?
>
> There are several options.
> (1) declare reduce to be expensive so require the user to call it
> explicitly (this is the approach followed by maxima).
> As a refinement this behaviour could be triggered by a new flag for a
> ring element: gcd_is_expensive (e.g.
> for polynomials in several variables).
> (2) call reduce lazily and cache the result (this is what you are
> suggesting).

I think that the call to reduce can be made considerably faster.  I ran into 
this particular bottleneck one day and found an ugly hack which made a huge 
difference.  That was to check if the gcd(numerator,denominator) ==1 and 
immediately return.  It didn't make sense to me that such a thing wasn't 
already implemented so I didn't submit any patches.  The right code should 
somehow have that check built in a way that doesn't duplicate the logic of 
that gcd call when the gcd != 1.

I don't know that that would make your code any faster.  I'm just saying that 
the reduce call probably has a few very easy optimizations before heading for 
a design change.

--
Joel

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to