|
From: Gary R. <gr...@bi...> - 2006-02-16 01:24:25
|
Tim Hochberg wrote: >> optimize: >> >> A**2, A**(2+0j), etc > > > I'm guessing here that you did not mean to include (2+0j) on both lists > and that, in fact you wanted not to optimize on complex exponents: Oops. The complex index in the optimise list has integer parts. I assumed Python distinguished between complex numbers with integer and real parts, but it doesn't, so you're correct about which cases I'd vote to optimise. > So, optimize: > > A**-1, A**0, A**1, A**2, etc. > >> >> and >> >> A**array([1,2,3]) >> >> but not >> >> A**array[1.0, 2.0, 3.0], A**2.0, A**(2.0+0j) > > > That makes sense. It's safer and easier to explain: "numpy optimizes > raising matrices (and possibly scalars) to integer powers)". The only > sticking point that I see is if David is still interested in optimizing > A**0.5, that's not going to mesh with this. On the other hand, perhaps > he can be persuaded that sqrt(A) is just as good. After all, it's only > one more character long ;) > > -tim |