On Sun, May 11, 2008 at 12:44 PM, Charles R Harris <[EMAIL PROTECTED]> wrote: > On Sun, May 11, 2008 at 1:01 PM, Keith Goodman <[EMAIL PROTECTED]> wrote: >> >> The most basic, and the most contentious, design decision of a new >> matrix class is matrix indexing. There seems to be two camps: >> >> 1. The matrix class should be more like the array class. In particular >> x[0,:] should return a 1d array or a 1d array like object that >> contains the orientation (row or column) as an attribute and x[0] >> should return a 1d array. (Is x.sum(1) also a 1d array like object?) >> >> 2. A matrix is a matrix: all operations on a matrix, including >> indexing, should return a matrix or a scalar. >> >> Does that describe the two approaches to matrix indexing? Are there >> other approaches? >> _________ > > Pretty well, I think. The thing about 2) is that ndarray routines break if > they can't treat arrays as nested sequences, i.e. scalar indexing needs to > return an array of one less dimension. So the matrix class shouldn't > subclass ndarray in that case, but rather should use an ndarray as a > component. More code to write, but such is life. > > 3) Everything is an array. I think Matlab treats scalars as 1x1 arrays.
So #3 is behave in a similar way to octave/matlab? In octave/matlab 1x1 matrices are handled in special ways, e.g. (nxm) * (1x1) is allowed. From the perspective of the user a 1x1 matrix is a scalar. _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion