[Numpy-discussion] matrix wart

Travis E. Oliphant oliphant@enthought....
Fri Feb 22 08:55:41 CST 2008

Konrad Hinsen wrote:
> On 22.02.2008, at 01:10, Alan G Isaac wrote:
>> Someone once pointed out on this list that one might
>> consider a matrix to be a container of 1d vectors.  For NumPy,
>> however, it is natural that it be a container of 1d arrays.
>> (See the discussion for the distinction.)
> If I were to design a Pythonic implementation of the mathematical  
> concept of a matrix, I'd implement three classes: Matrix,  
> ColumnVector, and RowVector. It would work like this:
> m = Matrix([[1, 2], [3, 4]])
> m[0, :] -->  ColumnVector([1, 3])
> m[:, 0] --> RowVector([1, 2])
These seem backward to me.    I would think that m[0,:] would be the 
RowVector([1,2]) and m[:,0] be the ColumnVector([1,3]).
> m[0,0] --> 1  # scalar
> m.shape --> (2, 2)
> m[0].shape --> (2,)
What is m[0] in this case?  The same as m[0, :]?
> However, the matrix implementation in Numeric was inspired by Matlab,  
> where everything is a matrix. But as I said before, Python is not  
> Matlab.
It should be kept in mind, however, that Matlab's matrix object is used 
successfully by a lot of people and should not be dismissed as irrelevant. 

I would like to see an improved Matrix object as a built-in type (for 
1.1).   I am aware of two implementations that could be referred to in 
creating it:  CVXOPT's matrix object and NumPy's matrix object.   There 
may be others as well.

If somebody has strong feelings about this sufficient to write a matrix 
built-in, then the door is wide open.



More information about the Numpy-discussion mailing list