[Numpy-discussion] matrix indexing question
Charles R Harris
Mon Mar 26 14:51:36 CDT 2007
On 3/26/07, Alan G Isaac <firstname.lastname@example.org> wrote:
> On Mon, 26 Mar 2007, "Colin J. Williams" apparently wrote:
> > One would expect the iteration over A to return row
> > vectors, represented by (1, n) matrices.
> This is again simple assertion.
> **Why** would "one" expect this?
> Some people clearly do not.
Well, and what *should* they expect. I think it is expected because the for
iterates over rows and rows of matrices are 1xn. Matrices and arrays, as has
been stated, are different animals. Probably it would have been best to
stick with arrays and I suspect that matrices appeared because of the dearth
of Python operators, in particular to make matrix multiplication simpler. On
the other hand, certain errors slip by when one is implementing matrix
algebra with arrays, but they can be avoided by never using 1-d vectors. So
all this mess results from catering to the matrix community. Matlab has the
opposite problem, multidimensional arrays were tacked on later and they
don't operate properly with everything.
One person commented that this unexpected behavior was
> a source of error in their code.
> Another person commented that they did not even guess that
> such a thing would be possible.
> Experience with Python should lead to the ability to
> anticipate the outcome. Apparently this is not the case.
> That suggests a design problem.
> What about **Python** would lead us to expect this behavior??
> In *contrast*, everyone agrees that for a matrix M,
> we should get a matrix from M[0,:].
> This is expected and desirable.
> Alan Isaac
> Numpy-discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion