[Numpy-discussion] suggestions for Matrix-related changes

Travis Oliphant oliphant at ee.byu.edu
Tue Jul 11 18:41:55 CDT 2006


JJ wrote:

>Hello.  For what its worth, as a newly ex-matlab user I would like to make a few
>suggestions on use of matrices in numpy.  As per earlier discussions, I like the
>idea of being able to choose matrices as the default (vs arrays).  But if
>possible, it would be nice if all functions etc that took matrices also returned
>matrices.  I know effort has been made on this.  Here are my suggestions:
>
>1) is it possible to get the function unique() to work with matrices, perhaps
>with a unique_rows() function to work with matrices of more than one column?
>
>2) It would be very convienient to have some simple way to delete selected
>columns of a matrix.  
>
This is a good idea.  It would be nice to address it at some point.  
There is a Python syntax for it, but we are not using it yet:

del X[...]

Of course one of the problems with this syntax (as opposed to a function 
that returns a new array) is that because X can share it's data with 
other arrays, you can't just re-size it's memory or other arrays 
depending on that chunk of memory will be in deep trouble.

So, we are probably not going to be able to have a "syntax-style" delete. 

But, some kind of function that returns an array with specific entries 
deleted would be nice.

>3) It would be nice if matrices could be used for iterations.  For example, if M
>was a 1 x n matrix, it would be nice to be able to use:  for i in M:  and
>iterate over the individual items in M.  
>  
>
They can be used as iterators.  The problem here is simply convention 
(rows are iterated over first).  We could over-ride the iterator 
behavior of matrices, though to handle 1xn and nx1 matrices identically 
if that is desirable.

>4) It would be nice if the linear algebra package and other packages returned
>matrices if given matrices.  For example, if M is a matrix, svd(M) now returns
>  
>
Svd returns matrices now.  Except for the list of singular values which 
is still an array.  Do you want a 1xn matrix instead of an array?

-Travis





More information about the Numpy-discussion mailing list