[Numpy-discussion] matrix indexing question
Bill Spotz
wfspotz at sandia.gov
Thu Mar 29 18:13:44 EDT 2007
What I envisioned was that M[i,:] would return a row_vector and M
[:,j] would return a column_vector, because this would be symmetric
behavior. M[i], by convention, would behave the same as M[i,:].
But then I personally don't distinguish between "python indexing" and
"numpy indexing". In both cases, __getitem__() (or __setitem__()) is
called. For multiple indexes, the index object is a tuple.
In any case, the behavior of "numpy indexing" as I have proposed it
would return an object that inherits from matrix, thus would BE a
matrix, although it would behave like an array.
On Mar 29, 2007, at 3:24 PM, Alan G Isaac wrote:
> On Tue, 27 Mar 2007, Zachary Pincus apparently wrote:
>> Now, Bill offers up a different suggestion: indexing
>> M yields neither a matrix nor an array, but a class that
>> operates more or less like an array, except insofar as it
>> interacts with other matrix objects, or other objects of
>> similar classes. I'm interested in hearing more about
>> this, what trade-offs or other compromises it might
>> involve.
>
> So would you agree that in this case M[0] and M[0,:] would
> have to be different things? Or would you then want even
> such numpy indexing not to produce matrices??
>
> Cheers,
> Alan Isaac
** Bill Spotz **
** Sandia National Laboratories Voice: (505)845-0170 **
** P.O. Box 5800 Fax: (505)284-5451 **
** Albuquerque, NM 87185-0370 Email: wfspotz at sandia.gov **
More information about the NumPy-Discussion
mailing list