On May 14, 2009, at 3:56 PM, Lisandro Dalcin wrote: > I used to teach numerical calculus, so I cannot resist :-)
Thanks for the heads up--I deal mostly with exact arithmetic (e.g. when writing that code I had the gaussian integers in my head) so it's good to have an expert speak up. > The current implementation of complex division for the struct case is > the dangerous one, it uses: > > 2 divides > 6 multiplies > 3 additions > > A safer way, far less sensible to roundoff/overflow (looks at core > CPython's complexobject.c, and skip the checks for dividing by zero), > would likely require: > > 2 comparison > 3 divides > 3 multiplies > 3 additions > > So the key question is (having a serious headache right now, hope I > got the number above and below right): > > Are 2 comparison and 1 divide SLOWER than 3 multiplies ?? > > If the answer is NO, we should clearly use the SAFER implementation. > If the answer is YES, should we trade SPEED over roundoff/overflow > issues? No idea--please post some benchmarks. It looks like more than 2 comparisons, as one has to take absolute values too. Branching can be expensive, but it's clearly not obvious enough to tell just by talking about it. If they're close, safer is better for sure, otherwise we'll have to really have to weight the pros and cons. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
