cephes.arraymap & multipack

Two questions: * Has anyone been using the arraymap function that's in Travis's cephes 1.2 module? I think this is an interesting idea: giving arbitrary python functions ufunc-like (array broadcasting) properties when given numpy array arguments. (I noticed the Pearu's multipack CVS module has only cephes 1.1 which seems to be missing arraymap) * Maybe I'm missing something, but is there any reason why multipack's functions are not implemented as ufuncs? For example, it would be useful to be able to use multipack.leastsq() along an axis of a 3-d array, or to use multipack.quad() over a 2 or 3-d space of integration parameters. -- Jon Moody

On Sat, 3 Feb 2001, Jon Moody wrote: [...]
* Maybe I'm missing something, but is there any reason why multipack's functions are not implemented as ufuncs? For example, it would be useful to be able to use multipack.leastsq() along an axis of a 3-d array, or to use multipack.quad() over a 2 or 3-d space of integration parameters. [...]
Not sure aboout the latter, but couldn't the former just be done by slicing? How does this relate to ufuncs? They were only intended to be simple wrappings around the FORTRAN / C I think, so I suspect Travis would say 'feel free to add it'. John

On Sun, Feb 04, 2001 at 02:45:51AM +0000, John J. Lee wrote:
Not sure aboout the latter, but couldn't the former just be done by slicing? How does this relate to ufuncs?
I'm probably being a little foggy on the distinction between the ufuncs (element-wise operations on arrays) and the array functions that sometimes allow you to specify an axis along which to apply the function. The problem I'm having with multipack.leastsq() is that the python function I supply as the model for the fit is expected to return a 1-d array or a single value. So if, for example, the independent variable is a 1-d array of shape (4,) and the data is a 3-d array of shape (4,256,256), to apply leastsq() along axis 0 you have to either loop in python or set things up so that you can map(leastsq, ....). It seems this kind of thing should properly be in the wrapper, and I would guess it should be in the C half of the wrapper for speed, unless there's some clever way to phrase it using native Numeric functions from python.
They were only intended to be simple wrappings around the FORTRAN / C I think, so I suspect Travis would say 'feel free to add it'.
Maybe I should try. Is there any general objection (don't all barf at once) to using Fortran for an wrapper via pyfort (I don't know C)? -- Jon Moody
participants (2)
-
John J. Lee
-
Jon Moody