[Numpy-discussion] array vs. matrix for matlab-compatible stuff

Travis Oliphant oliphant.travis at ieee.org
Thu Jan 19 11:26:02 CST 2006


Sven Schreiber wrote:

>I see, thanks for the quick answer. So wouldn't it be a good idea to have all the specifically
>matrix-related stuff (afaics, things in numpy/lib/twodim_base.py) return matrices?
>
>It seems my question (or misunderstanding) has a broader scope: Coming from matrix languages, I'm
>glad about short notations like A.I or A*B representing standard matrix operations. Much easier than
>linalg.inverse(A) or matrixmultiply(A,B). However, many matrix functions (decompositions etc.) seem
>to return arrays instead of matrices, even if you feed them matrices (is this assumption correct?).
>So you have to use mat(returned-result) again and again to be able to do return-result.I afterwards,
>which seems clumsy. So what's the best strategy here?
>  
>
Yes, some of them do still return arrays.  Matrices are longer lived in 
NumPy then the were in Numeric, for sure, but many functions still 
aren't friendly to matrices and convert all inputs to arrays before 
operation.   Originally, I had the asarray(...) function not convert 
matrices by default, but this is too surprising because matrices change 
the '*' and '**' operators which could make your function not work. 

We should convert all the functions that don't handle matrices so they 
will.  I'd like to see matrices survive longer than they do.   There are 
some functions that try to do that

-Travis





More information about the Numpy-discussion mailing list