Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2008-01-08 Thread Konrad Hinsen
On Jan 7, 2008, at 19:57, Travis E. Oliphant wrote: > Alternatively, the generic scalar operations should probably not be so > "inclusive" and should allow the other object a chance to perform the > operation more often (by returning NotImplemented). That would be great. In fact, this has been (a

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2008-01-07 Thread Travis E. Oliphant
Bruce Sherwood wrote: > Okay, I've implemented the scheme below that was proposed by Scott > Daniels on the VPython mailing list, and it solves my problem. It's also > much faster than using numpy directly: even with the "def "and "if" > overhead: sqrt(scalar) is over 3 times faster than the num

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2008-01-02 Thread Christopher Barker
Robert Kern wrote: > Bruce Sherwood wrote: >> There is also the question of >> whether it would pay for numpy to make what is probably an exceedingly >> fast check and do much faster calculations of sqrt(scalar) and other >> such mathematical functions. > > There is no question that it would pa

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-29 Thread Robert Kern
Bruce Sherwood wrote: > There is also the question of > whether it would pay for numpy to make what is probably an exceedingly > fast check and do much faster calculations of sqrt(scalar) and other > such mathematical functions. There is no question that it would pay. It takes time and effort t

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-29 Thread Bruce Sherwood
Okay, I've implemented the scheme below that was proposed by Scott Daniels on the VPython mailing list, and it solves my problem. It's also much faster than using numpy directly: even with the "def "and "if" overhead: sqrt(scalar) is over 3 times faster than the numpy sqrt, and sqrt(array) is v

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-29 Thread Bruce Sherwood
I found by timing measurements that a faster scheme with less penalty for the case of sqrt(array) looks like this: def sqrt(x): if type(x) is float: return mathsqrt(x) return numpysqrt(x) Bruce Sherwood wrote: > Roman Yakovenko wrote: >> On Dec 29, 2007 7:47 AM, Bruce Sherwood <[EMAIL

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-29 Thread Bruce Sherwood
Roman Yakovenko wrote: > On Dec 29, 2007 7:47 AM, Bruce Sherwood <[EMAIL PROTECTED]> wrote: > >> I realized belatedly that I should upgrade from Boost 1.33 to 1.34. >> Alas, that didn't cure my problem. >> > Can you post small and complete example of what you are trying to achieve? > I d

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-28 Thread Bruce Sherwood
I realized belatedly that I should upgrade from Boost 1.33 to 1.34. Alas, that didn't cure my problem. Bruce Sherwood Bruce Sherwood wrote: > I should have added: This structure worked with the older version of > VPython which used Numeric, but it doesn't work in the beta version > which uses

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-27 Thread Kevin Jacobs <[EMAIL PROTECTED]>
Hi Bruce, I have to add that I don't know the answer to your question either, but I do know that it is solvable and that once the list experts return, enlightenment will soon follow. My confidence comes from knowing the Python internals for how left and right multiplication are performed. As lon

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-27 Thread Bruce Sherwood
I should have added: This structure worked with the older version of VPython which used Numeric, but it doesn't work in the beta version which uses numpy. Since I don't know enough about either numpy or Boost, I'm left guessing which subsystem is the source of my difficulties, and clueless abou

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-27 Thread Bruce Sherwood
Thanks for the comment, which limits the range of possible solutions. The VPython vector class is implemented in C++, not in Python. I made up the simple test in my previous note to try out the solution that had been offered and which you have usefully ruled out. Here is the relevant part of th

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-26 Thread Robert Kern
Bruce Sherwood wrote: > Thanks for the suggestion. It hadn't occurred to me to try to override > numpy as you suggest. However, when I try the code shown below as the > start of a test of this scheme, I get the following error: > > Traceback (most recent call last): > File "C:\Documents and Se

Re: [Numpy-discussion] [C++-sig] Overloading sqrt(5.5)*myvector

2007-12-26 Thread Bruce Sherwood
Thanks for the suggestion. It hadn't occurred to me to try to override numpy as you suggest. However, when I try the code shown below as the start of a test of this scheme, I get the following error: Traceback (most recent call last): File "C:\Documents and Settings\Bruce\My Documents\0VPytho