[Numpy-discussion] Matlab page on scipy wiki
Fernando Perez
Fernando.Perez at colorado.edu
Thu Feb 9 16:35:03 EST 2006
[ regarding the way of describing arrays vs. matlab's matrices, and the use of
'dimension', 'rank', 'number of axes', etc.]
Let's not introduce new terms where none are needed. These concepts have had
well-established names (tensor rank and matrix rank) for a long time. It may
be a good idea to add a local glossary page reminding anyone of what the
definitions are, but for as long as I remember reading literature on these
topics, the two terms have been fully unambiguous.
A numpy array with length(array.shape)==d is closest to a rank d tensor (minus
the geometric co/contravariance information). A d=2 array can be used to
represent a matrix, and linear algebra operations can be performed on it; if a
Matrix object is built out of it, a number of things (notably the * operator)
are then performed in the linear algebra sense (and not element-wise). The
rank of a matrix has nothing to do with the shape attribute of the underlying
array, but with the number of non-zero singular values (and for floating-point
matrices, is best defined up to a given tolerance).
Since numpy is a n-dimensional array package, it may be convenient to
introduce a matrix_rank() routine which does what matlab's rank() for 2-d
arrays and matrices, while raising an error for any other shape. This would
also make it explicit that this operation is only well-defined for 2-d objects.
My 1e-2,
f
More information about the NumPy-Discussion
mailing list