[Numpy-discussion] matrix indexing question

Charles R Harris charlesr.harris at gmail.com
Mon Mar 26 15:51:36 EDT 2007


On 3/26/07, Alan G Isaac <aisaac at american.edu> 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.

Chuck

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.
>
> Cheers,
> Alan Isaac
>
>
>
>
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20070326/21928c8f/attachment.html>


More information about the NumPy-Discussion mailing list