Re: [Numpy-discussion] Subclassing record array

2009-10-17 Thread Charles R Harris
On Sat, Oct 17, 2009 at 9:13 AM, Loïc BERTHE wrote: > Hi, > > I would like to create my own class of record array to deal with units. > > Here is the code I used, inspired from > > http://docs.scipy.org/doc/numpy-1.3.x/user/basics.subclassing.html#slightly-more-realistic-example-attribute-added

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread josef . pktd
On Sat, Oct 17, 2009 at 8:00 PM, wrote: > On Sat, Oct 17, 2009 at 7:46 PM, Charles R Harris > wrote: >> >> >> On Sat, Oct 17, 2009 at 5:27 PM, wrote: >>> >>> On Sat, Oct 17, 2009 at 2:02 PM, Charles R Harris >>> wrote: >>> > >>> > >>> > On Sat, Oct 17, 2009 at 11:54 AM, wrote: >>> >> >>> >> O

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread josef . pktd
On Sat, Oct 17, 2009 at 7:46 PM, Charles R Harris wrote: > > > On Sat, Oct 17, 2009 at 5:27 PM, wrote: >> >> On Sat, Oct 17, 2009 at 2:02 PM, Charles R Harris >> wrote: >> > >> > >> > On Sat, Oct 17, 2009 at 11:54 AM, wrote: >> >> >> >> On Sat, Oct 17, 2009 at 1:20 PM, Charles R Harris >> >> w

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread Charles R Harris
On Sat, Oct 17, 2009 at 5:27 PM, wrote: > On Sat, Oct 17, 2009 at 2:02 PM, Charles R Harris > wrote: > > > > > > On Sat, Oct 17, 2009 at 11:54 AM, wrote: > >> > >> On Sat, Oct 17, 2009 at 1:20 PM, Charles R Harris > >> wrote: > >> > > >> > > >> > On Sat, Oct 17, 2009 at 9:36 AM, per freem > w

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread josef . pktd
On Sat, Oct 17, 2009 at 2:02 PM, Charles R Harris wrote: > > > On Sat, Oct 17, 2009 at 11:54 AM, wrote: >> >> On Sat, Oct 17, 2009 at 1:20 PM, Charles R Harris >> wrote: >> > >> > >> > On Sat, Oct 17, 2009 at 9:36 AM, per freem wrote: >> >> >> >> hi all, >> >> >> >> in my code, i use the functi

Re: [Numpy-discussion] Another suggestion for making numpy's functions generic

2009-10-17 Thread Charles R Harris
On Sat, Oct 17, 2009 at 6:49 AM, Darren Dale wrote: > numpy's functions, especially ufuncs, have had some ability to support > subclasses through the ndarray.__array_wrap__ method, which provides > masked arrays or quantities (for example) with an opportunity to set > the class and metadata of th

Re: [Numpy-discussion] double-precision sqrt?

2009-10-17 Thread Adam Ginsburg
Hi again, I apologize, the mistake was entirely my own. Sqrt's do the right thing Adam On Sat, Oct 17, 2009 at 12:17 PM, Adam Ginsburg wrote: > My code is actually wrong but I still have the problem I've > identified that sqrt is leading to precision errors.  Sorry about the > earlier m

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread Charles R Harris
On Sat, Oct 17, 2009 at 12:59 PM, Charles R Harris < charlesr.har...@gmail.com> wrote: > > > On Sat, Oct 17, 2009 at 12:40 PM, Neal Becker wrote: > >> Somewhat offtopic, but is there a generalization of the logsumexp shortcut >> to more than 2 variables? >> >> IIRC, it's this for 2 variables: >>

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread Charles R Harris
On Sat, Oct 17, 2009 at 12:40 PM, Neal Becker wrote: > Somewhat offtopic, but is there a generalization of the logsumexp shortcut > to more than 2 variables? > > IIRC, it's this for 2 variables: > log (exp (a) + exp (b)) = max (a,b) + log (1 + exp (-abs (a-b))) > > logaddexp.reduce will apply it

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread Neal Becker
Somewhat offtopic, but is there a generalization of the logsumexp shortcut to more than 2 variables? IIRC, it's this for 2 variables: log (exp (a) + exp (b)) = max (a,b) + log (1 + exp (-abs (a-b))) ___ NumPy-Discussion mailing list NumPy-Discussion@sc

Re: [Numpy-discussion] double-precision sqrt?

2009-10-17 Thread Anne Archibald
2009/10/17 Adam Ginsburg : > My code is actually wrong but I still have the problem I've > identified that sqrt is leading to precision errors.  Sorry about the > earlier mistake. I think you'll find that numpy's sqrt is as good as it gets for double precision. You can try using numpy's float9

Re: [Numpy-discussion] double-precision sqrt?

2009-10-17 Thread Charles R Harris
On Sat, Oct 17, 2009 at 12:08 PM, Adam Ginsburg wrote: > Hi folks, > I'm trying to write a ray-tracing code for which high precision is > required. I also "need" to use square roots. However, math.sqrt and > numpy.sqrt seem to only use single-precision floats. Is there a > simple way to make

Re: [Numpy-discussion] double-precision sqrt?

2009-10-17 Thread Nadav Horesh
The default precision is double unless yue specify otherwise (float32 or long double (float128 or float96)) You can see this from: f(fsolve(f,1.01)) # 1.7763568394002505e-15 The last line should be: >>> fsolve(f,1.01) - float64(1.034324523462345) 8.8817841970012523e-16 Nadav -הודעה מ

Re: [Numpy-discussion] double-precision sqrt?

2009-10-17 Thread Dag Sverre Seljebotn
Adam Ginsburg wrote: > Hi folks, >I'm trying to write a ray-tracing code for which high precision is > required. I also "need" to use square roots. However, math.sqrt and > numpy.sqrt seem to only use single-precision floats. Is there a > simple way to make sqrt use higher precision? Altern

Re: [Numpy-discussion] double-precision sqrt?

2009-10-17 Thread Adam Ginsburg
My code is actually wrong but I still have the problem I've identified that sqrt is leading to precision errors. Sorry about the earlier mistake. Adam On Sat, Oct 17, 2009 at 12:08 PM, Adam Ginsburg wrote: > > sqrt(float64(1.034324523462345)) > # 1.0170174646791199 > f=lambda x: x**2-float6

[Numpy-discussion] double-precision sqrt?

2009-10-17 Thread Adam Ginsburg
Hi folks, I'm trying to write a ray-tracing code for which high precision is required. I also "need" to use square roots. However, math.sqrt and numpy.sqrt seem to only use single-precision floats. Is there a simple way to make sqrt use higher precision? Alternately, am I simply being obtuse

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread Charles R Harris
On Sat, Oct 17, 2009 at 11:54 AM, wrote: > On Sat, Oct 17, 2009 at 1:20 PM, Charles R Harris > wrote: > > > > > > On Sat, Oct 17, 2009 at 9:36 AM, per freem wrote: > >> > >> hi all, > >> > >> in my code, i use the function 'logsumexp' from scipy.maxentropy a > >> lot. as far as i can tell, this

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread josef . pktd
On Sat, Oct 17, 2009 at 1:20 PM, Charles R Harris wrote: > > > On Sat, Oct 17, 2009 at 9:36 AM, per freem wrote: >> >> hi all, >> >> in my code, i use the function 'logsumexp' from scipy.maxentropy a >> lot. as far as i can tell, this function has no vectorized version >> that works on an m-x-n m

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread Charles R Harris
On Sat, Oct 17, 2009 at 9:36 AM, per freem wrote: > hi all, > > in my code, i use the function 'logsumexp' from scipy.maxentropy a > lot. as far as i can tell, this function has no vectorized version > that works on an m-x-n matrix. i might be doing something wrong here, > but i found that this f

Re: [Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread Keith Goodman
On Sat, Oct 17, 2009 at 8:36 AM, per freem wrote: > hi all, > > in my code, i use the function 'logsumexp' from scipy.maxentropy a > lot. as far as i can tell, this function has no vectorized version > that works on an m-x-n matrix. i might be doing something wrong here, > but i found that this fu

[Numpy-discussion] vectorized version of logsumexp? (from scipy.maxentropy)

2009-10-17 Thread per freem
hi all, in my code, i use the function 'logsumexp' from scipy.maxentropy a lot. as far as i can tell, this function has no vectorized version that works on an m-x-n matrix. i might be doing something wrong here, but i found that this function can run extremely slowly if used as follows: i have an

[Numpy-discussion] Subclassing record array

2009-10-17 Thread Loïc BERTHE
Hi, I would like to create my own class of record array to deal with units. Here is the code I used, inspired from http://docs.scipy.org/doc/numpy-1.3.x/user/basics.subclassing.html#slightly-more-realistic-example-attribute-added-to-existing-array : [code] from numpy import * class BlocArra

[Numpy-discussion] Another suggestion for making numpy's functions generic

2009-10-17 Thread Darren Dale
numpy's functions, especially ufuncs, have had some ability to support subclasses through the ndarray.__array_wrap__ method, which provides masked arrays or quantities (for example) with an opportunity to set the class and metadata of the output array at the end of an operation. An example is q1 =

Re: [Numpy-discussion] object array alignment issues

2009-10-17 Thread Francesc Alted
A Friday 16 October 2009 18:05:05 Sturla Molden escrigué: > Francesc Alted skrev: > > The response is clear: avoid memcpy() if you can. It is true that > > memcpy() performance has improved quite a lot in latest gcc (it has been > > quite good in Win versions since many years ago), but working wit