[Numpy-discussion] matrices in 1.1
Stéfan van der Walt
Sat Mar 22 17:21:32 CDT 2008
On Sat, Mar 22, 2008 at 5:49 PM, Alan G Isaac <firstname.lastname@example.org> wrote:
> 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.
No, I agree with you that that is unintuitive -- but it can be solved
by introducing Row and ColumnVectors, which are still 2-dimensional.
One important result you don't want is:
In : x = np.array([[1,2,3],[4,5,6],[7,8,9]])
In : x[:,0]
Out: array([1, 4, 7])
But instead the current behaviour:
In : x = np.matrix([[1,2,3],[4,5,6]])
In : x[:,0]
> 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.
Do I understand correctly that you want M[0,:] and M to behave
differently? Would you like M to return the first element of the
matrix as in Octave? Is there a reason why the Column/Row-vector
solution wouldn't work for you?
> In short, the behavior change I have requested will
> - mean that habits formed using ndarrays transfer naturally
> to the use of matrices
But other habits, such as x[0,:] and x meaning the same thing,
won't transfer so well. So you're just swapping one set of
inconveniences for another.
I'm not trying to sabotage your proposal, I just want to understand it
better. If I'm the only one who is not completely satisfied, then
please, submit a patch and have it applied.
More information about the Numpy-discussion