[Numpy-discussion] matrix wart
Christopher Barker
Chris.Barker@noaa....
Fri Feb 22 10:48:46 CST 2008
Travis E. Oliphant wrote:
> to behave as you described in your previous post: where M[i] returned a
> 1-d array
My thoughts on this:
As Konrad suggested, row vectors and column vectors are different beasts
,and both need to be easily and intuitively available.
M[i] returning a 1-d array breaks this -- that's what raw numpy arrays
do, and I like it, but it's not so natural for linear algebra. If we
really want to support matrixes, then no, M[i] should not return a 1-d
array -- what is a 1-d array mean in the matrix/linear algebra context?
It makes me think that M[i] should not even be possible, as you would
always want one of:
row vector: M[i,:]
column vector: M[:,i]
element: M[i,j]
I do like the idea of a row/column vectors being different objects than
matrices, then you could naturally index the elements from them.
If you really want a 1-d array, you can always do:
M.A[i]
What if you want to naturally iterate through all the rows, or all the
columns? what about:
for row in M.rows
for column in M.columns
M.rows and M.columns would be iterators.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
More information about the Numpy-discussion
mailing list