[Numpy-discussion] Re: indexing problem
Ryan Krauss
ryanlists at gmail.com
Mon Feb 13 21:21:01 CST 2006
I think that would be great, but is there any chance there would be a
problem with the scenario Tim posted earlier: If a script was running
some sort of optimization on x**y, could the y value ever actually be
returned as an integer and could that throw off the optimization if
round off error caused the float version returned a significantly
different value than the integer version?
Ryan
On 2/13/06, Gary Ruben <gruben at bigpond.net.au> wrote:
> Hi David,
> So, I think what you had done would be OK provided you removed the
> x**0.5 case to avoid the problem Tim raised and checked that the
> exponent is an integer, not just a scalar.
> Does anyone see a problem with this approach.
> Gary R.
>
> David M. Cooke wrote:
> > Gary Ruben <gruben at bigpond.net.au> writes:
> >
> >> Tim Hochberg wrote:
> >> <snip>
> >>> However, I'm not convinced this is a good idea for numpy. This would
> >>> introduce a discontinuity in a**b that could cause problems in some
> >>> cases. If, for instance, one were running an iterative solver of
> >>> some sort (something I've been known to do), and b was a free
> >>> variable, it could get stuck at b = 2 since things would go
> >>> nonmonotonic there.
> >> I don't quite understand the problem here. Tim says Python special
> >> cases integer powers but then talks about the problem when b is a
> >> floating type. I think special casing x**2 and maybe even x**3 when
> >> the power is an integer is still a good idea.
> >
> > Well, what I had done with Numeric did special case x**0, x**1,
> > x**(-1), x**0.5, x**2, x**3, x**4, and x**5, and only when the
> > exponent was a scalar (so x**y where y was an array wouldn't be). I
> > think this is very useful, as I don't want to microoptimize my code to
> > x*x instead of x**2. The reason for just scalar exponents was so
> > choosing how to do the power was lifted out of the inner loop. With
> > that, x**2 was as fast as x*x.
> >
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
More information about the Numpy-discussion
mailing list