[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Difference between array( [1,0,1] ) and array( [ [1,0,1] ] )

Keep also in mind that numpy is quite different from Matlab.
In Matlab every vaiable is a matrix of at least 2 dimensions.

This is not the case of numpy (and is not the case in Fortran too).
every array can have a different number of dimensions. The transposition of an array with just 1 dimension is not really meaningful.
On the other hand most of the time is not needed.
For example le have a matrix:
a = np.array([[1,2],[1,1]])
and an array:
b = np.array([0.1,0.2])
You can left multiply or right multiply it to this matrix without any need to transpose it  (as you have to do in Matlab):
a @ b
b @ a