[PYTHON MATRIX-SIG] Newbie: transpose
Andrew P. Mullhaupt
Thu, 20 Mar 1997 21:40:02 -0500
David Ascher wrote:
> Transpose won't change the rank (number of dimensions, length of shape
> tuple), so the only way to go from an array of shape (1,3) to one of shape
> (3,) is to slice it.
> I hope this helps. One big issue when learning Numeric is that it is not
> MATLAB -- in other words, because it is designed to deal with arrays of
> arbitrary rank (and not just 2D matrices), some of the assumptions which
> make sense in a linear algebra context don't transfer all that well. The
> other issue I've had is to learn to assimilate what choose, where, etc.
> all do and not mix them up. That comes with practice.
Cautionary tale. S is a language which has handled arbitrary rank arrays
for quite a while - I think about twenty years. As recently as version
3.1 (a couple years ago), the behavior of S was the same as what Numeric
Python does now. However, by popular demand, it was changed so that the
transpose of a vector is a 1-column matrix. Note that this gives rise to
the strange situation where transpose is not an involution.
The present behavior of Numerical Python is probably correct, since that
is the way that APL handles this. For most operations on dense
multidimensional arrays, APL provides the best semantics, since they
have been at it longer than anyone else (34 years) and they thought
about it a lot. A really good rule of thumb is that you need an
_exceptionally_ good reason to deviate from APL semantics for dense
multidimensional array semantics or else you will simply find out the
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: firstname.lastname@example.org
administrivia to: email@example.com