[Numpy-discussion] Apply a vector function to each row of a matrix
Thu Oct 9 13:48:57 CDT 2008
David Huard wrote:
> On Thu, Oct 9, 2008 at 9:40 AM, Neal Becker <email@example.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:
>> b[row,:] = apply_along_axis (func, row, a)
>> I don't suppose there is a way to do this without explicitly writing a
> Have you tried
> b = apply_along_axis(func, 1, a)
> It should work.
The doc for apply_along_axis is not clear.
For one thing, it says:
The output array. The shape of outarr depends on the return value of func1d. If it returns arrays with the same shape as the input arrays it receives, outarr has the same shape as arr.
What happens if the 'if' clause is not true?
More information about the Numpy-discussion