[Numpy-discussion] beginner question: rank-1 arrays

Sven Schreiber svetosch@gmx....
Tue Oct 9 01:36:27 CDT 2007


Alan G Isaac schrieb:
> On Mon, 8 Oct 2007, Robin apparently wrote:
>> However in my code (I am converting from MATLAB) it is 
>> important to maintain 2d arrays, and keep the difference 
>> between row and column vectors.
> 
> How about using matrices?
> help(numpy.mat)
> 
> hth,
> Alan Isaac
> 

Robin, Alan is right, you want numpy matrices which are always 2d. Check
out numpy.matlib; if you replace
from numpy import [whatever]
by
from numpy.matlib import [whatever]
you get everything there is in numpy, and things like ones() zeros()
empty() etc. will always be 2d matrices.

-sven



More information about the Numpy-discussion mailing list