[Numpy-discussion] matrices in 1.1
Alan G Isaac
Sat Mar 22 11:49:36 CDT 2008
On Sat, 22 Mar 2008, Stéfan van der Walt apparently wrote:
> maybe you can post a link as a reminder
> In the matrix world, everything has a minimum dimension of
> 2, so I don't see how you can contain ndarrays in
> a matrix.
Are you trying to suggest that in most matrix programming
languages if you extract a row you will then need to use two
indices to extract an element of that row? This does not
match my experience. I would ask you to justify that by
listing the languages you have in mind.
Additionally, you surely see how you "can" do this.
But as someone who does not use matrices much,
you have an *abstract* objection to allowing this desirable
functionality. (As far as I can tell, this objection is
grounded in how you have chosen to think about matrices as
mathematical objects, but nothing in the math implies your
Provocatively, I might boil your position down to simply
asserting that the only thing I should be able to get out of
a matrix is a submatrix, and then being willing to break
some nice ndarray behavior that would be expected by most
new matrix users for no reason other than to enforce your
Since you offer NO MORE than an unfounded assertion, there
is really no reason to stop me from e.g. getting the i,j-th
element of a matrix as M[i][j]. Instead you want to just
break this (which is the current status).
Remember, you will still be able to extract the first row of
a matrix ``M`` as a **submatrix** using ``M[0,:]``.
No functionality would be lost under my proposed change.
In short, the behavior change I have requested will
- mean that habits formed using ndarrays transfer naturally
to the use of matrices
- increase functionality without removing any functionality
Breaking the nice behavior of ndarrays should have a really
strong justification. No real justification has been given
for breaking e.g. the ability to use M[i] to get the i-th
row as an array or M[i][j] to get the i,j-th element.
Oddly, the weak justifications that have been offered have
been offered by people who make little or no use of
matrices. This behavior has been broken arbitrarily.
The breakage removes useful functionality,
adds no new functionality,
needlessly decreases similarities between matrices and ndarrays,
and thereby surprises new users (e.g., my students) for no good reason.
As a final observation, I will note that status quo bias of
course works against making this change, but making this
desirable change by 1.1 will be easier than making it later.
More information about the Numpy-discussion