[Numpy-discussion] Broadcasting rules (Ticket 76).
Keith Goodman
kwgoodman at gmail.com
Thu Apr 27 11:05:03 EDT 2006
On 4/27/06, Sasha <ndarray at mac.com> wrote:
> On 4/27/06, Keith Goodman <kwgoodman at gmail.com> wrote:
> > [...]
> > In Octave or Matlab, all you need to do is sum(x,1). For example:
> >
> > >> x = rand(1,4)
> > x =
> >
> > 0.56755 0.24575 0.53804 0.36521
> >
> > >> sum(x,1)
> > ans =
> >
> > 0.56755 0.24575 0.53804 0.36521
> >
>
> How is this different from Numpy:
>
> >>> x = matrix(rand(4))
> >>> sum(x.T, 1)
> matrix([[ 0.36186805],
> [ 0.90198107],
> [ 0.60407661],
> [ 0.49523327]])
>
Exactly. That's why the OP doesn't need to write a special function in
Matlab called SumColumns.
More information about the NumPy-Discussion
mailing list