[Numpy-discussion] Apply a vector function to each row of a matrix

David Huard david.huard@gmail....
Thu Oct 9 12:01:33 CDT 2008


On Thu, Oct 9, 2008 at 9:40 AM, Neal Becker <ndbecker2@gmail.com> wrote:

> David Huard wrote:
>
> > Neal,
> >
> > Look at: apply_along_axis
> >
> >
> I guess it'd be:
>
> b = empty_like(a)
> for row in a.shape[0]:
>  b[row,:] = apply_along_axis (func, row, a)
>

> I don't suppose there is a way to do this without explicitly writing a
> loop.


Have you tried

b = apply_along_axis(func, 1, a)

It should work.


>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081009/6b8038c3/attachment.html 


More information about the Numpy-discussion mailing list